@docsplain-kit/core 0.0.50 → 0.0.51

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
@@ -26,3 +26,39 @@ Get started with DocSplain Core in seconds:
26
26
  ```bash
27
27
  npm install --save @docsplain-kit/core
28
28
  ```
29
+
30
+ ---
31
+
32
+ ## 🔄 **Using in Server Components (Next.js App Router)**
33
+
34
+ All Docsplain UI Kit components are client components. To use them in server components, create a client wrapper file:
35
+
36
+ ```tsx
37
+ // components/docsplain.tsx
38
+ 'use client';
39
+
40
+ export {
41
+ Tab,
42
+ TabItem,
43
+ Button,
44
+ // ... other components
45
+ } from '@docsplain-kit/core';
46
+ ```
47
+
48
+ Then use in your server components:
49
+
50
+ ```tsx
51
+ // app/page.tsx (Server Component)
52
+ import { Tab, TabItem } from './components/docsplain';
53
+
54
+ export default function Page() {
55
+ return (
56
+ <Tab selectedValue="tab1" onTabSelect={() => {}}>
57
+ <TabItem value="tab1">Home</TabItem>
58
+ <TabItem value="tab2">About</TabItem>
59
+ </Tab>
60
+ );
61
+ }
62
+ ```
63
+
64
+ 📖 **See [SERVER_COMPONENTS.md](./SERVER_COMPONENTS.md) for a complete guide** with examples, best practices, and troubleshooting.
@@ -0,0 +1,256 @@
1
+ # Using Docsplain UI Kit in Server Components
2
+
3
+ ## Overview
4
+
5
+ All components in the Docsplain UI Kit are client components (they use `'use client'` directive) because they require React hooks, interactivity, and browser APIs. When using Next.js App Router or other React Server Components frameworks, you cannot directly import client components into server components.
6
+
7
+ ## Solution: Client Component Wrappers
8
+
9
+ The recommended approach is to create client component wrappers that you can import in your server components. This guide shows you how to do this effectively.
10
+
11
+ ## Quick Start
12
+
13
+ ### Method 1: Create Individual Client Wrappers
14
+
15
+ Create a `components` directory in your project and create client wrapper files:
16
+
17
+ ```typescript
18
+ // components/client-tab.tsx
19
+ 'use client';
20
+
21
+ import { Tab, TabItem } from '@docsplain-kit/core';
22
+
23
+ export { Tab, TabItem };
24
+ ```
25
+
26
+ Then use it in your server component:
27
+
28
+ ```typescript
29
+ // app/page.tsx (Server Component)
30
+ import { Tab, TabItem } from './components/client-tab';
31
+
32
+ export default function Page() {
33
+ return (
34
+ <Tab selectedValue="tab1" onTabSelect={() => {}}>
35
+ <TabItem value="tab1">Home</TabItem>
36
+ <TabItem value="tab2">About</TabItem>
37
+ </Tab>
38
+ );
39
+ }
40
+ ```
41
+
42
+ ### Method 2: Use the Client Wrapper Utility
43
+
44
+ We provide a utility to help you create client wrappers more easily:
45
+
46
+ ```typescript
47
+ // components/docsplain-client.tsx
48
+ 'use client';
49
+
50
+ import { createClientWrapper } from '@docsplain-kit/core/server';
51
+
52
+ // Export all components you need
53
+ export const {
54
+ Tab,
55
+ TabItem,
56
+ Button,
57
+ Checkbox,
58
+ // ... other components
59
+ } = createClientWrapper({
60
+ Tab: () => import('@docsplain-kit/core'),
61
+ TabItem: () => import('@docsplain-kit/core'),
62
+ Button: () => import('@docsplain-kit/core'),
63
+ Checkbox: () => import('@docsplain-kit/core'),
64
+ });
65
+ ```
66
+
67
+ ### Method 3: Create a Single Client Barrel File
68
+
69
+ Create a single file that re-exports all components you need:
70
+
71
+ ```typescript
72
+ // components/docsplain.tsx
73
+ 'use client';
74
+
75
+ // Re-export all components you need
76
+ export {
77
+ Tab,
78
+ TabItem,
79
+ Button,
80
+ Checkbox,
81
+ Label,
82
+ TextInput,
83
+ Select,
84
+ // ... add other components as needed
85
+ } from '@docsplain-kit/core';
86
+
87
+ // Re-export provider and hooks
88
+ export {
89
+ DocsplainProvider,
90
+ useTheme,
91
+ useDocsplain,
92
+ } from '@docsplain-kit/core';
93
+ ```
94
+
95
+ Then use it in your server components:
96
+
97
+ ```typescript
98
+ // app/page.tsx (Server Component)
99
+ import { Tab, TabItem } from './components/docsplain';
100
+
101
+ export default function Page() {
102
+ return (
103
+ <Tab selectedValue="tab1" onTabSelect={() => {}}>
104
+ <TabItem value="tab1">Home</TabItem>
105
+ <TabItem value="tab2">About</TabItem>
106
+ </Tab>
107
+ );
108
+ }
109
+ ```
110
+
111
+ ## Complete Example: Next.js App Router
112
+
113
+ Here's a complete example showing how to structure your Next.js app:
114
+
115
+ ### Project Structure
116
+
117
+ ```
118
+ app/
119
+ layout.tsx # Server Component
120
+ page.tsx # Server Component
121
+ components/
122
+ docsplain.tsx # Client Component (wrapper)
123
+ client-tab.tsx # Client Component (specific wrapper)
124
+ ```
125
+
126
+ ### 1. Create Client Wrapper
127
+
128
+ ```typescript
129
+ // components/docsplain.tsx
130
+ 'use client';
131
+
132
+ export {
133
+ Tab,
134
+ TabItem,
135
+ Button,
136
+ Checkbox,
137
+ Label,
138
+ TextInput,
139
+ DocsplainProvider,
140
+ useTheme,
141
+ } from '@docsplain-kit/core';
142
+ ```
143
+
144
+ ### 2. Use in Server Component
145
+
146
+ ```typescript
147
+ // app/page.tsx
148
+ import { Tab, TabItem } from '../components/docsplain';
149
+
150
+ export default function Page() {
151
+ // This is a server component - you can do server-side work here
152
+ const data = await fetchData(); // Server-side data fetching
153
+
154
+ return (
155
+ <div>
156
+ <h1>Server Component Page</h1>
157
+ <Tab selectedValue="tab1" onTabSelect={() => {}}>
158
+ <TabItem value="tab1">Home</TabItem>
159
+ <TabItem value="tab2">About</TabItem>
160
+ </Tab>
161
+ </div>
162
+ );
163
+ }
164
+ ```
165
+
166
+ ### 3. Wrap with Provider (in Layout)
167
+
168
+ ```typescript
169
+ // app/layout.tsx
170
+ import { DocsplainProvider } from '../components/docsplain';
171
+
172
+ export default function RootLayout({ children }) {
173
+ return (
174
+ <html>
175
+ <body>
176
+ <DocsplainProvider theme="light" dir="ltr">
177
+ {children}
178
+ </DocsplainProvider>
179
+ </body>
180
+ </html>
181
+ );
182
+ }
183
+ ```
184
+
185
+ ## Advanced: Dynamic Imports with SSR Disabled
186
+
187
+ For components that don't need SSR, you can use dynamic imports:
188
+
189
+ ```typescript
190
+ // app/page.tsx
191
+ import dynamic from 'next/dynamic';
192
+
193
+ const Tab = dynamic(
194
+ () => import('@docsplain-kit/core').then(mod => mod.Tab),
195
+ { ssr: false }
196
+ );
197
+
198
+ const TabItem = dynamic(
199
+ () => import('@docsplain-kit/core').then(mod => mod.TabItem),
200
+ { ssr: false }
201
+ );
202
+
203
+ export default function Page() {
204
+ return (
205
+ <Tab selectedValue="tab1" onTabSelect={() => {}}>
206
+ <TabItem value="tab1">Home</TabItem>
207
+ <TabItem value="tab2">About</TabItem>
208
+ </Tab>
209
+ );
210
+ }
211
+ ```
212
+
213
+ **Note:** This approach disables SSR for these components, which may not be ideal for SEO and initial load performance.
214
+
215
+ ## Best Practices
216
+
217
+ 1. **Create a Single Client Barrel File**: Instead of creating individual wrappers for each component, create one file that exports all components you need. This is easier to maintain.
218
+
219
+ 2. **Keep Server Components as Server Components**: Only create client wrappers when you actually need to use client components. Keep as much of your app as server components as possible.
220
+
221
+ 3. **Use the Provider in Layout**: Wrap your app with `DocsplainProvider` in your root layout so all components have access to theme and configuration.
222
+
223
+ 4. **Organize by Feature**: If you have many components, you can organize them by feature:
224
+ ```typescript
225
+ // components/forms.tsx
226
+ 'use client';
227
+ export { TextInput, Select, Checkbox, Label } from '@docsplain-kit/core';
228
+
229
+ // components/navigation.tsx
230
+ 'use client';
231
+ export { Tab, TabItem, Button } from '@docsplain-kit/core';
232
+ ```
233
+
234
+ ## Troubleshooting
235
+
236
+ ### Error: "use client" must be in a file that only exports client components
237
+
238
+ **Solution**: Make sure your wrapper file has `'use client'` at the very top and only exports client components. Don't mix server and client code in the same file.
239
+
240
+ ### Error: Cannot use hooks in server components
241
+
242
+ **Solution**: If you need to use hooks (like `useState`, `useEffect`), you must use them in a client component. Create a client wrapper component that uses the hooks, then use that wrapper in your server component.
243
+
244
+ ### Components not rendering on server
245
+
246
+ **Solution**: This is expected behavior. Client components are hydrated on the client side. If you need server-side rendering, consider using the dynamic import approach with `ssr: true` (though this may not work for all components that rely heavily on browser APIs).
247
+
248
+ ## Summary
249
+
250
+ - All Docsplain UI Kit components are client components
251
+ - Create client wrapper files with `'use client'` directive
252
+ - Import from your wrappers in server components
253
+ - Use a single barrel file for easier maintenance
254
+ - Wrap your app with `DocsplainProvider` in the root layout
255
+
256
+ This approach allows you to use all Docsplain UI Kit components in your server components while maintaining the benefits of React Server Components.
package/index.d.ts CHANGED
@@ -42,3 +42,4 @@ import Tooltip from './tooltip/tooltip';
42
42
  export { DocsplainProvider, useDocsplain, useFontSize, useResponsiveFontSize, useTextDirection, useTextScale, useTheme, } from './provider';
43
43
  export type { DocsplainConfig, DocsplainProviderProps, TextDirection, TextScale, Theme, } from './provider';
44
44
  export { Accordion, AccordionContent, AccordionHeader, AccordionItem, Alert, AutoComplete, Avatar, Badge, Button, Card, CardBody, CardHeader, CardFooter, Checkbox, Chip, Div, Divider, Label, List, ListItem, Media, Modal, MousePopup, MultiSelect, Popper, PopperContent, PopperHandler, RadioButton, Select, Skeleton, Slider, Snackbar, Spinner, SwitchBox, Tab, TabItem, Text, Textarea, TextInput, Tooltip, twMerge, };
45
+ export { createClientWrapper, generateClientWrapper, clientWrapperTemplates, type ComponentImport, } from './server';
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
- exports.twMerge = exports.Tooltip = exports.TextInput = exports.Textarea = exports.Text = exports.TabItem = exports.Tab = exports.SwitchBox = exports.Spinner = exports.Snackbar = exports.Slider = exports.Skeleton = exports.Select = exports.RadioButton = exports.PopperHandler = exports.PopperContent = exports.Popper = exports.MultiSelect = exports.MousePopup = exports.Modal = exports.Media = exports.ListItem = exports.List = exports.Label = exports.Divider = exports.Div = exports.Chip = exports.Checkbox = exports.CardFooter = exports.CardHeader = exports.CardBody = exports.Card = exports.Button = exports.Badge = exports.Avatar = exports.AutoComplete = exports.Alert = exports.AccordionItem = exports.AccordionHeader = exports.AccordionContent = exports.Accordion = exports.useTheme = exports.useTextScale = exports.useTextDirection = exports.useResponsiveFontSize = exports.useFontSize = exports.useDocsplain = exports.DocsplainProvider = void 0;
3
+ exports.generateClientWrapper = exports.createClientWrapper = exports.twMerge = exports.Tooltip = exports.TextInput = exports.Textarea = exports.Text = exports.TabItem = exports.Tab = exports.SwitchBox = exports.Spinner = exports.Snackbar = exports.Slider = exports.Skeleton = exports.Select = exports.RadioButton = exports.PopperHandler = exports.PopperContent = exports.Popper = exports.MultiSelect = exports.MousePopup = exports.Modal = exports.Media = exports.ListItem = exports.List = exports.Label = exports.Divider = exports.Div = exports.Chip = exports.Checkbox = exports.CardFooter = exports.CardHeader = exports.CardBody = exports.Card = exports.Button = exports.Badge = exports.Avatar = exports.AutoComplete = exports.Alert = exports.AccordionItem = exports.AccordionHeader = exports.AccordionContent = exports.Accordion = exports.useTheme = exports.useTextScale = exports.useTextDirection = exports.useResponsiveFontSize = exports.useFontSize = exports.useDocsplain = exports.DocsplainProvider = void 0;
4
+ exports.clientWrapperTemplates = void 0;
4
5
  var tslib_1 = require("tslib");
5
6
  var accordion_1 = tslib_1.__importDefault(require("./accordion/accordion"));
6
7
  exports.Accordion = accordion_1["default"];
@@ -93,4 +94,9 @@ tslib_1.__createBinding(exports, provider_1, "useResponsiveFontSize");
93
94
  tslib_1.__createBinding(exports, provider_1, "useTextDirection");
94
95
  tslib_1.__createBinding(exports, provider_1, "useTextScale");
95
96
  tslib_1.__createBinding(exports, provider_1, "useTheme");
97
+ // Server Component Utilities
98
+ var server_1 = require("./server");
99
+ tslib_1.__createBinding(exports, server_1, "createClientWrapper");
100
+ tslib_1.__createBinding(exports, server_1, "generateClientWrapper");
101
+ tslib_1.__createBinding(exports, server_1, "clientWrapperTemplates");
96
102
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;AAAA,4EAA8C;AA6D5C,oBA7DK,sBAAS,CA6DL;AA5DX,8GAA+E;AA6D7E,2BA7DK,8BAAgB,CA6DL;AA5DlB,2GAA4E;AA6D1E,0BA7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CA2DL;AA1DT,iEAAkD;AA+DhD,kBA/DO,+BAAO,CA+DP;AA9DT,+EAAgD;AA4D9C,oBA5DK,uBAAS,CA4DL;AA3DX,6DAA+B;AAyD7B,eAzDK,iBAAI,CAyDL;AAxDN,yEAA2C;AAyDzC,mBAzDK,qBAAQ,CAyDL;AAxDV,sEAAwC;AA0DtC,kBA1DK,oBAAO,CA0DL;AAxDT,WAAW;AACX,uCAQoB;AAPlB,kEAAiB;AACjB,6DAAY;AACZ,4DAAW;AACX,sEAAqB;AACrB,iEAAgB;AAChB,6DAAY;AACZ,yDAAQ;AAoDV,6BAA6B;AAC7B,mCAKkB;AAJhB,kEAAmB;AACnB,oEAAqB;AACrB,qEAAsB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docsplain-kit/core",
3
- "version": "0.0.50",
3
+ "version": "0.0.51",
4
4
  "main": "./index.js",
5
5
  "module": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Client Wrapper Utility
3
+ *
4
+ * This utility helps create client component wrappers for use in server components.
5
+ * Since all Docsplain UI Kit components are client components, you need to create
6
+ * wrapper files with 'use client' directive to use them in server components.
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * // components/docsplain.tsx
11
+ * 'use client';
12
+ *
13
+ * export {
14
+ * Tab,
15
+ * TabItem,
16
+ * Button,
17
+ * } from '@docsplain-kit/core';
18
+ * ```
19
+ *
20
+ * Then use in server components:
21
+ * ```tsx
22
+ * // app/page.tsx
23
+ * import { Tab, TabItem } from './components/docsplain';
24
+ *
25
+ * export default function Page() {
26
+ * return (
27
+ * <Tab selectedValue="tab1" onTabSelect={() => {}}>
28
+ * <TabItem value="tab1">Home</TabItem>
29
+ * </Tab>
30
+ * );
31
+ * }
32
+ * ```
33
+ */
34
+ import React from 'react';
35
+ /**
36
+ * Type for component imports
37
+ */
38
+ export type ComponentImport<T = any> = () => Promise<{
39
+ default?: T;
40
+ [key: string]: T | any;
41
+ }>;
42
+ /**
43
+ * Configuration for creating client wrappers
44
+ */
45
+ interface ClientWrapperConfig {
46
+ [componentName: string]: ComponentImport;
47
+ }
48
+ /**
49
+ * Creates client component wrappers from dynamic imports
50
+ *
51
+ * This is useful when you want to lazy-load components or create
52
+ * wrappers that can be used in server components.
53
+ *
54
+ * @param config - Object mapping component names to their import functions
55
+ * @returns Object with component wrappers
56
+ *
57
+ * @example
58
+ * ```tsx
59
+ * const { Tab, TabItem } = createClientWrapper({
60
+ * Tab: () => import('@docsplain-kit/core').then(mod => ({ default: mod.Tab })),
61
+ * TabItem: () => import('@docsplain-kit/core').then(mod => ({ default: mod.TabItem })),
62
+ * });
63
+ * ```
64
+ */
65
+ export declare function createClientWrapper<T extends ClientWrapperConfig>(config: T): {
66
+ [K in keyof T]: React.ComponentType<any>;
67
+ };
68
+ /**
69
+ * Helper to create a simple client wrapper file content
70
+ *
71
+ * This generates the content for a client wrapper file that you can
72
+ * copy into your project.
73
+ *
74
+ * @param componentNames - Array of component names to export
75
+ * @returns String content for the wrapper file
76
+ *
77
+ * @example
78
+ * ```tsx
79
+ * const content = generateClientWrapper(['Tab', 'TabItem', 'Button']);
80
+ * // Returns: 'use client';\n\nexport { Tab, TabItem, Button } from '@docsplain-kit/core';
81
+ * ```
82
+ */
83
+ export declare function generateClientWrapper(componentNames: string[]): string;
84
+ /**
85
+ * Pre-configured client wrapper exports
86
+ *
87
+ * These are ready-to-use exports for common component groups.
88
+ * You can copy these into your own client wrapper files.
89
+ */
90
+ export declare const clientWrapperTemplates: {
91
+ /**
92
+ * All form components
93
+ */
94
+ forms: string;
95
+ /**
96
+ * All navigation components
97
+ */
98
+ navigation: string;
99
+ /**
100
+ * All layout components
101
+ */
102
+ layout: string;
103
+ /**
104
+ * All feedback components
105
+ */
106
+ feedback: string;
107
+ /**
108
+ * All data display components
109
+ */
110
+ display: string;
111
+ /**
112
+ * All components
113
+ */
114
+ all: string;
115
+ };
116
+ export {};
@@ -0,0 +1,249 @@
1
+ "use strict";
2
+ /**
3
+ * Client Wrapper Utility
4
+ *
5
+ * This utility helps create client component wrappers for use in server components.
6
+ * Since all Docsplain UI Kit components are client components, you need to create
7
+ * wrapper files with 'use client' directive to use them in server components.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * // components/docsplain.tsx
12
+ * 'use client';
13
+ *
14
+ * export {
15
+ * Tab,
16
+ * TabItem,
17
+ * Button,
18
+ * } from '@docsplain-kit/core';
19
+ * ```
20
+ *
21
+ * Then use in server components:
22
+ * ```tsx
23
+ * // app/page.tsx
24
+ * import { Tab, TabItem } from './components/docsplain';
25
+ *
26
+ * export default function Page() {
27
+ * return (
28
+ * <Tab selectedValue="tab1" onTabSelect={() => {}}>
29
+ * <TabItem value="tab1">Home</TabItem>
30
+ * </Tab>
31
+ * );
32
+ * }
33
+ * ```
34
+ */
35
+ 'use client';
36
+ /**
37
+ * Client Wrapper Utility
38
+ *
39
+ * This utility helps create client component wrappers for use in server components.
40
+ * Since all Docsplain UI Kit components are client components, you need to create
41
+ * wrapper files with 'use client' directive to use them in server components.
42
+ *
43
+ * @example
44
+ * ```tsx
45
+ * // components/docsplain.tsx
46
+ * 'use client';
47
+ *
48
+ * export {
49
+ * Tab,
50
+ * TabItem,
51
+ * Button,
52
+ * } from '@docsplain-kit/core';
53
+ * ```
54
+ *
55
+ * Then use in server components:
56
+ * ```tsx
57
+ * // app/page.tsx
58
+ * import { Tab, TabItem } from './components/docsplain';
59
+ *
60
+ * export default function Page() {
61
+ * return (
62
+ * <Tab selectedValue="tab1" onTabSelect={() => {}}>
63
+ * <TabItem value="tab1">Home</TabItem>
64
+ * </Tab>
65
+ * );
66
+ * }
67
+ * ```
68
+ */
69
+ exports.__esModule = true;
70
+ exports.clientWrapperTemplates = exports.generateClientWrapper = exports.createClientWrapper = void 0;
71
+ var tslib_1 = require("tslib");
72
+ var react_1 = tslib_1.__importDefault(require("react"));
73
+ /**
74
+ * Creates client component wrappers from dynamic imports
75
+ *
76
+ * This is useful when you want to lazy-load components or create
77
+ * wrappers that can be used in server components.
78
+ *
79
+ * @param config - Object mapping component names to their import functions
80
+ * @returns Object with component wrappers
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * const { Tab, TabItem } = createClientWrapper({
85
+ * Tab: () => import('@docsplain-kit/core').then(mod => ({ default: mod.Tab })),
86
+ * TabItem: () => import('@docsplain-kit/core').then(mod => ({ default: mod.TabItem })),
87
+ * });
88
+ * ```
89
+ */
90
+ function createClientWrapper(config) {
91
+ var _this = this;
92
+ var wrappers = {};
93
+ var _loop_1 = function (name_1, importFn) {
94
+ var LazyComponent = react_1["default"].lazy(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
95
+ var module;
96
+ return tslib_1.__generator(this, function (_a) {
97
+ switch (_a.label) {
98
+ case 0: return [4 /*yield*/, importFn()];
99
+ case 1:
100
+ module = _a.sent();
101
+ return [2 /*return*/, {
102
+ "default": module["default"] || module[name_1]
103
+ }];
104
+ }
105
+ });
106
+ }); });
107
+ // Create a wrapper that handles Suspense
108
+ wrappers[name_1] = function (props) { return (react_1["default"].createElement(react_1["default"].Suspense, { fallback: react_1["default"].createElement("div", null, "Loading...") },
109
+ react_1["default"].createElement(LazyComponent, tslib_1.__assign({}, props)))); };
110
+ };
111
+ for (var _i = 0, _a = Object.entries(config); _i < _a.length; _i++) {
112
+ var _b = _a[_i], name_1 = _b[0], importFn = _b[1];
113
+ _loop_1(name_1, importFn);
114
+ }
115
+ return wrappers;
116
+ }
117
+ exports.createClientWrapper = createClientWrapper;
118
+ /**
119
+ * Helper to create a simple client wrapper file content
120
+ *
121
+ * This generates the content for a client wrapper file that you can
122
+ * copy into your project.
123
+ *
124
+ * @param componentNames - Array of component names to export
125
+ * @returns String content for the wrapper file
126
+ *
127
+ * @example
128
+ * ```tsx
129
+ * const content = generateClientWrapper(['Tab', 'TabItem', 'Button']);
130
+ * // Returns: 'use client';\n\nexport { Tab, TabItem, Button } from '@docsplain-kit/core';
131
+ * ```
132
+ */
133
+ function generateClientWrapper(componentNames) {
134
+ var exports = componentNames.join(', ');
135
+ return "'use client';\n\nexport { ".concat(exports, " } from '@docsplain-kit/core';");
136
+ }
137
+ exports.generateClientWrapper = generateClientWrapper;
138
+ /**
139
+ * Pre-configured client wrapper exports
140
+ *
141
+ * These are ready-to-use exports for common component groups.
142
+ * You can copy these into your own client wrapper files.
143
+ */
144
+ exports.clientWrapperTemplates = {
145
+ /**
146
+ * All form components
147
+ */
148
+ forms: generateClientWrapper([
149
+ 'TextInput',
150
+ 'Textarea',
151
+ 'Select',
152
+ 'MultiSelect',
153
+ 'Checkbox',
154
+ 'RadioButton',
155
+ 'SwitchBox',
156
+ 'Slider',
157
+ 'Label',
158
+ 'AutoComplete',
159
+ ]),
160
+ /**
161
+ * All navigation components
162
+ */
163
+ navigation: generateClientWrapper([
164
+ 'Tab',
165
+ 'TabItem',
166
+ 'Button',
167
+ 'Chip',
168
+ ]),
169
+ /**
170
+ * All layout components
171
+ */
172
+ layout: generateClientWrapper([
173
+ 'Div',
174
+ 'Card',
175
+ 'CardHeader',
176
+ 'CardBody',
177
+ 'CardFooter',
178
+ 'Divider',
179
+ 'List',
180
+ 'ListItem',
181
+ ]),
182
+ /**
183
+ * All feedback components
184
+ */
185
+ feedback: generateClientWrapper([
186
+ 'Alert',
187
+ 'Snackbar',
188
+ 'Modal',
189
+ 'Tooltip',
190
+ 'MousePopup',
191
+ ]),
192
+ /**
193
+ * All data display components
194
+ */
195
+ display: generateClientWrapper([
196
+ 'Avatar',
197
+ 'Badge',
198
+ 'Skeleton',
199
+ 'Spinner',
200
+ 'Text',
201
+ 'Media',
202
+ ]),
203
+ /**
204
+ * All components
205
+ */
206
+ all: generateClientWrapper([
207
+ 'Accordion',
208
+ 'AccordionContent',
209
+ 'AccordionHeader',
210
+ 'AccordionItem',
211
+ 'Alert',
212
+ 'AutoComplete',
213
+ 'Avatar',
214
+ 'Badge',
215
+ 'Button',
216
+ 'Card',
217
+ 'CardBody',
218
+ 'CardFooter',
219
+ 'CardHeader',
220
+ 'Checkbox',
221
+ 'Chip',
222
+ 'Div',
223
+ 'Divider',
224
+ 'Label',
225
+ 'List',
226
+ 'ListItem',
227
+ 'Media',
228
+ 'Modal',
229
+ 'MousePopup',
230
+ 'MultiSelect',
231
+ 'Popper',
232
+ 'PopperContent',
233
+ 'PopperHandler',
234
+ 'RadioButton',
235
+ 'Select',
236
+ 'Skeleton',
237
+ 'Slider',
238
+ 'Snackbar',
239
+ 'Spinner',
240
+ 'SwitchBox',
241
+ 'Tab',
242
+ 'TabItem',
243
+ 'Text',
244
+ 'Textarea',
245
+ 'TextInput',
246
+ 'Tooltip',
247
+ ])
248
+ };
249
+ //# sourceMappingURL=client-wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-wrapper.js","sourceRoot":"","sources":["../../server/client-wrapper.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,YAAY,CAAC;AAlCb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;;;;AAIH,wDAA0B;AAc1B;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,mBAAmB,CACjC,MAAS;IADX,iBAwBC;IAnBC,IAAM,QAAQ,GAA6C,EAAE,CAAC;4BAElD,MAAI,EAAE,QAAQ;QACxB,IAAM,aAAa,GAAG,kBAAK,CAAC,IAAI,CAAC;;;;4BAChB,qBAAM,QAAQ,EAAE,EAAA;;wBAAzB,MAAM,GAAG,SAAgB;wBAC/B,sBAAO;gCACL,SAAO,EAAE,MAAM,CAAC,SAAO,CAAA,IAAI,MAAM,CAAC,MAAI,CAAC;6BACxC,EAAC;;;aACH,CAAC,CAAC;QAEH,yCAAyC;QACzC,QAAQ,CAAC,MAAI,CAAC,GAAG,UAAC,KAAU,IAAK,OAAA,CAC/B,iCAAC,kBAAK,CAAC,QAAQ,IAAC,QAAQ,EAAE,2DAAqB;YAC7C,iCAAC,aAAa,uBAAK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;QACX,kBAAkB;QAClB,iBAAiB;QACjB,eAAe;QACf,OAAO;QACP,cAAc;QACd,QAAQ;QACR,OAAO;QACP,QAAQ;QACR,MAAM;QACN,UAAU;QACV,YAAY;QACZ,YAAY;QACZ,UAAU;QACV,MAAM;QACN,KAAK;QACL,SAAS;QACT,OAAO;QACP,MAAM;QACN,UAAU;QACV,OAAO;QACP,OAAO;QACP,YAAY;QACZ,aAAa;QACb,QAAQ;QACR,eAAe;QACf,eAAe;QACf,aAAa;QACb,QAAQ;QACR,UAAU;QACV,QAAQ;QACR,UAAU;QACV,SAAS;QACT,WAAW;QACX,KAAK;QACL,SAAS;QACT,MAAM;QACN,UAAU;QACV,WAAW;QACX,SAAS;KACV,CAAC;CACH,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Server Component Utilities
3
+ *
4
+ * This module provides utilities and helpers for using Docsplain UI Kit
5
+ * components in React Server Components (Next.js App Router, etc.)
6
+ *
7
+ * Since all Docsplain UI Kit components are client components, you need
8
+ * to create wrapper files with 'use client' directive to use them in server components.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * // components/docsplain.tsx
13
+ * 'use client';
14
+ *
15
+ * export {
16
+ * Tab,
17
+ * TabItem,
18
+ * Button,
19
+ * } from '@docsplain-kit/core';
20
+ * ```
21
+ */
22
+ export { createClientWrapper, generateClientWrapper, clientWrapperTemplates, type ComponentImport, } from './client-wrapper';
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /**
3
+ * Server Component Utilities
4
+ *
5
+ * This module provides utilities and helpers for using Docsplain UI Kit
6
+ * components in React Server Components (Next.js App Router, etc.)
7
+ *
8
+ * Since all Docsplain UI Kit components are client components, you need
9
+ * to create wrapper files with 'use client' directive to use them in server components.
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * // components/docsplain.tsx
14
+ * 'use client';
15
+ *
16
+ * export {
17
+ * Tab,
18
+ * TabItem,
19
+ * Button,
20
+ * } from '@docsplain-kit/core';
21
+ * ```
22
+ */
23
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ var desc = Object.getOwnPropertyDescriptor(m, k);
26
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
27
+ desc = { enumerable: true, get: function() { return m[k]; } };
28
+ }
29
+ Object.defineProperty(o, k2, desc);
30
+ }) : (function(o, m, k, k2) {
31
+ if (k2 === undefined) k2 = k;
32
+ o[k2] = m[k];
33
+ }));
34
+ exports.__esModule = true;
35
+ exports.clientWrapperTemplates = exports.generateClientWrapper = exports.createClientWrapper = void 0;
36
+ var client_wrapper_1 = require("./client-wrapper");
37
+ __createBinding(exports, client_wrapper_1, "createClientWrapper");
38
+ __createBinding(exports, client_wrapper_1, "generateClientWrapper");
39
+ __createBinding(exports, client_wrapper_1, "clientWrapperTemplates");
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;AAEH,mDAK0B;AAJxB,kEAAmB;AACnB,oEAAqB;AACrB,qEAAsB"}