@lvce-editor/about-view 2.2.0 → 2.4.0

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.
@@ -800,15 +800,15 @@ const WebWorkerRpcClient = {
800
800
  };
801
801
 
802
802
  const None = 0;
803
- const Ok = 1;
804
- const Copy = 2;
803
+ const Ok$1 = 1;
804
+ const Copy$1 = 2;
805
805
 
806
806
  const getNextFocus = focusId => {
807
807
  switch (focusId) {
808
- case Ok:
809
- return Copy;
810
- case Copy:
811
- return Ok;
808
+ case Ok$1:
809
+ return Copy$1;
810
+ case Copy$1:
811
+ return Ok$1;
812
812
  default:
813
813
  return None;
814
814
  }
@@ -826,10 +826,10 @@ const focusNext = state => {
826
826
 
827
827
  const getPreviousFocus = focusId => {
828
828
  switch (focusId) {
829
- case Ok:
830
- return Copy;
831
- case Copy:
832
- return Ok;
829
+ case Ok$1:
830
+ return Copy$1;
831
+ case Copy$1:
832
+ return Ok$1;
833
833
  default:
834
834
  return None;
835
835
  }
@@ -846,13 +846,12 @@ const focusPrevious = state => {
846
846
  };
847
847
 
848
848
  const emptyObject = {};
849
- const RE_PLACEHOLDER = /{(PH\d+)}/g;
849
+ const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
850
850
  const i18nString = (key, placeholders = emptyObject) => {
851
851
  if (placeholders === emptyObject) {
852
852
  return key;
853
853
  }
854
854
  const replacer = (match, rest) => {
855
- // @ts-ignore
856
855
  return placeholders[rest];
857
856
  };
858
857
  return key.replaceAll(RE_PLACEHOLDER, replacer);
@@ -1260,26 +1259,31 @@ const mergeClassNames = (...classNames) => {
1260
1259
  return joinBySpace(...classNames.filter(Boolean));
1261
1260
  };
1262
1261
 
1263
- const getPrimaryButtonVirtualDom = (message, onClick) => {
1262
+ const getPrimaryButtonVirtualDom = (message, onClick, name) => {
1264
1263
  return [{
1265
1264
  type: Button$1,
1266
1265
  className: mergeClassNames(Button$2, ButtonPrimary),
1267
1266
  onClick,
1268
- childCount: 1
1267
+ childCount: 1,
1268
+ name
1269
1269
  }, text(message)];
1270
1270
  };
1271
- const getSecondaryButtonVirtualDom = (message, onClick) => {
1271
+ const getSecondaryButtonVirtualDom = (message, onClick, name) => {
1272
1272
  return [{
1273
1273
  type: Button$1,
1274
1274
  className: mergeClassNames(Button$2, ButtonSecondary),
1275
1275
  onClick,
1276
- childCount: 1
1276
+ childCount: 1,
1277
+ name
1277
1278
  }, text(message)];
1278
1279
  };
1279
1280
 
1280
1281
  const DialogIcon = 'DialogIcon';
1281
1282
  const DialogHeading = 'DialogHeading';
1282
1283
 
1284
+ const Ok = 'Ok';
1285
+ const Copy = 'Copy';
1286
+
1283
1287
  const Focusable = -1;
1284
1288
 
1285
1289
  const getDialogVirtualDom = (content, closeMessage, infoMessage, okMessage, copyMessage, productName) => {
@@ -1330,7 +1334,7 @@ const getDialogVirtualDom = (content, closeMessage, infoMessage, okMessage, copy
1330
1334
  type: Div,
1331
1335
  className: DialogButtonsRow,
1332
1336
  childCount: 2
1333
- }, ...getSecondaryButtonVirtualDom(okMessage, HandleClickOk), ...getPrimaryButtonVirtualDom(copyMessage, HandleClickCopy)];
1337
+ }, ...getSecondaryButtonVirtualDom(okMessage, HandleClickOk, Ok), ...getPrimaryButtonVirtualDom(copyMessage, HandleClickCopy, Copy)];
1334
1338
  return dom;
1335
1339
  };
1336
1340
 
@@ -1344,13 +1348,36 @@ const getAboutVirtualDom = (productName, lines, closeMessage, okMessage, copyMes
1344
1348
  }, ...getDialogVirtualDom(content, closeMessage, infoMessage, okMessage, copyMessage, productName)];
1345
1349
  };
1346
1350
 
1351
+ const Tab = 2;
1352
+ const Escape = 8;
1353
+
1354
+ const Shift = 1 << 10 >>> 0;
1355
+
1356
+ const FocusAbout = 4;
1357
+
1358
+ const getKeyBindings = () => {
1359
+ return [{
1360
+ key: Escape,
1361
+ command: 'About.handleClickClose',
1362
+ when: FocusAbout
1363
+ }, {
1364
+ key: Tab,
1365
+ command: 'About.focusNext',
1366
+ when: FocusAbout
1367
+ }, {
1368
+ key: Tab | Shift,
1369
+ command: 'About.focusPrevious',
1370
+ when: FocusAbout
1371
+ }];
1372
+ };
1373
+
1347
1374
  const loadContent = state => {
1348
1375
  const lines = getDetailStringWeb();
1349
1376
  return {
1350
1377
  ...state,
1351
1378
  productName: productNameLong,
1352
1379
  lines,
1353
- focusId: Ok
1380
+ focusId: Ok$1
1354
1381
  };
1355
1382
  };
1356
1383
 
@@ -1383,10 +1410,10 @@ const closeDialog = () => {
1383
1410
 
1384
1411
  const getFocusSelector = focusId => {
1385
1412
  switch (focusId) {
1386
- case Copy:
1387
- return '.ButtonPrimary';
1388
- case Ok:
1389
- return '.ButtonSecondary';
1413
+ case Copy$1:
1414
+ return Copy;
1415
+ case Ok$1:
1416
+ return Ok;
1390
1417
  default:
1391
1418
  return '';
1392
1419
  }
@@ -1410,8 +1437,8 @@ const renderFocus = {
1410
1437
  return oldState.focusId === newState.focusId;
1411
1438
  },
1412
1439
  apply(oldState, newState) {
1413
- const selector = getFocusSelector(newState.focusId);
1414
- return ['setFocused', selector];
1440
+ const name = getFocusSelector(newState.focusId);
1441
+ return ['Viewlet.focusElementByName', name];
1415
1442
  }
1416
1443
  };
1417
1444
  const render = [renderDialog, renderFocus];
@@ -1450,6 +1477,7 @@ const commandMap = {
1450
1477
  'About.focusPrevious': focusPrevious,
1451
1478
  'About.getDetailString': getDetailString,
1452
1479
  'About.getDetailStringWeb': getDetailStringWeb,
1480
+ 'About.getKeyBindings': getKeyBindings,
1453
1481
  'About.getVirtualDom': getAboutVirtualDom,
1454
1482
  'About.loadContent': loadContent,
1455
1483
  'About.render': doRender,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/about-view",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
4
4
  "description": "",
5
5
  "main": "dist/aboutWorkerMain.js",
6
6
  "type": "module",