@bailaya/react 1.0.38 → 1.0.39

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,168 +1,168 @@
1
- # @bailaya/react
2
-
3
- > A React component library and hooks for the BailaYa public API
4
-
5
- ## Overview
6
-
7
- `@bailaya/react` builds on top of **@bailaya/core** to provide:
8
-
9
- * A **`BailayaProvider`** + **`useBailayaClient`** context
10
- * React **hooks** for fetching all core data (with `loading`, `error`, `data`, and `refetch`)
11
- * **Components** with sensible Tailwind defaults (and full styling slots)
12
- * Full TypeScript support, including localized text & date formatting
13
-
14
- > Works **with or without Tailwind**. If you don’t use Tailwind, just override the class props (or use the render props) to apply your own styling.
15
-
16
- ## Features
17
-
18
- * **Context + client** (`BailayaProvider` + `useBailayaClient`)
19
- * **Hooks** (all return `{ data, error, loading, refetch }`)
20
-
21
- * `useStudioProfile(overrideId?)`
22
- * `useUserProfile(userId)`
23
- * `useInstructors(overrideId?)`
24
- * `useClasses(from?, overrideId?)`
25
- * `useClassesByType(typeName, from?, overrideId?)`
26
- * `useEvents(from?, overrideId?)`
27
- * **Components** (all props overridable)
28
-
29
- * `<StudioProfileCard />`
30
- * `<UserProfileCard />`
31
- * `<InstructorList />`
32
- * `<ClassSchedule />`
33
- * `<ClassScheduleByType />`
34
- * `<EventSchedule />`
35
- * `<StudioDescription />`
36
-
37
- ## Installation
38
-
39
- ```bash
40
- npm install @bailaya/react
41
- ```
42
-
43
- or with Yarn:
44
-
45
- ```bash
46
- yarn add @bailaya/react
47
- ```
48
-
49
- > **Peer Dependencies**
50
- >
51
- > * `"react": ">=17"`
52
- > * `"react-dom": ">=17"`
53
-
54
- ---
55
-
56
- ## Quick Start
57
-
58
- First, wrap your app with **BailayaProvider**:
59
-
60
- ```tsx
61
- // App.tsx
62
- import React from "react";
63
- import { BailayaProvider } from "@bailaya/react";
64
-
65
- export default function App() {
66
- return (
67
- <BailayaProvider config={{ studioId: "YOUR_STUDIO_ID" }}>
68
- {/* ...your app */}
69
- </BailayaProvider>
70
- );
71
- }
72
- ```
73
-
74
- ### Using a Hook
75
-
76
- ```tsx
77
- import React from "react";
78
- import { useInstructors } from "@bailaya/react";
79
-
80
- export function TeamSection() {
81
- const { data: instructors, loading, error, refetch } = useInstructors();
82
-
83
- if (loading) return <p>Loading...</p>;
84
- if (error) return <p>Error: {error.message}</p>;
85
-
86
- return (
87
- <>
88
- <button onClick={refetch}>Refresh</button>
89
- <ul>
90
- {instructors?.map((i) => (
91
- <li key={i.id}>{i.name} {i.lastname}</li>
92
- ))}
93
- </ul>
94
- </>
95
- );
96
- }
97
- ```
98
-
99
- ### Using a Component
100
-
101
- ```tsx
102
- import React from "react";
103
- import { StudioProfileCard } from "@bailaya/react";
104
-
105
- export function Dashboard() {
106
- return (
107
- <div className="max-w-md mx-auto">
108
- <StudioProfileCard locale="en" />
109
- </div>
110
- );
111
- }
112
- ```
113
-
114
- ---
115
-
116
- ## API Reference
117
-
118
- ### `<BailayaProvider config>`
119
-
120
- Provides `useBailayaClient()` context.
121
-
122
- * `config.baseUrl?: string` – override default API URL
123
- * `config.studioId?: string` – default studio ID
124
-
125
- ### Hooks
126
-
127
- All hooks return:
128
-
129
- ```ts
130
- {
131
- data: T | null;
132
- error: Error | null;
133
- loading: boolean;
134
- refetch: () => Promise<void>;
135
- }
136
- ```
137
-
138
- | Hook | Description |
139
- |--------------------------------------------------|--------------------------------------------------------------|
140
- | `useStudioProfile(overrideId?)` | Fetch a studio’s profile. |
141
- | `useUserProfile(userId)` | Fetch a user’s profile / bio. |
142
- | `useInstructors(overrideId?)` | Fetch list of active instructors (owner, admin, instructor). |
143
- | `useClasses(from?, overrideId?)` | Fetch next 7 days of classes (all types). |
144
- | `useClassesByType(typeName, from?, overrideId?)` | Fetch next 7 days of classes filtered by `typeName`. |
145
- | `useEvents(from?, overrideId?)` | Fetch next 7 days of events. |
146
-
147
- ### Components
148
-
149
- All components share:
150
-
151
- * **Override props** for every styling slot
152
- * **`locale`** (where relevant)
153
- * **`labels`** object for custom text (e.g. instructor or business-hours labels)
154
- * **`renderItem`** for full JSX override
155
-
156
- | Component | Props |
157
- |---------------------------| --------------------------------------------------------------------------------------------------------------------------------- |
158
- | `<StudioProfileCard />` | `overrideId?`, `locale?`, `labels?`, `className?`, `nameClassName?`, `descriptionClassName?`, `labelClassName?`, `renderProfile?` |
159
- | `<UserProfileCard />` | `userId`, `locale?`, `labels?`, `className?`, `nameClassName?`, `bioClassName?`, `renderProfile?` |
160
- | `<InstructorList />` | `overrideId?`, `renderItem?`, plus styling slots: `className?`, `itemClassName?`, `imageWrapperClassName?`, etc. |
161
- | `<ClassSchedule />` | `from?`, `overrideId?`, `locale?`, `labels?`, `renderItem?`, plus slots: `className?`, `itemClassName?`, etc. |
162
- | `<ClassScheduleByType />` | `typeName`, `from?`, `overrideId?`, `locale?`, `labels?`, `renderItem?`, plus same styling slots as `<ClassSchedule />`. |
163
- | `<EventSchedule />` | `from?`, `overrideId?`, `locale?`, `labels?`, `renderItem?`, plus slots: `className?`, `itemClassName?`, etc. |
164
- | `<StudioDescription />` | `overrideId?`, `locale?`, `render?`, plus styling slots: `className?`, `paragraphClassName?` |
165
-
166
- ## License
167
-
168
- ISC
1
+ # @bailaya/react
2
+
3
+ > A React component library and hooks for the BailaYa public API
4
+
5
+ ## Overview
6
+
7
+ `@bailaya/react` builds on top of **@bailaya/core** to provide:
8
+
9
+ * A **`BailayaProvider`** + **`useBailayaClient`** context
10
+ * React **hooks** for fetching all core data (with `loading`, `error`, `data`, and `refetch`)
11
+ * **Components** with sensible Tailwind defaults (and full styling slots)
12
+ * Full TypeScript support, including localized text & date formatting
13
+
14
+ > Works **with or without Tailwind**. If you don’t use Tailwind, just override the class props (or use the render props) to apply your own styling.
15
+
16
+ ## Features
17
+
18
+ * **Context + client** (`BailayaProvider` + `useBailayaClient`)
19
+ * **Hooks** (all return `{ data, error, loading, refetch }`)
20
+
21
+ * `useStudioProfile(overrideId?)`
22
+ * `useUserProfile(userId)`
23
+ * `useInstructors(overrideId?)`
24
+ * `useClasses(from?, overrideId?)`
25
+ * `useClassesByType(typeName, from?, overrideId?)`
26
+ * `useEvents(from?, overrideId?)`
27
+ * **Components** (all props overridable)
28
+
29
+ * `<StudioProfileCard />`
30
+ * `<UserProfileCard />`
31
+ * `<InstructorList />`
32
+ * `<ClassSchedule />`
33
+ * `<ClassScheduleByType />`
34
+ * `<EventSchedule />`
35
+ * `<StudioDescription />`
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ npm install @bailaya/react
41
+ ```
42
+
43
+ or with Yarn:
44
+
45
+ ```bash
46
+ yarn add @bailaya/react
47
+ ```
48
+
49
+ > **Peer Dependencies**
50
+ >
51
+ > * `"react": ">=17"`
52
+ > * `"react-dom": ">=17"`
53
+
54
+ ---
55
+
56
+ ## Quick Start
57
+
58
+ First, wrap your app with **BailayaProvider**:
59
+
60
+ ```tsx
61
+ // App.tsx
62
+ import React from "react";
63
+ import { BailayaProvider } from "@bailaya/react";
64
+
65
+ export default function App() {
66
+ return (
67
+ <BailayaProvider config={{ studioId: "YOUR_STUDIO_ID" }}>
68
+ {/* ...your app */}
69
+ </BailayaProvider>
70
+ );
71
+ }
72
+ ```
73
+
74
+ ### Using a Hook
75
+
76
+ ```tsx
77
+ import React from "react";
78
+ import { useInstructors } from "@bailaya/react";
79
+
80
+ export function TeamSection() {
81
+ const { data: instructors, loading, error, refetch } = useInstructors();
82
+
83
+ if (loading) return <p>Loading...</p>;
84
+ if (error) return <p>Error: {error.message}</p>;
85
+
86
+ return (
87
+ <>
88
+ <button onClick={refetch}>Refresh</button>
89
+ <ul>
90
+ {instructors?.map((i) => (
91
+ <li key={i.id}>{i.name} {i.lastname}</li>
92
+ ))}
93
+ </ul>
94
+ </>
95
+ );
96
+ }
97
+ ```
98
+
99
+ ### Using a Component
100
+
101
+ ```tsx
102
+ import React from "react";
103
+ import { StudioProfileCard } from "@bailaya/react";
104
+
105
+ export function Dashboard() {
106
+ return (
107
+ <div className="max-w-md mx-auto">
108
+ <StudioProfileCard locale="en" />
109
+ </div>
110
+ );
111
+ }
112
+ ```
113
+
114
+ ---
115
+
116
+ ## API Reference
117
+
118
+ ### `<BailayaProvider config>`
119
+
120
+ Provides `useBailayaClient()` context.
121
+
122
+ * `config.baseUrl?: string` – override default API URL
123
+ * `config.studioId?: string` – default studio ID
124
+
125
+ ### Hooks
126
+
127
+ All hooks return:
128
+
129
+ ```ts
130
+ {
131
+ data: T | null;
132
+ error: Error | null;
133
+ loading: boolean;
134
+ refetch: () => Promise<void>;
135
+ }
136
+ ```
137
+
138
+ | Hook | Description |
139
+ |--------------------------------------------------|--------------------------------------------------------------|
140
+ | `useStudioProfile(overrideId?)` | Fetch a studio’s profile. |
141
+ | `useUserProfile(userId)` | Fetch a user’s profile / bio. |
142
+ | `useInstructors(overrideId?)` | Fetch list of active instructors (owner, admin, instructor). |
143
+ | `useClasses(from?, overrideId?)` | Fetch next 7 days of classes (all types). |
144
+ | `useClassesByType(typeName, from?, overrideId?)` | Fetch next 7 days of classes filtered by `typeName`. |
145
+ | `useEvents(from?, overrideId?)` | Fetch next 7 days of events. |
146
+
147
+ ### Components
148
+
149
+ All components share:
150
+
151
+ * **Override props** for every styling slot
152
+ * **`locale`** (where relevant)
153
+ * **`labels`** object for custom text (e.g. instructor or business-hours labels)
154
+ * **`renderItem`** for full JSX override
155
+
156
+ | Component | Props |
157
+ |---------------------------| --------------------------------------------------------------------------------------------------------------------------------- |
158
+ | `<StudioProfileCard />` | `overrideId?`, `locale?`, `labels?`, `className?`, `nameClassName?`, `descriptionClassName?`, `labelClassName?`, `renderProfile?` |
159
+ | `<UserProfileCard />` | `userId`, `locale?`, `labels?`, `className?`, `nameClassName?`, `bioClassName?`, `renderProfile?` |
160
+ | `<InstructorList />` | `overrideId?`, `renderItem?`, plus styling slots: `className?`, `itemClassName?`, `imageWrapperClassName?`, etc. |
161
+ | `<ClassSchedule />` | `from?`, `overrideId?`, `locale?`, `labels?`, `renderItem?`, plus slots: `className?`, `itemClassName?`, etc. |
162
+ | `<ClassScheduleByType />` | `typeName`, `from?`, `overrideId?`, `locale?`, `labels?`, `renderItem?`, plus same styling slots as `<ClassSchedule />`. |
163
+ | `<EventSchedule />` | `from?`, `overrideId?`, `locale?`, `labels?`, `renderItem?`, plus slots: `className?`, `itemClassName?`, etc. |
164
+ | `<StudioDescription />` | `overrideId?`, `locale?`, `render?`, plus styling slots: `className?`, `paragraphClassName?` |
165
+
166
+ ## License
167
+
168
+ ISC
@@ -74,7 +74,7 @@ const ClassSchedule = ({ from, overrideId, locale, currency, labels = {}, classN
74
74
  cls.instructor.name,
75
75
  cls.instructor.lastname ? ` ${cls.instructor.lastname}` : "")))),
76
76
  react_1.default.createElement("div", { className: rightClassName },
77
- Number.isFinite(cls.price) && (react_1.default.createElement("div", { className: priceClassName }, priceText)),
77
+ Number.isFinite(cls.price) && cls.price > 0.0 && (react_1.default.createElement("div", { className: priceClassName }, priceText)),
78
78
  !hideBookButton &&
79
79
  (renderLink ? (renderLink({
80
80
  href,
@@ -83,7 +83,7 @@ const ClassScheduleByType = ({ typeName, from, overrideId, locale, currency, lab
83
83
  ? ` ${cls.instructor.lastname}`
84
84
  : "")))),
85
85
  react_1.default.createElement("div", { className: rightClassName },
86
- Number.isFinite(cls.price) && (react_1.default.createElement("div", { className: priceClassName }, priceText)),
86
+ Number.isFinite(cls.price) && cls.price > 0.0 && (react_1.default.createElement("div", { className: priceClassName }, priceText)),
87
87
  !hideBookButton &&
88
88
  (renderLink ? (renderLink({
89
89
  href,
package/package.json CHANGED
@@ -1,39 +1,39 @@
1
- {
2
- "name": "@bailaya/react",
3
- "version": "1.0.38",
4
- "description": "A React component library for the BailaYa public API",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "exports": {
8
- ".": "./dist/index.js",
9
- "./styles.css": "./dist/styles.css"
10
- },
11
- "files": [
12
- "dist"
13
- ],
14
- "scripts": {
15
- "build": "tsc --build && npm run copy:css",
16
- "copy:css": "copyfiles -u 1 \"src/**/*.css\" dist",
17
- "test": "jest"
18
- },
19
- "peerDependencies": {
20
- "react": ">=17.0.0 <20.0.0",
21
- "react-dom": ">=17.0.0 <20.0.0"
22
- },
23
- "devDependencies": {
24
- "@types/jest": "^30.0.0",
25
- "@types/react": "^18.0.0",
26
- "@types/react-dom": "^18.0.0",
27
- "copyfiles": "^2.4.1",
28
- "jest": "^30.0.5",
29
- "react": "^18.2.0",
30
- "react-dom": "^18.2.0",
31
- "ts-jest": "^29.4.0",
32
- "typescript": "^5.8.3"
33
- },
34
- "dependencies": {
35
- "@bailaya/core": "^1.0.9",
36
- "lucide-react": "^0.536.0"
37
- },
38
- "license": "ISC"
39
- }
1
+ {
2
+ "name": "@bailaya/react",
3
+ "version": "1.0.39",
4
+ "description": "A React component library for the BailaYa public API",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": "./dist/index.js",
9
+ "./styles.css": "./dist/styles.css"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc --build && npm run copy:css",
16
+ "copy:css": "copyfiles -u 1 \"src/**/*.css\" dist",
17
+ "test": "jest"
18
+ },
19
+ "peerDependencies": {
20
+ "react": ">=17.0.0 <20.0.0",
21
+ "react-dom": ">=17.0.0 <20.0.0"
22
+ },
23
+ "devDependencies": {
24
+ "@types/jest": "^30.0.0",
25
+ "@types/react": "^18.0.0",
26
+ "@types/react-dom": "^18.0.0",
27
+ "copyfiles": "^2.4.1",
28
+ "jest": "^30.0.5",
29
+ "react": "^18.2.0",
30
+ "react-dom": "^18.2.0",
31
+ "ts-jest": "^29.4.0",
32
+ "typescript": "^5.8.3"
33
+ },
34
+ "dependencies": {
35
+ "@bailaya/core": "^1.0.9",
36
+ "lucide-react": "^0.536.0"
37
+ },
38
+ "license": "ISC"
39
+ }