@plurid/plurid-react 0.0.0-24 → 0.0.0-25

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
@@ -62,13 +62,12 @@ npm install \
62
62
  @plurid/plurid-themes \
63
63
  @plurid/plurid-ui-components-react \
64
64
  @plurid/plurid-ui-state-react \
65
+ @reduxjs/toolkit \
65
66
  cross-fetch \
66
67
  hammerjs \
67
68
  react \
68
69
  react-dom \
69
70
  react-redux \
70
- redux \
71
- redux-thunk \
72
71
  styled-components
73
72
  ```
74
73
 
@@ -87,13 +86,12 @@ yarn add \
87
86
  @plurid/plurid-themes \
88
87
  @plurid/plurid-ui-components-react \
89
88
  @plurid/plurid-ui-state-react \
89
+ @reduxjs/toolkit \
90
90
  cross-fetch \
91
91
  hammerjs \
92
92
  react \
93
93
  react-dom \
94
94
  react-redux \
95
- redux \
96
- redux-thunk \
97
95
  styled-components
98
96
  ```
99
97
 
@@ -126,7 +124,8 @@ A simple, rendering-test application component, could look like
126
124
  /** imports */
127
125
  import React from 'react';
128
126
 
129
- import PluridApplication, {
127
+ import {
128
+ PluridApplication,
130
129
  PluridPlane,
131
130
  } from '@plurid/plurid-react';
132
131
 
@@ -136,13 +135,10 @@ import PluridApplication, {
136
135
  const Application: React.FC<any> = () => {
137
136
  /** plurid' planes */
138
137
  const pluridPlanes: PluridPlane[] = [
139
- {
140
- route: '/',
141
- component: {
142
- kind: 'react',
143
- element: () => (<div>Plurid' Application</div>),
144
- },
145
- },
138
+ [
139
+ '/',
140
+ () => (<div>Plurid' Application Plane</div>),
141
+ ],
146
142
  ];
147
143
 
148
144
  /** plurid' view */
@@ -3,7 +3,7 @@ import { AnyAction, ThunkDispatch } from '@reduxjs/toolkit';
3
3
  import { Theme } from '@plurid/plurid-themes';
4
4
  import {
5
5
  /** interfaces */
6
- PluridApplication as PluridApplicationProperties, PluridConfiguration as PluridAppConfiguration, TreePlane, PluridApplicationView } from '@plurid/plurid-data';
6
+ PluridApplication as PluridApplicationProperties, PluridConfiguration as PluridAppConfiguration, TreePlane, SpaceTransform, PluridApplicationView } from '@plurid/plurid-data';
7
7
  import { PluridReactComponent } from "../../../data/interfaces";
8
8
  import { AppState } from "../../../services/state/store";
9
9
  import actions from "../../../services/state/actions";
@@ -14,7 +14,7 @@ export interface PluridViewStateProperties {
14
14
  state: AppState;
15
15
  stateConfiguration: PluridAppConfiguration;
16
16
  stateSpaceLoading: boolean;
17
- stateTransform: any;
17
+ stateTransform: SpaceTransform;
18
18
  stateTree: TreePlane[];
19
19
  stateSpaceView: PluridApplicationView;
20
20
  stateGeneralTheme: Theme;
@@ -0,0 +1 @@
1
+ export declare const PluridScrollTop: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -380,8 +380,10 @@ const initialState$2 = {
380
380
  lastClosedPlane: ""
381
381
  };
382
382
 
383
+ const name = "space";
384
+
383
385
  const space = createSlice({
384
- name: "space,",
386
+ name: name,
385
387
  initialState: initialState$2,
386
388
  reducers: {
387
389
  setSpaceField: (state, action) => {
@@ -414,7 +416,11 @@ const space = createSlice({
414
416
  state.transformTime = action.payload;
415
417
  },
416
418
  setSpaceLocation: (state, action) => {
417
- state = Object.assign(Object.assign({}, state), action.payload);
419
+ const newState = Object.assign(Object.assign({}, state), action.payload);
420
+ const transform = computeMatrix(newState);
421
+ return Object.assign(Object.assign({}, newState), {
422
+ transform: transform
423
+ });
418
424
  },
419
425
  viewCameraMoveForward: state => {
420
426
  state.translationZ = state.translationZ + TRANSLATION_STEP * 6 * Math.cos(toRadians(-state.rotationY));
@@ -602,6 +608,7 @@ const reducer$3 = space.reducer;
602
608
 
603
609
  var space$1 = Object.freeze({
604
610
  __proto__: null,
611
+ name: name,
605
612
  space: space,
606
613
  actions: actions$3,
607
614
  selectors: selectors$3,
@@ -955,9 +962,16 @@ const navigateToRoot = (dispatch, state, type) => {
955
962
  return;
956
963
  }
957
964
  const treeIndex = type === "previous" ? rootIndex - 1 || 0 : rootIndex + 1;
958
- const root = tree[treeIndex];
965
+ let root = tree[treeIndex];
959
966
  if (!root) {
960
- return;
967
+ if (type === "previous") {
968
+ root = tree[tree.length - 1];
969
+ } else {
970
+ root = tree[0];
971
+ }
972
+ if (!root) {
973
+ return;
974
+ }
961
975
  }
962
976
  navigateToPluridPlane(dispatch, root, undefined, true);
963
977
  };
@@ -1173,6 +1187,15 @@ const handleGlobalShortcuts = (dispatch, state, pubsub, event, firstPerson, lock
1173
1187
  focusNextRoot(dispatch, state);
1174
1188
  return;
1175
1189
  }
1190
+ if (event.altKey && event.code === "Tab") {
1191
+ event.preventDefault();
1192
+ if (event.shiftKey) {
1193
+ focusPreviousRoot(dispatch, state);
1194
+ } else {
1195
+ focusNextRoot(dispatch, state);
1196
+ }
1197
+ return;
1198
+ }
1176
1199
  if (event.altKey && event.code.startsWith("Digit")) {
1177
1200
  const index = parseInt(event.code.replace("Digit", "")) - 1;
1178
1201
  focusRootIndex(dispatch, state, index);
@@ -4308,7 +4331,7 @@ const PluridView = properties => {
4308
4331
  };
4309
4332
  const treeUpdateCallback = useCallback((() => {
4310
4333
  treeUpdate(stateSpaceView);
4311
- }), [ hostname, stateSpaceView, stateConfiguration ]);
4334
+ }), [ hostname, stateSpaceView, stateConfiguration, JSON.stringify(stateTree) ]);
4312
4335
  const handlePubSubSubscribe = pubsub => {
4313
4336
  const subscriptions = [ {
4314
4337
  topic: PLURID_PUBSUB_TOPIC.CONFIGURATION,
@@ -4718,7 +4741,7 @@ const PluridView = properties => {
4718
4741
  return () => {
4719
4742
  window.removeEventListener("resize", treeUpdateCallback);
4720
4743
  };
4721
- }), [ stateSpaceView, stateConfiguration ]);
4744
+ }), [ stateSpaceView, stateConfiguration, JSON.stringify(stateTree) ]);
4722
4745
  useEffect((() => {
4723
4746
  if (typeof window === "undefined") {
4724
4747
  return;
@@ -5359,10 +5382,16 @@ const renderDirectPlane = (routePlane, planesRegistrar, hostname = "origin") =>
5359
5382
  return DirectPlane;
5360
5383
  };
5361
5384
 
5385
+ const PluridScrollTop = styled.div`
5386
+ height: 0;
5387
+ width: 0;
5388
+ `;
5389
+
5362
5390
  const PluridRouterBrowser = properties => {
5363
- const {routes: routes, planes: planes, exterior: exterior, shell: shell, hostname: hostname, static: staticContext, view: cleanNavigationView, cleanNavigation: cleanNavigation, notFoundPath: notFoundPathProperty} = properties;
5391
+ const {routes: routes, planes: planes, exterior: exterior, shell: shell, hostname: hostname, scrollToTop: scrollToTop, static: staticContext, view: cleanNavigationView, cleanNavigation: cleanNavigation, notFoundPath: notFoundPathProperty} = properties;
5364
5392
  const notFoundPath = notFoundPathProperty || "/not-found";
5365
5393
  const pluridPlanes = gatherPluridPlanes(routes, planes);
5394
+ const topContainer = useRef(null);
5366
5395
  const pluridPlanesRegistrar = useRef(new PluridPlanesRegistrar(pluridPlanes, hostname));
5367
5396
  const pluridIsoMatcher = useRef(new PluridIsoMatcher$1({
5368
5397
  routes: routes,
@@ -5372,6 +5401,15 @@ const PluridRouterBrowser = properties => {
5372
5401
  const [matchedPath, setMatchedPath] = useState(computeInitialMatchedPath(staticContext));
5373
5402
  const [matchedRoute, setMatchedRoute] = useState(pluridIsoMatcher.current.match(matchedPath, "route"));
5374
5403
  const [PluridRoute, setPluridRoute] = useState(computePluridRoute(matchedRoute, pluridPlanesRegistrar.current, pluridIsoMatcher.current, staticContext && staticContext.directPlane ? pluridIsoMatcher.current.match(staticContext.directPlane, "route") : undefined, hostname));
5404
+ const scrollTop = () => {
5405
+ if (!topContainer.current || scrollToTop === false) {
5406
+ return;
5407
+ }
5408
+ const behavior = typeof scrollToTop === "undefined" || scrollToTop === true || scrollToTop === "smooth" ? "smooth" : "auto";
5409
+ topContainer.current.scrollIntoView({
5410
+ behavior: behavior
5411
+ });
5412
+ };
5375
5413
  const handleLocation = event => {
5376
5414
  let matchedPath;
5377
5415
  if (event && event.detail && event.detail.path && !matchedPath) {
@@ -5385,6 +5423,7 @@ const PluridRouterBrowser = properties => {
5385
5423
  matchedPath = pathname + window.location.search;
5386
5424
  }
5387
5425
  setMatchedPath(matchedPath);
5426
+ scrollTop();
5388
5427
  };
5389
5428
  useEffect((() => {
5390
5429
  window.addEventListener("popstate", handleLocation);
@@ -5446,7 +5485,9 @@ const PluridRouterBrowser = properties => {
5446
5485
  PluridRouterShell.displayName = "PluridRouterShell";
5447
5486
  }
5448
5487
  }
5449
- return React.createElement(React.Fragment, null, PluridRouterExterior && React.createElement(PluridRouterExterior, {
5488
+ return React.createElement(React.Fragment, null, React.createElement(PluridScrollTop, {
5489
+ ref: topContainer
5490
+ }), PluridRouterExterior && React.createElement(PluridRouterExterior, {
5450
5491
  matchedRoute: matchedRoute
5451
5492
  }), React.createElement(PluridRouterShell, {
5452
5493
  matchedRoute: matchedRoute
@@ -6299,6 +6340,7 @@ const serverComputeMetastate = (isoMatch, paths, globals) => __awaiter(void 0, v
6299
6340
  space: {
6300
6341
  loading: false,
6301
6342
  animatedTransform: false,
6343
+ transform: "matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)",
6302
6344
  scale: 1,
6303
6345
  rotationX: 0,
6304
6346
  rotationY: 0,