@anker-in/ui 0.1.5 → 0.1.8

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 CHANGED
@@ -1,55 +1,187 @@
1
- # @anker-dtc/ui
1
+ # @anker-in/ui
2
2
 
3
- React UI components with Tailwind CSS for Anker DTC projects.
3
+ React UI components library for demo room booking system with full TypeScript support.
4
4
 
5
- ## Installation
5
+ ## Features
6
6
 
7
- ### For Production (via npm/pnpm)
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
- When installing from npm registry, all dependencies will be automatically installed:
14
+ ## Installation
10
15
 
11
16
  ```bash
12
- pnpm add @anker-dtc/ui
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
- ### For Development (via pnpm link)
24
+ ### Required Dependencies
16
25
 
17
- When using `pnpm link` for local development, you need to manually install the required dependencies in your Next.js project:
26
+ The package requires the following peer dependencies:
18
27
 
19
28
  ```bash
20
- # Required dependencies
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
- ## Usage
32
+ ## Quick Start
33
+
34
+ ### 1. Import Styles
35
+
36
+ ```tsx
37
+ import '@anker-in/ui/styles.css'
38
+ ```
28
39
 
29
- ### Import Components
40
+ ### 2. Use Components
30
41
 
31
42
  ```tsx
32
- import { DemoRoom } from '@anker-dtc/ui/demo-room'
33
- import '@anker-dtc/ui/styles.css'
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
- ### Next.js Configuration
86
+ ## Multi-language Support
87
+
88
+ All components support customizable text through the `pageData` prop:
37
89
 
38
- Add `@anker-dtc/ui` to `transpilePackages` in your `next.config.js`:
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-dtc/ui'],
43
- // ... other config
157
+ transpilePackages: ['@anker-in/ui'],
44
158
  }
45
159
  ```
46
160
 
47
- ## Available Exports
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
- - `@anker-dtc/ui` - Main components
50
- - `@anker-dtc/ui/demo-room` - Demo room components
51
- - `@anker-dtc/ui/theme` - Theme configuration
52
- - `@anker-dtc/ui/styles.css` - CSS styles
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
- ## Link for Local Development
202
+ ## Version
74
203
 
75
- ```bash
76
- # In this package directory
77
- pnpm link --global
204
+ Current version: **0.1.6**
78
205
 
79
- # In your Next.js project
80
- pnpm link --global @anker-dtc/ui
206
+ ## License
81
207
 
82
- # Don't forget to install the required dependencies (see above)
83
- ```
208
+ ISC
@@ -0,0 +1,85 @@
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
+ /**
20
+ * 位置筛选相关文案
21
+ */
22
+ locationFilter?: {
23
+ allLocations?: string;
24
+ clear?: string;
25
+ country?: string;
26
+ state?: string;
27
+ city?: string;
28
+ noStudiosFound?: string;
29
+ };
30
+ /**
31
+ * 工作室卡片相关文案
32
+ */
33
+ studioCard?: {
34
+ scheduleNow?: string;
35
+ available?: string;
36
+ away?: string;
37
+ };
38
+ /**
39
+ * 地图相关文案
40
+ */
41
+ map?: {
42
+ apiKeyRequired?: string;
43
+ loadingMap?: string;
44
+ scheduleNow?: string;
45
+ available?: string;
46
+ };
47
+ /**
48
+ * 其他配置
49
+ */
50
+ defaultCountry?: string;
51
+ noAvailableTime?: string;
52
+ }
53
+
54
+ interface DemoRoomProps extends React.HTMLAttributes<HTMLDivElement> {
55
+ layoutClassName?: string;
56
+ /**
57
+ * 谷歌地图 API Key
58
+ */
59
+ googleMapsApiKey?: string;
60
+ /**
61
+ * API 配置
62
+ */
63
+ apiConfig: {
64
+ baseUrl: string;
65
+ apiKey: string;
66
+ locale?: string;
67
+ };
68
+ /**
69
+ * 团队编码或品牌站点(二选一)
70
+ */
71
+ teamCode?: string;
72
+ brandWebsite?: string;
73
+ /**
74
+ * Callback when user clicks "Schedule Now" button
75
+ * @param demoRoomCode - The demo room code
76
+ */
77
+ onSchedule?: (demoRoomCode: string) => void;
78
+ /**
79
+ * 页面可配置数据(文案、图标等)
80
+ */
81
+ pageData?: DemoRoomPageData;
82
+ }
83
+ declare const DemoRoom: React.FC<DemoRoomProps>;
84
+
85
+ export { DemoRoom as D, type DemoRoomProps as a, type DemoRoomPageData as b };
@@ -0,0 +1,85 @@
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
+ /**
20
+ * 位置筛选相关文案
21
+ */
22
+ locationFilter?: {
23
+ allLocations?: string;
24
+ clear?: string;
25
+ country?: string;
26
+ state?: string;
27
+ city?: string;
28
+ noStudiosFound?: string;
29
+ };
30
+ /**
31
+ * 工作室卡片相关文案
32
+ */
33
+ studioCard?: {
34
+ scheduleNow?: string;
35
+ available?: string;
36
+ away?: string;
37
+ };
38
+ /**
39
+ * 地图相关文案
40
+ */
41
+ map?: {
42
+ apiKeyRequired?: string;
43
+ loadingMap?: string;
44
+ scheduleNow?: string;
45
+ available?: string;
46
+ };
47
+ /**
48
+ * 其他配置
49
+ */
50
+ defaultCountry?: string;
51
+ noAvailableTime?: string;
52
+ }
53
+
54
+ interface DemoRoomProps extends React.HTMLAttributes<HTMLDivElement> {
55
+ layoutClassName?: string;
56
+ /**
57
+ * 谷歌地图 API Key
58
+ */
59
+ googleMapsApiKey?: string;
60
+ /**
61
+ * API 配置
62
+ */
63
+ apiConfig: {
64
+ baseUrl: string;
65
+ apiKey: string;
66
+ locale?: string;
67
+ };
68
+ /**
69
+ * 团队编码或品牌站点(二选一)
70
+ */
71
+ teamCode?: string;
72
+ brandWebsite?: string;
73
+ /**
74
+ * Callback when user clicks "Schedule Now" button
75
+ * @param demoRoomCode - The demo room code
76
+ */
77
+ onSchedule?: (demoRoomCode: string) => void;
78
+ /**
79
+ * 页面可配置数据(文案、图标等)
80
+ */
81
+ pageData?: DemoRoomPageData;
82
+ }
83
+ declare const DemoRoom: React.FC<DemoRoomProps>;
84
+
85
+ export { DemoRoom as D, type DemoRoomProps as a, type DemoRoomPageData as b };
@@ -1,4 +1,4 @@
1
- export { D as DemoRoom, a as DemoRoomProps } from './DemoRoom-CZyrsxWe.mjs';
1
+ export { D as DemoRoom, b as DemoRoomPageData, a as DemoRoomProps } from './DemoRoom-Dx3PluHP.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
 
@@ -1,4 +1,4 @@
1
- export { D as DemoRoom, a as DemoRoomProps } from './DemoRoom-CZyrsxWe.js';
1
+ export { D as DemoRoom, b as DemoRoomPageData, a as DemoRoomProps } from './DemoRoom-Dx3PluHP.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