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

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
  };
@@ -1053,127 +1067,174 @@ const handleGlobalShortcuts = (dispatch, state, pubsub, event, firstPerson, lock
1053
1067
  return;
1054
1068
  }
1055
1069
  const noModifiers = !event.shiftKey && !event.altKey && !event.ctrlKey && !event.metaKey;
1070
+ const handleEvent = () => {
1071
+ event.preventDefault();
1072
+ };
1056
1073
  if (event.code === "KeyF" && noModifiers) {
1074
+ handleEvent();
1057
1075
  return dispatch(actions.configuration.toggleConfigurationSpaceFirstPerson());
1058
1076
  }
1059
1077
  if (firstPerson) {
1060
1078
  if (event.code === "KeyW" && noModifiers && locks.translationZ) {
1079
+ handleEvent();
1061
1080
  return dispatch(actions.space.viewCameraMoveForward());
1062
1081
  }
1063
1082
  if (event.code === "KeyS" && noModifiers && locks.translationZ) {
1083
+ handleEvent();
1064
1084
  return dispatch(actions.space.viewCameraMoveBackward());
1065
1085
  }
1066
1086
  if (event.code === "KeyA" && noModifiers && locks.translationX) {
1087
+ handleEvent();
1067
1088
  return dispatch(actions.space.viewCameraMoveLeft());
1068
1089
  }
1069
1090
  if (event.code === "KeyA" && event.shiftKey && locks.rotationY) {
1091
+ handleEvent();
1070
1092
  return dispatch(actions.space.viewCameraTurnLeft());
1071
1093
  }
1072
1094
  if (event.code === "KeyD" && noModifiers && locks.translationX) {
1095
+ handleEvent();
1073
1096
  return dispatch(actions.space.viewCameraMoveRight());
1074
1097
  }
1075
1098
  if (event.code === "KeyD" && event.shiftKey && locks.rotationY) {
1099
+ handleEvent();
1076
1100
  return dispatch(actions.space.viewCameraTurnRight());
1077
1101
  }
1078
1102
  if (event.code === "KeyQ" && noModifiers && locks.rotationX) {
1103
+ handleEvent();
1079
1104
  return dispatch(actions.space.viewCameraTurnUp());
1080
1105
  }
1081
1106
  if (event.code === "KeyZ" && noModifiers && locks.rotationX) {
1107
+ handleEvent();
1082
1108
  return dispatch(actions.space.viewCameraTurnDown());
1083
1109
  }
1084
1110
  if (event.code === "KeyE" && noModifiers && locks.translationY) {
1111
+ handleEvent();
1085
1112
  return dispatch(actions.space.viewCameraMoveUp());
1086
1113
  }
1087
1114
  if (event.code === "KeyC" && noModifiers && locks.translationY) {
1115
+ handleEvent();
1088
1116
  return dispatch(actions.space.viewCameraMoveDown());
1089
1117
  }
1090
1118
  }
1091
1119
  if (event.code === "KeyR" && noModifiers) {
1120
+ handleEvent();
1092
1121
  return dispatch(actions.configuration.setConfigurationSpaceTransformMode(TRANSFORM_MODES.ROTATION));
1093
1122
  }
1094
1123
  if (event.code === "KeyT" && noModifiers) {
1124
+ handleEvent();
1095
1125
  return dispatch(actions.configuration.setConfigurationSpaceTransformMode(TRANSFORM_MODES.TRANSLATION));
1096
1126
  }
1097
1127
  if (event.code === "KeyS" && noModifiers && !firstPerson) {
1128
+ handleEvent();
1098
1129
  return dispatch(actions.configuration.setConfigurationSpaceTransformMode(TRANSFORM_MODES.SCALE));
1099
1130
  }
1100
1131
  if (event.key === "ArrowRight") {
1101
1132
  if (event.shiftKey && locks.rotationY) {
1133
+ handleEvent();
1102
1134
  return dispatch(actions.space.rotateLeft());
1103
1135
  }
1104
1136
  if (event.altKey && locks.translationX) {
1137
+ handleEvent();
1105
1138
  return dispatch(actions.space.translateRight());
1106
1139
  }
1107
1140
  }
1108
1141
  if (event.key === "ArrowLeft") {
1109
1142
  if (event.shiftKey && locks.rotationY) {
1143
+ handleEvent();
1110
1144
  return dispatch(actions.space.rotateRight());
1111
1145
  }
1112
1146
  if (event.altKey && locks.translationX) {
1147
+ handleEvent();
1113
1148
  return dispatch(actions.space.translateLeft());
1114
1149
  }
1115
1150
  }
1116
1151
  if (event.key === "ArrowUp") {
1117
1152
  if (event.shiftKey && event.altKey && locks.translationZ) {
1153
+ handleEvent();
1118
1154
  return dispatch(actions.space.translateIn());
1119
1155
  }
1120
1156
  if (event.shiftKey && !event.altKey && locks.rotationX) {
1157
+ handleEvent();
1121
1158
  return dispatch(actions.space.rotateUp());
1122
1159
  }
1123
1160
  if (event.altKey && !event.shiftKey && locks.translationY) {
1161
+ handleEvent();
1124
1162
  return dispatch(actions.space.translateUp());
1125
1163
  }
1126
1164
  if (event.metaKey || event.ctrlKey && locks.scale) {
1165
+ handleEvent();
1127
1166
  return dispatch(actions.space.scaleUp());
1128
1167
  }
1129
1168
  }
1130
1169
  if (event.key === "ArrowDown") {
1131
1170
  if (event.shiftKey && event.altKey && locks.translationZ) {
1171
+ handleEvent();
1132
1172
  return dispatch(actions.space.translateOut());
1133
1173
  }
1134
1174
  if (event.shiftKey && !event.altKey && locks.rotationX) {
1175
+ handleEvent();
1135
1176
  return dispatch(actions.space.rotateDown());
1136
1177
  }
1137
1178
  if (event.altKey && !event.shiftKey && locks.translationY) {
1179
+ handleEvent();
1138
1180
  return dispatch(actions.space.translateDown());
1139
1181
  }
1140
1182
  if (event.metaKey || event.ctrlKey && locks.scale) {
1183
+ handleEvent();
1141
1184
  return dispatch(actions.space.scaleDown());
1142
1185
  }
1143
1186
  }
1144
1187
  if (event.altKey && event.code === "KeyF") {
1188
+ handleEvent();
1145
1189
  focusActivePlane(dispatch, state);
1146
1190
  return;
1147
1191
  }
1148
1192
  if (event.altKey && event.code === "KeyB") {
1193
+ handleEvent();
1149
1194
  focusParentActivePlane(dispatch, state);
1150
1195
  return;
1151
1196
  }
1152
1197
  if (event.altKey && event.code === "KeyR") {
1198
+ handleEvent();
1153
1199
  refreshActivePlane(state, pubsub);
1154
1200
  return;
1155
1201
  }
1156
1202
  if (event.altKey && event.code === "KeyE") {
1203
+ handleEvent();
1157
1204
  isolateActivePlane(state, pubsub);
1158
1205
  return;
1159
1206
  }
1160
1207
  if (event.altKey && event.shiftKey && event.code === "KeyT") {
1208
+ handleEvent();
1161
1209
  openClosedPlane(pubsub);
1162
1210
  return;
1163
1211
  }
1164
1212
  if (event.altKey && event.code === "KeyW") {
1213
+ handleEvent();
1165
1214
  closeActivePlane(state, pubsub);
1166
1215
  return;
1167
1216
  }
1168
1217
  if (event.altKey && event.code === "KeyA") {
1218
+ handleEvent();
1169
1219
  focusPreviousRoot(dispatch, state);
1170
1220
  return;
1171
1221
  }
1172
1222
  if (event.altKey && event.code === "KeyD") {
1223
+ handleEvent();
1173
1224
  focusNextRoot(dispatch, state);
1174
1225
  return;
1175
1226
  }
1227
+ if (event.altKey && event.code === "Tab") {
1228
+ handleEvent();
1229
+ if (event.shiftKey) {
1230
+ focusPreviousRoot(dispatch, state);
1231
+ } else {
1232
+ focusNextRoot(dispatch, state);
1233
+ }
1234
+ return;
1235
+ }
1176
1236
  if (event.altKey && event.code.startsWith("Digit")) {
1237
+ handleEvent();
1177
1238
  const index = parseInt(event.code.replace("Digit", "")) - 1;
1178
1239
  focusRootIndex(dispatch, state, index);
1179
1240
  return;
@@ -4308,7 +4369,7 @@ const PluridView = properties => {
4308
4369
  };
4309
4370
  const treeUpdateCallback = useCallback((() => {
4310
4371
  treeUpdate(stateSpaceView);
4311
- }), [ hostname, stateSpaceView, stateConfiguration ]);
4372
+ }), [ hostname, stateSpaceView, stateConfiguration, JSON.stringify(stateTree) ]);
4312
4373
  const handlePubSubSubscribe = pubsub => {
4313
4374
  const subscriptions = [ {
4314
4375
  topic: PLURID_PUBSUB_TOPIC.CONFIGURATION,
@@ -4718,7 +4779,7 @@ const PluridView = properties => {
4718
4779
  return () => {
4719
4780
  window.removeEventListener("resize", treeUpdateCallback);
4720
4781
  };
4721
- }), [ stateSpaceView, stateConfiguration ]);
4782
+ }), [ stateSpaceView, stateConfiguration, JSON.stringify(stateTree) ]);
4722
4783
  useEffect((() => {
4723
4784
  if (typeof window === "undefined") {
4724
4785
  return;
@@ -5359,10 +5420,16 @@ const renderDirectPlane = (routePlane, planesRegistrar, hostname = "origin") =>
5359
5420
  return DirectPlane;
5360
5421
  };
5361
5422
 
5423
+ const PluridScrollTop = styled.div`
5424
+ height: 0;
5425
+ width: 0;
5426
+ `;
5427
+
5362
5428
  const PluridRouterBrowser = properties => {
5363
- const {routes: routes, planes: planes, exterior: exterior, shell: shell, hostname: hostname, static: staticContext, view: cleanNavigationView, cleanNavigation: cleanNavigation, notFoundPath: notFoundPathProperty} = properties;
5429
+ const {routes: routes, planes: planes, exterior: exterior, shell: shell, hostname: hostname, scrollToTop: scrollToTop, static: staticContext, view: cleanNavigationView, cleanNavigation: cleanNavigation, notFoundPath: notFoundPathProperty} = properties;
5364
5430
  const notFoundPath = notFoundPathProperty || "/not-found";
5365
5431
  const pluridPlanes = gatherPluridPlanes(routes, planes);
5432
+ const topContainer = useRef(null);
5366
5433
  const pluridPlanesRegistrar = useRef(new PluridPlanesRegistrar(pluridPlanes, hostname));
5367
5434
  const pluridIsoMatcher = useRef(new PluridIsoMatcher$1({
5368
5435
  routes: routes,
@@ -5372,6 +5439,15 @@ const PluridRouterBrowser = properties => {
5372
5439
  const [matchedPath, setMatchedPath] = useState(computeInitialMatchedPath(staticContext));
5373
5440
  const [matchedRoute, setMatchedRoute] = useState(pluridIsoMatcher.current.match(matchedPath, "route"));
5374
5441
  const [PluridRoute, setPluridRoute] = useState(computePluridRoute(matchedRoute, pluridPlanesRegistrar.current, pluridIsoMatcher.current, staticContext && staticContext.directPlane ? pluridIsoMatcher.current.match(staticContext.directPlane, "route") : undefined, hostname));
5442
+ const scrollTop = () => {
5443
+ if (!topContainer.current || scrollToTop === false) {
5444
+ return;
5445
+ }
5446
+ const behavior = typeof scrollToTop === "undefined" || scrollToTop === true || scrollToTop === "smooth" ? "smooth" : "auto";
5447
+ topContainer.current.scrollIntoView({
5448
+ behavior: behavior
5449
+ });
5450
+ };
5375
5451
  const handleLocation = event => {
5376
5452
  let matchedPath;
5377
5453
  if (event && event.detail && event.detail.path && !matchedPath) {
@@ -5385,6 +5461,7 @@ const PluridRouterBrowser = properties => {
5385
5461
  matchedPath = pathname + window.location.search;
5386
5462
  }
5387
5463
  setMatchedPath(matchedPath);
5464
+ scrollTop();
5388
5465
  };
5389
5466
  useEffect((() => {
5390
5467
  window.addEventListener("popstate", handleLocation);
@@ -5446,7 +5523,9 @@ const PluridRouterBrowser = properties => {
5446
5523
  PluridRouterShell.displayName = "PluridRouterShell";
5447
5524
  }
5448
5525
  }
5449
- return React.createElement(React.Fragment, null, PluridRouterExterior && React.createElement(PluridRouterExterior, {
5526
+ return React.createElement(React.Fragment, null, React.createElement(PluridScrollTop, {
5527
+ ref: topContainer
5528
+ }), PluridRouterExterior && React.createElement(PluridRouterExterior, {
5450
5529
  matchedRoute: matchedRoute
5451
5530
  }), React.createElement(PluridRouterShell, {
5452
5531
  matchedRoute: matchedRoute
@@ -6299,6 +6378,7 @@ const serverComputeMetastate = (isoMatch, paths, globals) => __awaiter(void 0, v
6299
6378
  space: {
6300
6379
  loading: false,
6301
6380
  animatedTransform: false,
6381
+ transform: "matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)",
6302
6382
  scale: 1,
6303
6383
  rotationX: 0,
6304
6384
  rotationY: 0,