@ossy/connected-components 0.7.4 → 0.7.6
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/build/index.js +15 -53
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import React$1, { useState, useMemo, useCallback, useEffect
|
|
1
|
+
import React$1, { createContext, useState, useMemo, useCallback, useEffect } from 'react';
|
|
2
2
|
import { SDK } from '@ossy/sdk';
|
|
3
|
-
import
|
|
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
6
|
import { Resume as Resume$1 } from '@ossy/design-system-extras';
|
|
7
7
|
|
|
8
|
+
const AppContext = /*#__PURE__*/createContext(defaultAppSettings());
|
|
9
|
+
const useApp = () => React$1.useContext(AppContext);
|
|
10
|
+
|
|
8
11
|
const overlayStyles = {
|
|
9
12
|
background: 'transparent',
|
|
10
13
|
display: 'content',
|
|
@@ -59,6 +62,7 @@ const ThemeSwitcher = () => {
|
|
|
59
62
|
}, themeName))));
|
|
60
63
|
};
|
|
61
64
|
const ThemeEditor = () => {
|
|
65
|
+
const app = useApp();
|
|
62
66
|
const {
|
|
63
67
|
updateResourceContent
|
|
64
68
|
} = useResource('PCX53TaGviq4_8KvK-VOp');
|
|
@@ -86,7 +90,7 @@ const ThemeEditor = () => {
|
|
|
86
90
|
useEffect(() => {
|
|
87
91
|
if (!isEditorOpen) return;
|
|
88
92
|
const views = document.querySelectorAll('[data-view]');
|
|
89
|
-
views.forEach(view => view.style.border = '1px solid red')
|
|
93
|
+
// views.forEach(view => view.style.border = '1px solid red')
|
|
90
94
|
setViewCount(views.length);
|
|
91
95
|
}, [isEditorOpen]);
|
|
92
96
|
return /*#__PURE__*/React$1.createElement(Overlay, {
|
|
@@ -125,7 +129,7 @@ const ThemeEditor = () => {
|
|
|
125
129
|
}))), /*#__PURE__*/React$1.createElement(Button, {
|
|
126
130
|
type: "submit",
|
|
127
131
|
variant: "cta"
|
|
128
|
-
}, "Save")), /*#__PURE__*/React$1.createElement(ThemeSwitcher, null), /*#__PURE__*/React$1.createElement(Text, null, "Views: ", viewCount))), /*#__PURE__*/React$1.createElement(Button, {
|
|
132
|
+
}, "Save")), /*#__PURE__*/React$1.createElement(ThemeSwitcher, null), /*#__PURE__*/React$1.createElement(Text, null, "Views: ", viewCount)), /*#__PURE__*/React$1.createElement(View, null, /*#__PURE__*/React$1.createElement(View, null, "Pages: ", app?.pages?.length || 0), /*#__PURE__*/React$1.createElement(View, null, (app?.pages || []).map(page => /*#__PURE__*/React$1.createElement(Button, null, page.id))))), /*#__PURE__*/React$1.createElement(Button, {
|
|
129
133
|
variant: "cta",
|
|
130
134
|
prefix: "math-plus",
|
|
131
135
|
style: toggleStyles,
|
|
@@ -133,8 +137,7 @@ const ThemeEditor = () => {
|
|
|
133
137
|
}));
|
|
134
138
|
};
|
|
135
139
|
|
|
136
|
-
|
|
137
|
-
function defaultAppSettings() {
|
|
140
|
+
function defaultAppSettings$1() {
|
|
138
141
|
return {
|
|
139
142
|
workspaceId: undefined,
|
|
140
143
|
defaultLanguage: undefined,
|
|
@@ -151,11 +154,9 @@ function defaultAppSettings() {
|
|
|
151
154
|
};
|
|
152
155
|
}
|
|
153
156
|
|
|
154
|
-
const AppContext = /*#__PURE__*/createContext(defaultAppSettings());
|
|
155
|
-
const useApp = () => React$1.useContext(AppContext);
|
|
156
157
|
const App = _appSettings => {
|
|
157
158
|
const appSettings = {
|
|
158
|
-
...defaultAppSettings(),
|
|
159
|
+
...defaultAppSettings$1(),
|
|
159
160
|
..._appSettings
|
|
160
161
|
};
|
|
161
162
|
const sdk = SDK.of({
|
|
@@ -263,45 +264,6 @@ const Ossybot = ({
|
|
|
263
264
|
})));
|
|
264
265
|
};
|
|
265
266
|
|
|
266
|
-
const appendSlash = string => string[string.length - 1] === '/' ? string : `${string}/`;
|
|
267
|
-
const prependSlash = string => string[0] === '/' ? string : `/${string}`;
|
|
268
|
-
const padWithSlash = string => appendSlash(prependSlash(string));
|
|
269
|
-
const Predicates = {
|
|
270
|
-
byLength: desiredLength => route => {
|
|
271
|
-
const routeParts = route.split('/').filter(x => !!x);
|
|
272
|
-
return routeParts.length === desiredLength;
|
|
273
|
-
},
|
|
274
|
-
byParamPlaceHolders: activePathname => route => {
|
|
275
|
-
const routeParts = route.split('/').filter(x => !!x).reduce((parts, part) => part.startsWith(':') ? [...parts, '.+?'] : [...parts, part], []).join('/');
|
|
276
|
-
const regex = new RegExp(`^${padWithSlash(routeParts)}$`);
|
|
277
|
-
const passes = regex.test(activePathname);
|
|
278
|
-
return passes;
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
const useActivePageLocation = path => {
|
|
282
|
-
console.log('useActivePageLocation path', path);
|
|
283
|
-
const {
|
|
284
|
-
routes: pages
|
|
285
|
-
} = useAppSettings();
|
|
286
|
-
if (!path) return;
|
|
287
|
-
|
|
288
|
-
// TODO: this needs tests because I don't think it works right
|
|
289
|
-
const activePathname = path === '' ? '/' : padWithSlash(path);
|
|
290
|
-
const registeredPageRoutes = pages.map(page => padWithSlash(page.path));
|
|
291
|
-
const exactRouteMatch = registeredPageRoutes.find(route => route === activePathname);
|
|
292
|
-
let activePageLocation;
|
|
293
|
-
if (!!exactRouteMatch) {
|
|
294
|
-
activePageLocation = exactRouteMatch;
|
|
295
|
-
} else {
|
|
296
|
-
const activePathnameParts = activePathname.split('/').filter(x => !!x);
|
|
297
|
-
const dynamicRouteMatch = registeredPageRoutes.find(route => Predicates.byLength(activePathnameParts.length)(route) && Predicates.byParamPlaceHolders(activePathname)(route));
|
|
298
|
-
activePageLocation = dynamicRouteMatch;
|
|
299
|
-
}
|
|
300
|
-
console.log('useActivePageLocation exactRouteMatch', exactRouteMatch);
|
|
301
|
-
console.log('useActivePageLocation activePageLocation', activePageLocation);
|
|
302
|
-
return activePageLocation;
|
|
303
|
-
};
|
|
304
|
-
|
|
305
267
|
// import { useParams } from '../use-params'
|
|
306
268
|
// import { AppHeader } from './AppHeader'
|
|
307
269
|
// import { AppFooter } from './AppFooter'
|
|
@@ -387,7 +349,7 @@ const Section = ({
|
|
|
387
349
|
};
|
|
388
350
|
|
|
389
351
|
const Page = () => {
|
|
390
|
-
const activePageLocation =
|
|
352
|
+
const activePageLocation = '/';
|
|
391
353
|
const {
|
|
392
354
|
resources: folder
|
|
393
355
|
} = useResources(`/pages${activePageLocation}`);
|
|
@@ -428,7 +390,7 @@ const PageStatus = {
|
|
|
428
390
|
const PageDataLoader = ({
|
|
429
391
|
children
|
|
430
392
|
}) => {
|
|
431
|
-
const activePageLocation =
|
|
393
|
+
const activePageLocation = '/';
|
|
432
394
|
const {
|
|
433
395
|
status,
|
|
434
396
|
resources: folder
|
|
@@ -631,9 +593,9 @@ const ThemeProvider = props => {
|
|
|
631
593
|
status,
|
|
632
594
|
resource: theme
|
|
633
595
|
} = useResource('PCX53TaGviq4_8KvK-VOp');
|
|
634
|
-
return status === AsyncStatus.Success ? /*#__PURE__*/React$
|
|
596
|
+
return status === AsyncStatus.Success ? /*#__PURE__*/React$1.createElement(Theme, _extends({
|
|
635
597
|
theme: theme.data
|
|
636
|
-
}, props)) : /*#__PURE__*/React$
|
|
598
|
+
}, props)) : /*#__PURE__*/React$1.createElement(React$1.Fragment, null);
|
|
637
599
|
};
|
|
638
600
|
|
|
639
|
-
export { App,
|
|
601
|
+
export { App, Layout, Ossybot, Page, PageDataLoader, PagesModule, Resume, ResumeTemplates, ThemeEditor, ThemeProvider, defaultAppSettings$1 as defaultAppSettings, location, useApp, useMergeAsyncStatus, useResume };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/connected-components",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/ossy-se/packages.git"
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"/build",
|
|
59
59
|
"README.md"
|
|
60
60
|
],
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "9d5b59044ac7ffef6e0f16d827a3cb5822a545e8"
|
|
62
62
|
}
|