@ossy/connected-components 0.9.1 → 0.10.1

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.
Files changed (3) hide show
  1. package/README.md +66 -0
  2. package/build/index.js +29 -12
  3. package/package.json +4 -6
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # @ossy/connected-components
2
+
3
+ CMS-connected React components for the Ossy Ecosystem. The `App` component provides routing, theming, workspace context, and SDK integration in a single wrapper.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @ossy/connected-components @ossy/design-system @ossy/themes @ossy/router-react @ossy/sdk @ossy/sdk-react
9
+ ```
10
+
11
+ ## When to use
12
+
13
+ - **@ossy/cli** — Fastest path: run `npx @ossy/cli dev` with `src/*.page.jsx` and `src/config.js`
14
+ - **@ossy/connected-components** — Custom setups (Next.js, Vite, Remix): use the `App` component with your own bundler and server
15
+
16
+ ## Quick start
17
+
18
+ ```jsx
19
+ import { App } from '@ossy/connected-components'
20
+ import { CloudLight } from '@ossy/themes'
21
+
22
+ export default () => (
23
+ <App
24
+ workspaceId="your-workspace-id"
25
+ theme={CloudLight}
26
+ pages={[
27
+ { id: 'home', path: '/', element: <HomePage /> },
28
+ { id: 'about', path: '/about', element: <AboutPage /> },
29
+ ]}
30
+ />
31
+ )
32
+ ```
33
+
34
+ ## Configuration
35
+
36
+ | Prop | Description |
37
+ |------|-------------|
38
+ | `workspaceId` | Your workspace identifier |
39
+ | `theme` | Theme object (e.g. `CloudLight`, `CloudDark`) |
40
+ | `themes` | Multiple themes for switching via `useTheme` |
41
+ | `pages` | Array of `{ id, path, element }` page configs |
42
+ | `apiUrl` | Optional API base URL |
43
+ | `devMode` | Enables theme editor when `true` |
44
+
45
+ ## Documentation
46
+
47
+ See **App — Getting Started** in Storybook for detailed setup with `@ossy/cli` and custom bundlers:
48
+
49
+ ```bash
50
+ npm start
51
+ ```
52
+
53
+ ## Peer dependencies
54
+
55
+ - `react` >=19.0.0
56
+ - `@ossy/design-system` >=0.5.0
57
+ - `@ossy/pages` >=0.5.0
58
+ - `@ossy/router` >=0.5.0
59
+ - `@ossy/router-react` >=0.5.0
60
+ - `@ossy/sdk` >=0.5.0
61
+ - `@ossy/sdk-react` >=0.5.0
62
+ - `@ossy/themes` >=0.5.0
63
+
64
+ ## License
65
+
66
+ MIT
package/build/index.js CHANGED
@@ -3,7 +3,17 @@ import { SDK } from '@ossy/sdk';
3
3
  import { useResource, WorkspaceProvider, AsyncStatus, useQuery, useResources } from '@ossy/sdk-react';
4
4
  import { Overlay, View, Button, Text, useTheme, Theme, useDocumentTitle, Switch } from '@ossy/design-system';
5
5
  import { Router } from '@ossy/router-react';
6
- import { Resume as Resume$1 } from '@ossy/design-system-extras';
6
+ import { Resume as Resume$1 } from '@ossy/pages';
7
+
8
+ function _extends() {
9
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
10
+ for (var e = 1; e < arguments.length; e++) {
11
+ var t = arguments[e];
12
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
13
+ }
14
+ return n;
15
+ }, _extends.apply(null, arguments);
16
+ }
7
17
 
8
18
  function defaultAppSettings() {
9
19
  return {
@@ -13,6 +23,7 @@ function defaultAppSettings() {
13
23
  theme: undefined,
14
24
  themes: undefined,
15
25
  routes: [],
26
+ pages: [],
16
27
  initialEntries: [],
17
28
  initialIndex: 0,
18
29
  router: 'browser',
@@ -154,11 +165,25 @@ const ThemeEditor = () => {
154
165
  }));
155
166
  };
156
167
 
168
+ function routesToPages(routes) {
169
+ if (!routes?.length) return [];
170
+ return routes.map((route, i) => {
171
+ const path = typeof route.path === 'string' ? route.path : route.path?.en ?? '/';
172
+ const id = route.id ?? (path === '/' ? 'home' : path.replace(/^\//, '').replace(/\/$/, '').replace(/\//g, '-') || `page-${i}`);
173
+ return {
174
+ id,
175
+ path: route.path,
176
+ element: route.element,
177
+ render: route.render ?? (() => route.element)
178
+ };
179
+ });
180
+ }
157
181
  const App = _appSettings => {
158
182
  const appSettings = {
159
183
  ...defaultAppSettings(),
160
184
  ..._appSettings
161
185
  };
186
+ const pages = appSettings.pages?.length ? appSettings.pages : routesToPages(appSettings.routes);
162
187
  const sdk = SDK.of({
163
188
  apiUrl: appSettings.apiUrl,
164
189
  workspaceId: appSettings.workspaceId
@@ -170,19 +195,11 @@ const App = _appSettings => {
170
195
  themes: appSettings.themes
171
196
  }, /*#__PURE__*/React$1.createElement(WorkspaceProvider, {
172
197
  sdk: sdk
173
- }, /*#__PURE__*/React$1.createElement(Router, appSettings), appSettings.devMode && /*#__PURE__*/React$1.createElement(ThemeEditor, null))));
198
+ }, /*#__PURE__*/React$1.createElement(Router, _extends({}, appSettings, {
199
+ pages: pages
200
+ })), appSettings.devMode && /*#__PURE__*/React$1.createElement(ThemeEditor, null))));
174
201
  };
175
202
 
176
- function _extends() {
177
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
178
- for (var e = 1; e < arguments.length; e++) {
179
- var t = arguments[e];
180
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
181
- }
182
- return n;
183
- }, _extends.apply(null, arguments);
184
- }
185
-
186
203
  const Layout = ({
187
204
  layoutId,
188
205
  ...props
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ossy/connected-components",
3
- "version": "0.9.1",
3
+ "version": "0.10.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ossy-se/packages.git"
@@ -12,9 +12,7 @@
12
12
  "author": "Ossy <yourfriends@ossy.se> (https://ossy.se)",
13
13
  "scripts": {
14
14
  "build": "rollup -c rollup.config.js",
15
- "test": "",
16
- "storybook": "storybook dev -p 6006",
17
- "build-storybook": "storybook build"
15
+ "test": ""
18
16
  },
19
17
  "browserslist": {
20
18
  "production": [
@@ -42,7 +40,7 @@
42
40
  },
43
41
  "peerDependencies": {
44
42
  "@ossy/design-system": ">=0.5.0 <1.0.0",
45
- "@ossy/design-system-extras": ">=0.5.0 <1.0.0",
43
+ "@ossy/pages": ">=0.5.0 <1.0.0",
46
44
  "@ossy/router": ">=0.5.0 <1.0.0",
47
45
  "@ossy/router-react": ">=0.5.0 <1.0.0",
48
46
  "@ossy/sdk": ">=0.5.0 <1.0.0",
@@ -58,5 +56,5 @@
58
56
  "/build",
59
57
  "README.md"
60
58
  ],
61
- "gitHead": "009330a43cf08e0cab806434b5f654401924af95"
59
+ "gitHead": "fa8cbcb5f24811e6844c929d7fa7cd1d2544efa7"
62
60
  }