react-cheminfo 0.23.0 → 0.24.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.
- package/README.md +39 -26
- package/lib/chrome/ui/HeaderToggle.d.ts +52 -0
- package/lib/chrome/ui/HeaderToggle.d.ts.map +1 -0
- package/lib/chrome/ui/HeaderToggle.js +31 -0
- package/lib/chrome/ui/HeaderToggle.js.map +1 -0
- package/lib/chrome/ui/index.d.ts +2 -0
- package/lib/chrome/ui/index.d.ts.map +1 -1
- package/lib/chrome/ui/index.js +1 -0
- package/lib/chrome/ui/index.js.map +1 -1
- package/lib/citation/core/gfn2Paper.d.ts +10 -0
- package/lib/citation/core/gfn2Paper.d.ts.map +1 -0
- package/lib/citation/core/gfn2Paper.js +28 -0
- package/lib/citation/core/gfn2Paper.js.map +1 -0
- package/lib/citation/core/index.d.ts +1 -0
- package/lib/citation/core/index.d.ts.map +1 -1
- package/lib/citation/core/index.js +1 -0
- package/lib/citation/core/index.js.map +1 -1
- package/lib/clipboard/ui/ClickToCopy.d.ts +8 -7
- package/lib/clipboard/ui/ClickToCopy.d.ts.map +1 -1
- package/lib/clipboard/ui/ClickToCopy.js +3 -3
- package/lib/clipboard/ui/ClickToCopy.js.map +1 -1
- package/lib/conformers.d.ts +27 -0
- package/lib/conformers.d.ts.map +1 -0
- package/lib/conformers.js +19 -0
- package/lib/conformers.js.map +1 -0
- package/lib/core.d.ts +1 -0
- package/lib/core.d.ts.map +1 -1
- package/lib/core.js +1 -0
- package/lib/core.js.map +1 -1
- package/lib/credits/core/credits.d.ts +12 -0
- package/lib/credits/core/credits.d.ts.map +1 -1
- package/lib/credits/core/credits.js +14 -0
- package/lib/credits/core/credits.js.map +1 -1
- package/lib/ecosystem/core/index.d.ts +1 -1
- package/lib/ecosystem/core/index.d.ts.map +1 -1
- package/lib/ecosystem/core/index.js.map +1 -1
- package/lib/ecosystem/core/sites.d.ts +11 -1
- package/lib/ecosystem/core/sites.d.ts.map +1 -1
- package/lib/ecosystem/core/sites.js +7 -2
- package/lib/ecosystem/core/sites.js.map +1 -1
- package/lib/ecosystem/ui/EcosystemLinks.d.ts.map +1 -1
- package/lib/ecosystem/ui/EcosystemLinks.js +3 -1
- package/lib/ecosystem/ui/EcosystemLinks.js.map +1 -1
- package/lib/ecosystem/ui/SiteTile.d.ts.map +1 -1
- package/lib/ecosystem/ui/SiteTile.js +3 -1
- package/lib/ecosystem/ui/SiteTile.js.map +1 -1
- package/lib/format/core/index.d.ts +1 -1
- package/lib/format/core/index.d.ts.map +1 -1
- package/lib/format/core/index.js +1 -1
- package/lib/format/core/index.js.map +1 -1
- package/lib/format/core/words.d.ts +9 -0
- package/lib/format/core/words.d.ts.map +1 -1
- package/lib/format/core/words.js +16 -0
- package/lib/format/core/words.js.map +1 -1
- package/lib/language/core/index.d.ts +3 -0
- package/lib/language/core/index.d.ts.map +1 -0
- package/lib/language/core/index.js +3 -0
- package/lib/language/core/index.js.map +1 -0
- package/lib/language/core/languageName.d.ts +8 -0
- package/lib/language/core/languageName.d.ts.map +1 -0
- package/lib/language/core/languageName.js +16 -0
- package/lib/language/core/languageName.js.map +1 -0
- package/lib/language/core/languageParam.d.ts +35 -0
- package/lib/language/core/languageParam.d.ts.map +1 -0
- package/lib/language/core/languageParam.js +67 -0
- package/lib/language/core/languageParam.js.map +1 -0
- package/lib/language/ui/SiteLanguage.d.ts +20 -0
- package/lib/language/ui/SiteLanguage.d.ts.map +1 -0
- package/lib/language/ui/SiteLanguage.js +14 -0
- package/lib/language/ui/SiteLanguage.js.map +1 -0
- package/lib/language/ui/index.d.ts +4 -0
- package/lib/language/ui/index.d.ts.map +1 -0
- package/lib/language/ui/index.js +3 -0
- package/lib/language/ui/index.js.map +1 -0
- package/lib/language/ui/siteLanguageContext.d.ts +12 -0
- package/lib/language/ui/siteLanguageContext.d.ts.map +1 -0
- package/lib/language/ui/siteLanguageContext.js +19 -0
- package/lib/language/ui/siteLanguageContext.js.map +1 -0
- package/lib/orbital/core/atomicOrbitals.d.ts +9 -1
- package/lib/orbital/core/atomicOrbitals.d.ts.map +1 -1
- package/lib/orbital/core/atomicOrbitals.js +7 -0
- package/lib/orbital/core/atomicOrbitals.js.map +1 -1
- package/lib/orbital/core/hydrogenic.d.ts +2 -1
- package/lib/orbital/core/hydrogenic.d.ts.map +1 -1
- package/lib/orbital/core/hydrogenic.js +2 -1
- package/lib/orbital/core/hydrogenic.js.map +1 -1
- package/lib/orbital/core/index.d.ts +1 -0
- package/lib/orbital/core/index.d.ts.map +1 -1
- package/lib/orbital/core/index.js +1 -0
- package/lib/orbital/core/index.js.map +1 -1
- package/lib/orbital/core/slaterEnergy.d.ts +35 -0
- package/lib/orbital/core/slaterEnergy.d.ts.map +1 -0
- package/lib/orbital/core/slaterEnergy.js +66 -0
- package/lib/orbital/core/slaterEnergy.js.map +1 -0
- package/lib/shared/ui/MenuButton.d.ts +3 -2
- package/lib/shared/ui/MenuButton.d.ts.map +1 -1
- package/lib/shared/ui/MenuButton.js +1 -1
- package/lib/shared/ui/MenuButton.js.map +1 -1
- package/lib/structure/core/conformerMinimise.d.ts +36 -0
- package/lib/structure/core/conformerMinimise.d.ts.map +1 -0
- package/lib/structure/core/conformerMinimise.js +81 -0
- package/lib/structure/core/conformerMinimise.js.map +1 -0
- package/lib/structure/core/conformerMinimum.d.ts +62 -0
- package/lib/structure/core/conformerMinimum.d.ts.map +1 -0
- package/lib/structure/core/conformerMinimum.js +90 -0
- package/lib/structure/core/conformerMinimum.js.map +1 -0
- package/lib/structure/core/conformerOptions.d.ts +62 -0
- package/lib/structure/core/conformerOptions.d.ts.map +1 -0
- package/lib/structure/core/conformerOptions.js +83 -0
- package/lib/structure/core/conformerOptions.js.map +1 -0
- package/lib/structure/core/conformerRefine.d.ts +104 -0
- package/lib/structure/core/conformerRefine.d.ts.map +1 -0
- package/lib/structure/core/conformerRefine.js +130 -0
- package/lib/structure/core/conformerRefine.js.map +1 -0
- package/lib/structure/core/conformerRefineRank.d.ts +36 -0
- package/lib/structure/core/conformerRefineRank.d.ts.map +1 -0
- package/lib/structure/core/conformerRefineRank.js +69 -0
- package/lib/structure/core/conformerRefineRank.js.map +1 -0
- package/lib/structure/core/conformerSession.d.ts +50 -0
- package/lib/structure/core/conformerSession.d.ts.map +1 -0
- package/lib/structure/core/conformerSession.js +88 -0
- package/lib/structure/core/conformerSession.js.map +1 -0
- package/lib/structure/core/conformerShape.d.ts +36 -0
- package/lib/structure/core/conformerShape.d.ts.map +1 -0
- package/lib/structure/core/conformerShape.js +150 -0
- package/lib/structure/core/conformerShape.js.map +1 -0
- package/lib/structure/core/conformers.d.ts +107 -0
- package/lib/structure/core/conformers.d.ts.map +1 -0
- package/lib/structure/core/conformers.js +149 -0
- package/lib/structure/core/conformers.js.map +1 -0
- package/lib/structure/core/geometryRelaxer.d.ts +66 -0
- package/lib/structure/core/geometryRelaxer.d.ts.map +1 -0
- package/lib/structure/core/geometryRelaxer.js +2 -0
- package/lib/structure/core/geometryRelaxer.js.map +1 -0
- package/lib/structure/core/index.d.ts +4 -0
- package/lib/structure/core/index.d.ts.map +1 -1
- package/lib/structure/core/index.js +2 -0
- package/lib/structure/core/index.js.map +1 -1
- package/lib/structure/core/moleculeCoordinates.d.ts +31 -0
- package/lib/structure/core/moleculeCoordinates.d.ts.map +1 -0
- package/lib/structure/core/moleculeCoordinates.js +80 -0
- package/lib/structure/core/moleculeCoordinates.js.map +1 -0
- package/lib/structure/core/molfileExport.d.ts +42 -0
- package/lib/structure/core/molfileExport.d.ts.map +1 -0
- package/lib/structure/core/molfileExport.js +47 -0
- package/lib/structure/core/molfileExport.js.map +1 -0
- package/lib/structure/core/oclResources.d.ts +12 -0
- package/lib/structure/core/oclResources.d.ts.map +1 -0
- package/lib/structure/core/oclResources.js +35 -0
- package/lib/structure/core/oclResources.js.map +1 -0
- package/lib/translate/core/catalog.d.ts +61 -0
- package/lib/translate/core/catalog.d.ts.map +1 -0
- package/lib/translate/core/catalog.js +49 -0
- package/lib/translate/core/catalog.js.map +1 -0
- package/lib/translate/core/checkTranslation.d.ts +32 -0
- package/lib/translate/core/checkTranslation.d.ts.map +1 -0
- package/lib/translate/core/checkTranslation.js +98 -0
- package/lib/translate/core/checkTranslation.js.map +1 -0
- package/lib/translate/core/contribution.d.ts +88 -0
- package/lib/translate/core/contribution.d.ts.map +1 -0
- package/lib/translate/core/contribution.js +14 -0
- package/lib/translate/core/contribution.js.map +1 -0
- package/lib/translate/core/index.d.ts +19 -0
- package/lib/translate/core/index.d.ts.map +1 -0
- package/lib/translate/core/index.js +15 -0
- package/lib/translate/core/index.js.map +1 -0
- package/lib/translate/core/marker.d.ts +45 -0
- package/lib/translate/core/marker.d.ts.map +1 -0
- package/lib/translate/core/marker.js +79 -0
- package/lib/translate/core/marker.js.map +1 -0
- package/lib/translate/core/mergeMessages.d.ts +35 -0
- package/lib/translate/core/mergeMessages.d.ts.map +1 -0
- package/lib/translate/core/mergeMessages.js +69 -0
- package/lib/translate/core/mergeMessages.js.map +1 -0
- package/lib/translate/core/session.d.ts +102 -0
- package/lib/translate/core/session.d.ts.map +1 -0
- package/lib/translate/core/session.js +162 -0
- package/lib/translate/core/session.js.map +1 -0
- package/lib/translate/core/start.d.ts +70 -0
- package/lib/translate/core/start.d.ts.map +1 -0
- package/lib/translate/core/start.js +73 -0
- package/lib/translate/core/start.js.map +1 -0
- package/lib/translate/core/suggestions.d.ts +77 -0
- package/lib/translate/core/suggestions.d.ts.map +1 -0
- package/lib/translate/core/suggestions.js +143 -0
- package/lib/translate/core/suggestions.js.map +1 -0
- package/lib/translate/core/tables.d.ts +100 -0
- package/lib/translate/core/tables.d.ts.map +1 -0
- package/lib/translate/core/tables.js +51 -0
- package/lib/translate/core/tables.js.map +1 -0
- package/lib/translate.d.ts +2 -0
- package/lib/translate.d.ts.map +1 -0
- package/lib/translate.js +6 -0
- package/lib/translate.js.map +1 -0
- package/lib/ui.d.ts +1 -0
- package/lib/ui.d.ts.map +1 -1
- package/lib/ui.js +1 -0
- package/lib/ui.js.map +1 -1
- package/lib/xtb/core/xtbRelaxer.d.ts +61 -0
- package/lib/xtb/core/xtbRelaxer.d.ts.map +1 -0
- package/lib/xtb/core/xtbRelaxer.js +108 -0
- package/lib/xtb/core/xtbRelaxer.js.map +1 -0
- package/lib/xtb.d.ts +11 -0
- package/lib/xtb.d.ts.map +1 -0
- package/lib/xtb.js +10 -0
- package/lib/xtb.js.map +1 -0
- package/package.json +18 -11
- package/src/chrome/ui/HeaderToggle.tsx +100 -0
- package/src/chrome/ui/index.ts +2 -0
- package/src/citation/core/gfn2Paper.ts +32 -0
- package/src/citation/core/index.ts +1 -0
- package/src/clipboard/ui/ClickToCopy.tsx +8 -7
- package/src/conformers.ts +87 -0
- package/src/core.ts +1 -0
- package/src/credits/core/credits.ts +16 -0
- package/src/ecosystem/core/index.ts +1 -0
- package/src/ecosystem/core/sites.ts +20 -2
- package/src/ecosystem/ui/EcosystemLinks.tsx +3 -1
- package/src/ecosystem/ui/SiteTile.tsx +3 -1
- package/src/format/core/index.ts +1 -1
- package/src/format/core/words.ts +19 -0
- package/src/language/core/index.ts +7 -0
- package/src/language/core/languageName.ts +16 -0
- package/src/language/core/languageParam.ts +70 -0
- package/src/language/ui/SiteLanguage.tsx +26 -0
- package/src/language/ui/index.ts +3 -0
- package/src/language/ui/siteLanguageContext.ts +20 -0
- package/src/orbital/core/atomicOrbitals.ts +17 -1
- package/src/orbital/core/hydrogenic.ts +2 -1
- package/src/orbital/core/index.ts +1 -0
- package/src/orbital/core/slaterEnergy.ts +83 -0
- package/src/shared/ui/MenuButton.tsx +4 -3
- package/src/structure/core/conformerMinimise.ts +99 -0
- package/src/structure/core/conformerMinimum.ts +125 -0
- package/src/structure/core/conformerOptions.ts +125 -0
- package/src/structure/core/conformerRefine.ts +234 -0
- package/src/structure/core/conformerRefineRank.ts +89 -0
- package/src/structure/core/conformerSession.ts +123 -0
- package/src/structure/core/conformerShape.ts +181 -0
- package/src/structure/core/conformers.ts +282 -0
- package/src/structure/core/geometryRelaxer.ts +71 -0
- package/src/structure/core/index.ts +13 -0
- package/src/structure/core/moleculeCoordinates.ts +93 -0
- package/src/structure/core/molfileExport.ts +62 -0
- package/src/structure/core/oclResources.ts +41 -0
- package/src/translate/core/catalog.ts +83 -0
- package/src/translate/core/checkTranslation.ts +128 -0
- package/src/translate/core/contribution.ts +99 -0
- package/src/translate/core/index.ts +72 -0
- package/src/translate/core/marker.ts +85 -0
- package/src/translate/core/mergeMessages.ts +74 -0
- package/src/translate/core/session.ts +250 -0
- package/src/translate/core/start.ts +121 -0
- package/src/translate/core/suggestions.ts +211 -0
- package/src/translate/core/tables.ts +120 -0
- package/src/translate.ts +5 -0
- package/src/ui.ts +1 -0
- package/src/xtb/core/xtbRelaxer.ts +160 -0
- package/src/xtb.ts +16 -0
- package/styles/chrome.css +61 -30
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tables of a site whose rows are translated: the element sheet, a list of
|
|
3
|
+
* ions, the rules of a nomenclature.
|
|
4
|
+
*
|
|
5
|
+
* A site's prose is not only its interface. Most of what a chemistry tool
|
|
6
|
+
* shows is a table, and a table mixes two kinds of column: what was measured
|
|
7
|
+
* or computed — an atomic number, a mass, a formula, an identifier — and what
|
|
8
|
+
* was written — a name, where the name comes from, a note. The first kind is
|
|
9
|
+
* the same in every language and must never reach a translator; the second is
|
|
10
|
+
* exactly what a translator is for.
|
|
11
|
+
*
|
|
12
|
+
* The line between them is drawn once, here. A site declares its tables, and
|
|
13
|
+
* only a field it declares can be edited, in a catalog key built the same way
|
|
14
|
+
* everywhere:
|
|
15
|
+
*
|
|
16
|
+
* ```text
|
|
17
|
+
* <table>.<row>.<field> element.Fe.name, element.Fe.origin
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Everything else about the row — the mass, the density, the id itself — stays
|
|
21
|
+
* in the data the site generates from its source, out of reach.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* The key one field of one row is kept under.
|
|
25
|
+
* @param table - The table the row belongs to.
|
|
26
|
+
* @param rowId - The row.
|
|
27
|
+
* @param fieldId - The column.
|
|
28
|
+
* @returns The catalog key, e.g. `element.Fe.name`.
|
|
29
|
+
*/
|
|
30
|
+
export function tableKey(table, rowId, fieldId) {
|
|
31
|
+
return `${table.id}.${rowId}.${fieldId}`;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Every key a table can hold, row by row and field by field.
|
|
35
|
+
*
|
|
36
|
+
* It is what the editor walks to draw the grid, and what tells it which cells
|
|
37
|
+
* are still empty: a key absent from the catalog is a translation nobody has
|
|
38
|
+
* written yet, not a field that does not exist.
|
|
39
|
+
* @param table - The table to walk.
|
|
40
|
+
* @returns One entry per cell, in reading order.
|
|
41
|
+
*/
|
|
42
|
+
export function tableCells(table) {
|
|
43
|
+
const cells = [];
|
|
44
|
+
for (const row of table.rows) {
|
|
45
|
+
for (const field of table.fields) {
|
|
46
|
+
cells.push({ key: tableKey(table, row.id, field.id), row, field });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return cells;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tables.js","sourceRoot":"","sources":["../../../src/translate/core/tables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAwDH;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CACtB,KAAoC,EACpC,KAAa,EACb,OAAe;IAEf,OAAO,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,IAAI,OAAO,EAAE,CAAC;AAC3C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,KAAwB;IACjD,MAAM,KAAK,GAAgB,EAAE,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QAC7B,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACjC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../src/translate.ts"],"names":[],"mappings":"AAIA,cAAc,2BAA2B,CAAC"}
|
package/lib/translate.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Everything a page, an overlay or a server needs to translate a site of the
|
|
2
|
+
// family: the catalogs, the invisible marker, the checks, and the session a
|
|
3
|
+
// page in translate mode hands to the overlay. It is its own entry point
|
|
4
|
+
// because an ordinary visit loads none of it.
|
|
5
|
+
export * from "./translate/core/index.js";
|
|
6
|
+
//# sourceMappingURL=translate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translate.js","sourceRoot":"","sources":["../src/translate.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,yEAAyE;AACzE,8CAA8C;AAC9C,cAAc,2BAA2B,CAAC"}
|
package/lib/ui.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from './ecosystem/ui/index.ts';
|
|
|
14
14
|
export * from './error/ui/index.ts';
|
|
15
15
|
export * from './help/ui/index.ts';
|
|
16
16
|
export * from './hooks/ui/index.ts';
|
|
17
|
+
export * from './language/ui/index.ts';
|
|
17
18
|
export * from './overlay/ui/index.ts';
|
|
18
19
|
export * from './parallel/ui/index.ts';
|
|
19
20
|
export * from './pedagogy/ui/index.ts';
|
package/lib/ui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAA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CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
|
package/lib/ui.js
CHANGED
|
@@ -14,6 +14,7 @@ export * from "./ecosystem/ui/index.js";
|
|
|
14
14
|
export * from "./error/ui/index.js";
|
|
15
15
|
export * from "./help/ui/index.js";
|
|
16
16
|
export * from "./hooks/ui/index.js";
|
|
17
|
+
export * from "./language/ui/index.js";
|
|
17
18
|
export * from "./overlay/ui/index.js";
|
|
18
19
|
export * from "./parallel/ui/index.js";
|
|
19
20
|
export * from "./pedagogy/ui/index.js";
|
package/lib/ui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { GeometryRelaxer } from '../../structure/core/geometryRelaxer.ts';
|
|
2
|
+
/**
|
|
3
|
+
* kcal/mol per hartree, CODATA 2018. Every energy a relaxer reports is in
|
|
4
|
+
* kcal/mol, so it can be read against a force-field energy without the reader
|
|
5
|
+
* converting anything.
|
|
6
|
+
*/
|
|
7
|
+
export declare const KCAL_PER_MOL_PER_HARTREE = 627.5094740631;
|
|
8
|
+
/** How many occjs instances a relaxation may use. */
|
|
9
|
+
export interface XtbRelaxerOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Hard cap on the number of GFN2 instances. Each one costs about 100 MB of
|
|
12
|
+
* WebAssembly memory, so a long batch on a small machine is worth capping.
|
|
13
|
+
* @default one per structure, one below the core count
|
|
14
|
+
*/
|
|
15
|
+
maxWorkers?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Total molecular charge in units of e, applied to every structure.
|
|
18
|
+
* @default 0
|
|
19
|
+
*/
|
|
20
|
+
charge?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Unpaired electrons, applied to every structure. `1` for a doublet radical.
|
|
23
|
+
* @default 0
|
|
24
|
+
*/
|
|
25
|
+
unpairedElectrons?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Cycle budget of one optimization.
|
|
28
|
+
* @default 250
|
|
29
|
+
*/
|
|
30
|
+
maxCycles?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* GFN2-xTB as a {@link GeometryRelaxer}: the second stage that decides how good
|
|
34
|
+
* a force field's conformers really are.
|
|
35
|
+
*
|
|
36
|
+
* `xtb-wasm` is loaded on the **first call**, never on the import, so a page that
|
|
37
|
+
* offers refinement as an action downloads the 21.5 MB WebAssembly only once a
|
|
38
|
+
* visitor asks for it. The module is cached afterwards, and the worker pool it
|
|
39
|
+
* starts is kept alive between calls.
|
|
40
|
+
*
|
|
41
|
+
* Energies come back in kcal/mol, which is the unit `conformer.energy` is
|
|
42
|
+
* already in.
|
|
43
|
+
* @param options - Instance cap, charge, spin and the cycle budget.
|
|
44
|
+
* @returns A relaxer to hand to `refineConformers`, or to call directly.
|
|
45
|
+
*/
|
|
46
|
+
export declare function xtbRelaxer(options?: XtbRelaxerOptions): GeometryRelaxer;
|
|
47
|
+
/**
|
|
48
|
+
* Whether this environment has the worker pool the relaxer prefers.
|
|
49
|
+
*
|
|
50
|
+
* Without `Worker` — Node, a prerender pass, a test run — the relaxer still
|
|
51
|
+
* works, one structure at a time on the calling thread, so a site keeps one code
|
|
52
|
+
* path. It is the caller's business only when the difference in speed matters.
|
|
53
|
+
* @returns `true` in a browser, `false` in a plain Node process.
|
|
54
|
+
*/
|
|
55
|
+
export declare function isXtbRelaxerAvailable(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Drop the GFN2 worker pool and the memory it holds, about 100 MB per instance.
|
|
58
|
+
* The next relaxation starts a fresh one.
|
|
59
|
+
*/
|
|
60
|
+
export declare function disposeXtbRelaxer(): Promise<void>;
|
|
61
|
+
//# sourceMappingURL=xtbRelaxer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xtbRelaxer.d.ts","sourceRoot":"","sources":["../../../src/xtb/core/xtbRelaxer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,yCAAyC,CAAC;AAEjD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,iBAAoB,CAAC;AAE1D,qDAAqD;AACrD,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,eAAe,CAqC3E;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAGvD"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { errorMessage } from "../../error/core/toError.js";
|
|
2
|
+
/**
|
|
3
|
+
* kcal/mol per hartree, CODATA 2018. Every energy a relaxer reports is in
|
|
4
|
+
* kcal/mol, so it can be read against a force-field energy without the reader
|
|
5
|
+
* converting anything.
|
|
6
|
+
*/
|
|
7
|
+
export const KCAL_PER_MOL_PER_HARTREE = 627.509_474_063_1;
|
|
8
|
+
/**
|
|
9
|
+
* GFN2-xTB as a {@link GeometryRelaxer}: the second stage that decides how good
|
|
10
|
+
* a force field's conformers really are.
|
|
11
|
+
*
|
|
12
|
+
* `xtb-wasm` is loaded on the **first call**, never on the import, so a page that
|
|
13
|
+
* offers refinement as an action downloads the 21.5 MB WebAssembly only once a
|
|
14
|
+
* visitor asks for it. The module is cached afterwards, and the worker pool it
|
|
15
|
+
* starts is kept alive between calls.
|
|
16
|
+
*
|
|
17
|
+
* Energies come back in kcal/mol, which is the unit `conformer.energy` is
|
|
18
|
+
* already in.
|
|
19
|
+
* @param options - Instance cap, charge, spin and the cycle budget.
|
|
20
|
+
* @returns A relaxer to hand to `refineConformers`, or to call directly.
|
|
21
|
+
*/
|
|
22
|
+
export function xtbRelaxer(options = {}) {
|
|
23
|
+
return async (geometries, runOptions = {}) => {
|
|
24
|
+
const xtb = await loadXtb();
|
|
25
|
+
const settings = {
|
|
26
|
+
charge: options.charge ?? 0,
|
|
27
|
+
unpairedElectrons: options.unpairedElectrons ?? 0,
|
|
28
|
+
...(options.maxCycles === undefined
|
|
29
|
+
? {}
|
|
30
|
+
: { maxCycles: options.maxCycles }),
|
|
31
|
+
};
|
|
32
|
+
const requests = geometries.map((geometry) => ({ geometry, settings }));
|
|
33
|
+
const results = isXtbRelaxerAvailable()
|
|
34
|
+
? await xtb.relaxGeometries(requests, {
|
|
35
|
+
maxWorkers: options.maxWorkers,
|
|
36
|
+
onSettled: runOptions.onSettled,
|
|
37
|
+
signal: runOptions.signal,
|
|
38
|
+
})
|
|
39
|
+
: await relaxHere(xtb, requests, runOptions);
|
|
40
|
+
const relaxed = [];
|
|
41
|
+
for (const result of results) {
|
|
42
|
+
relaxed.push({
|
|
43
|
+
coordinates: result.coordinates,
|
|
44
|
+
energy: result.energy.total * KCAL_PER_MOL_PER_HARTREE,
|
|
45
|
+
dispersionEnergy: result.energy.dispersion === null
|
|
46
|
+
? null
|
|
47
|
+
: result.energy.dispersion * KCAL_PER_MOL_PER_HARTREE,
|
|
48
|
+
cycles: result.cycles,
|
|
49
|
+
converged: result.converged,
|
|
50
|
+
warnings: result.warnings,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return relaxed;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Whether this environment has the worker pool the relaxer prefers.
|
|
58
|
+
*
|
|
59
|
+
* Without `Worker` — Node, a prerender pass, a test run — the relaxer still
|
|
60
|
+
* works, one structure at a time on the calling thread, so a site keeps one code
|
|
61
|
+
* path. It is the caller's business only when the difference in speed matters.
|
|
62
|
+
* @returns `true` in a browser, `false` in a plain Node process.
|
|
63
|
+
*/
|
|
64
|
+
export function isXtbRelaxerAvailable() {
|
|
65
|
+
return typeof Worker !== 'undefined';
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Drop the GFN2 worker pool and the memory it holds, about 100 MB per instance.
|
|
69
|
+
* The next relaxation starts a fresh one.
|
|
70
|
+
*/
|
|
71
|
+
export async function disposeXtbRelaxer() {
|
|
72
|
+
const loaded = await pending;
|
|
73
|
+
loaded?.disposeOccPool();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Relax one structure after another on this thread, for want of a pool.
|
|
77
|
+
* @param xtb - The loaded `xtb-wasm` module.
|
|
78
|
+
* @param requests - The structures to relax, with their settings.
|
|
79
|
+
* @param runOptions - Progress and cancellation.
|
|
80
|
+
* @returns One `xtb-wasm` result per request, in request order.
|
|
81
|
+
* @throws {Error} When the run is cancelled, or when occ fails.
|
|
82
|
+
*/
|
|
83
|
+
async function relaxHere(xtb, requests, runOptions) {
|
|
84
|
+
const results = [];
|
|
85
|
+
for (const [index, request] of requests.entries()) {
|
|
86
|
+
if (runOptions.signal?.aborted === true) {
|
|
87
|
+
throw new Error('calculation cancelled');
|
|
88
|
+
}
|
|
89
|
+
/* eslint-disable-next-line no-await-in-loop -- there is one thread: the
|
|
90
|
+
whole point of this path is that the structures run in turn. */
|
|
91
|
+
results.push(await xtb.relaxGeometryInProcess(request));
|
|
92
|
+
runOptions.onSettled?.(index + 1, requests.length);
|
|
93
|
+
}
|
|
94
|
+
return results;
|
|
95
|
+
}
|
|
96
|
+
let pending = null;
|
|
97
|
+
function loadXtb() {
|
|
98
|
+
pending ??= import('xtb-wasm').catch((error) => {
|
|
99
|
+
// A failed chunk load must not poison every later call of the session.
|
|
100
|
+
pending = null;
|
|
101
|
+
// The reason is in the message, not only in `cause`: what a reader sees is
|
|
102
|
+
// whatever the UI renders, and "could not be loaded" alone names neither a
|
|
103
|
+
// missing install nor a chunk that failed to come down the wire.
|
|
104
|
+
throw new Error(`xtb-wasm could not be loaded, so geometries cannot be refined: ${errorMessage(error)}`, { cause: error });
|
|
105
|
+
});
|
|
106
|
+
return pending;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=xtbRelaxer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xtbRelaxer.js","sourceRoot":"","sources":["../../../src/xtb/core/xtbRelaxer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAQ3D;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAC;AA2B1D;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,UAAU,CAAC,UAA6B,EAAE;IACxD,OAAO,KAAK,EACV,UAAwC,EACxC,aAA6B,EAAE,EACH,EAAE;QAC9B,MAAM,GAAG,GAAG,MAAM,OAAO,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG;YACf,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,CAAC;YAC3B,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,IAAI,CAAC;YACjD,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS;gBACjC,CAAC,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drags `xtb-wasm` and a 21.5 MB WebAssembly binary
|
|
5
|
+
* behind it, and because most pages never refine anything. The contract it
|
|
6
|
+
* implements — `GeometryRelaxer` — lives in `react-cheminfo/core`, so the code
|
|
7
|
+
* that orchestrates a refinement (`refineConformers`) loads none of this.
|
|
8
|
+
*/
|
|
9
|
+
export type { XtbRelaxerOptions } from './xtb/core/xtbRelaxer.ts';
|
|
10
|
+
export { KCAL_PER_MOL_PER_HARTREE, disposeXtbRelaxer, isXtbRelaxerAvailable, xtbRelaxer, } from './xtb/core/xtbRelaxer.ts';
|
|
11
|
+
//# sourceMappingURL=xtb.d.ts.map
|
package/lib/xtb.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xtb.d.ts","sourceRoot":"","sources":["../src/xtb.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,GACX,MAAM,0BAA0B,CAAC"}
|
package/lib/xtb.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GFN2-xTB, the opt-in second stage after a force field.
|
|
3
|
+
*
|
|
4
|
+
* Its own door because it drags `xtb-wasm` and a 21.5 MB WebAssembly binary
|
|
5
|
+
* behind it, and because most pages never refine anything. The contract it
|
|
6
|
+
* implements — `GeometryRelaxer` — lives in `react-cheminfo/core`, so the code
|
|
7
|
+
* that orchestrates a refinement (`refineConformers`) loads none of this.
|
|
8
|
+
*/
|
|
9
|
+
export { KCAL_PER_MOL_PER_HARTREE, disposeXtbRelaxer, isXtbRelaxerAvailable, xtbRelaxer, } from "./xtb/core/xtbRelaxer.js";
|
|
10
|
+
//# sourceMappingURL=xtb.js.map
|
package/lib/xtb.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xtb.js","sourceRoot":"","sources":["../src/xtb.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,GACX,MAAM,0BAA0B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cheminfo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React components, hooks and framework-free helpers shared by the cheminfo sites: site chrome, citations, sharing, routing, pedagogy, charts, and the structure, orbital and 3D molecule viewers",
|
|
6
6
|
"author": "Luc Patiny",
|
|
@@ -16,15 +16,18 @@
|
|
|
16
16
|
],
|
|
17
17
|
"exports": {
|
|
18
18
|
"./build-info": "./lib/build-info.js",
|
|
19
|
+
"./conformers": "./lib/conformers.js",
|
|
19
20
|
"./core": "./lib/core.js",
|
|
20
21
|
"./molecule3d": "./lib/molecule3d.js",
|
|
21
22
|
"./orbital": "./lib/orbital.js",
|
|
22
23
|
"./slides": "./lib/slides.js",
|
|
23
24
|
"./spectra": "./lib/spectra.js",
|
|
24
25
|
"./structure": "./lib/structure.js",
|
|
26
|
+
"./styles/*.css": "./styles/*.css",
|
|
27
|
+
"./translate": "./lib/translate.js",
|
|
25
28
|
"./ui": "./lib/ui.js",
|
|
26
29
|
"./vite": "./lib/vite.js",
|
|
27
|
-
"./
|
|
30
|
+
"./xtb": "./lib/xtb.js"
|
|
28
31
|
},
|
|
29
32
|
"bin": {
|
|
30
33
|
"cheminfo-check-deploy": "bin/check-deploy.mjs",
|
|
@@ -55,7 +58,11 @@
|
|
|
55
58
|
"tsc-build": "tsc --project tsconfig.build.json"
|
|
56
59
|
},
|
|
57
60
|
"dependencies": {
|
|
61
|
+
"@formatjs/icu-messageformat-parser": "^3.5.20",
|
|
58
62
|
"cheminfo-font": "^1.28.0",
|
|
63
|
+
"intl-messageformat": "^11.2.15",
|
|
64
|
+
"leven": "^4.1.0",
|
|
65
|
+
"openchemlib": "^9.25.0",
|
|
59
66
|
"react-markdown": "^10.1.0",
|
|
60
67
|
"rehype-raw": "^7.0.0",
|
|
61
68
|
"rehype-sanitize": "^6.0.0",
|
|
@@ -80,7 +87,6 @@
|
|
|
80
87
|
"ml-pca": "^4.1.1",
|
|
81
88
|
"ml-signal-processing": "^2.2.2",
|
|
82
89
|
"molstar": "^5.11.0",
|
|
83
|
-
"openchemlib": "^9.25.0",
|
|
84
90
|
"prettier": "^3.9.6",
|
|
85
91
|
"react": "^19.2.8",
|
|
86
92
|
"react-dom": "^19.2.8",
|
|
@@ -91,20 +97,21 @@
|
|
|
91
97
|
"storybook": "^10.5.8",
|
|
92
98
|
"typescript": "^6.0.3",
|
|
93
99
|
"vite": "^8.2.1",
|
|
94
|
-
"vitest": "^4.1.10"
|
|
100
|
+
"vitest": "^4.1.10",
|
|
101
|
+
"xtb-wasm": "^1.1.0"
|
|
95
102
|
},
|
|
96
103
|
"peerDependencies": {
|
|
97
104
|
"@blueprintjs/core": "^6.18.0",
|
|
98
105
|
"ml-pca": "^4.1.1",
|
|
99
106
|
"ml-signal-processing": "^2.2.2",
|
|
100
107
|
"molstar": "^5.11.0",
|
|
101
|
-
"
|
|
102
|
-
"react": "^
|
|
103
|
-
"react-dom": "^18.3.1 || ^19.0.0",
|
|
108
|
+
"react": "^19.0.0",
|
|
109
|
+
"react-dom": "^19.0.0",
|
|
104
110
|
"react-ocl": "^8.7.1",
|
|
105
111
|
"react-science": "^20.6.2 || ^21.0.0 || ^22.0.0 || ^23.0.0",
|
|
106
112
|
"spectra-processor": "^5.0.0",
|
|
107
|
-
"vite": "^7.0.0 || ^8.0.0"
|
|
113
|
+
"vite": "^7.0.0 || ^8.0.0",
|
|
114
|
+
"xtb-wasm": "^1.1.0"
|
|
108
115
|
},
|
|
109
116
|
"repository": {
|
|
110
117
|
"type": "git",
|
|
@@ -124,9 +131,6 @@
|
|
|
124
131
|
"molstar": {
|
|
125
132
|
"optional": true
|
|
126
133
|
},
|
|
127
|
-
"openchemlib": {
|
|
128
|
-
"optional": true
|
|
129
|
-
},
|
|
130
134
|
"react-ocl": {
|
|
131
135
|
"optional": true
|
|
132
136
|
},
|
|
@@ -135,6 +139,9 @@
|
|
|
135
139
|
},
|
|
136
140
|
"vite": {
|
|
137
141
|
"optional": true
|
|
142
|
+
},
|
|
143
|
+
"xtb-wasm": {
|
|
144
|
+
"optional": true
|
|
138
145
|
}
|
|
139
146
|
}
|
|
140
147
|
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Button, ButtonGroup } from '@blueprintjs/core';
|
|
2
|
+
import type { ReactElement } from 'react';
|
|
3
|
+
|
|
4
|
+
/** One value a {@link HeaderToggle} offers. */
|
|
5
|
+
export interface HeaderToggleOption<TValue extends string = string> {
|
|
6
|
+
/** What picking it sets. */
|
|
7
|
+
value: TValue;
|
|
8
|
+
/**
|
|
9
|
+
* What the button reads. It sits in the bar beside every other value, so it
|
|
10
|
+
* is a mark rather than a sentence: `FR`, `°C`.
|
|
11
|
+
*/
|
|
12
|
+
label: string;
|
|
13
|
+
/**
|
|
14
|
+
* What the pointer and a screen reader are told, e.g. `Français` behind
|
|
15
|
+
* `FR`.
|
|
16
|
+
* @default the label
|
|
17
|
+
*/
|
|
18
|
+
title?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Props of {@link HeaderToggle}. */
|
|
22
|
+
export interface HeaderToggleProps<TValue extends string = string> {
|
|
23
|
+
/** What the row sets, e.g. `Language`: the name it is read by. */
|
|
24
|
+
label: string;
|
|
25
|
+
/** The values on offer, in the order they are shown. */
|
|
26
|
+
options: ReadonlyArray<HeaderToggleOption<TValue>>;
|
|
27
|
+
/** The value in force. */
|
|
28
|
+
value: TValue;
|
|
29
|
+
/** Called with the value picked. */
|
|
30
|
+
onChange: (value: TValue) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the bar has run out of room: the row is then the one button of the
|
|
33
|
+
* value in force, and a click advances to the next.
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
compact?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* `data-testid` of the row; each button carries it suffixed by its value.
|
|
39
|
+
* @default undefined
|
|
40
|
+
*/
|
|
41
|
+
testId?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A setting of the site header shown as the values themselves, the one in
|
|
46
|
+
* force pressed — the language the page is written in, the scale a temperature
|
|
47
|
+
* is read on.
|
|
48
|
+
*
|
|
49
|
+
* It is a row of buttons rather than a menu: there are two or four values, all
|
|
50
|
+
* of them a mark wide, so a click sets one instead of opening a list to look
|
|
51
|
+
* through, and the bar says what is set without being asked.
|
|
52
|
+
* @param props - The values, the one in force, and what a click changes.
|
|
53
|
+
* @returns The row, or the single advancing button of a narrow bar.
|
|
54
|
+
*/
|
|
55
|
+
export function HeaderToggle<TValue extends string>(
|
|
56
|
+
props: HeaderToggleProps<TValue>,
|
|
57
|
+
): ReactElement | null {
|
|
58
|
+
const { label, options, value, onChange, compact = false, testId } = props;
|
|
59
|
+
const index = options.findIndex((option) => option.value === value);
|
|
60
|
+
const current = options[index === -1 ? 0 : index];
|
|
61
|
+
if (current === undefined) return null;
|
|
62
|
+
|
|
63
|
+
if (compact) {
|
|
64
|
+
const next = options[(options.indexOf(current) + 1) % options.length];
|
|
65
|
+
return (
|
|
66
|
+
<Button
|
|
67
|
+
variant="minimal"
|
|
68
|
+
className="site-toggle site-toggle--compact"
|
|
69
|
+
text={current.label}
|
|
70
|
+
aria-label={`${label}: ${current.title ?? current.label}`}
|
|
71
|
+
title={`${label}: ${current.title ?? current.label}`}
|
|
72
|
+
data-testid={testId}
|
|
73
|
+
onClick={() => {
|
|
74
|
+
if (next !== undefined) onChange(next.value);
|
|
75
|
+
}}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<ButtonGroup className="site-toggle" role="group" aria-label={label}>
|
|
82
|
+
{options.map((option) => (
|
|
83
|
+
<Button
|
|
84
|
+
key={option.value}
|
|
85
|
+
variant="minimal"
|
|
86
|
+
active={option.value === current.value}
|
|
87
|
+
aria-pressed={option.value === current.value}
|
|
88
|
+
text={option.label}
|
|
89
|
+
title={option.title ?? option.label}
|
|
90
|
+
data-testid={
|
|
91
|
+
testId === undefined ? undefined : `${testId}-${option.value}`
|
|
92
|
+
}
|
|
93
|
+
onClick={() => {
|
|
94
|
+
onChange(option.value);
|
|
95
|
+
}}
|
|
96
|
+
/>
|
|
97
|
+
))}
|
|
98
|
+
</ButtonGroup>
|
|
99
|
+
);
|
|
100
|
+
}
|
package/src/chrome/ui/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export type { HeaderToggleOption, HeaderToggleProps } from './HeaderToggle.tsx';
|
|
2
|
+
export { HeaderToggle } from './HeaderToggle.tsx';
|
|
1
3
|
export type { NavItem } from './navItem.ts';
|
|
2
4
|
// A site drawing its own link needs the same reading of a click the shared nav
|
|
3
5
|
// items use: a middle click or a modified one belongs to the browser.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Reference } from './reference.ts';
|
|
2
|
+
import type { CitedWork } from './works.ts';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The paper that defines GFN2-xTB: the semi-empirical tight-binding method, its
|
|
6
|
+
* multipole electrostatics and its D4 dispersion.
|
|
7
|
+
*/
|
|
8
|
+
export const GFN2_XTB_PAPER: Reference = {
|
|
9
|
+
authors: [
|
|
10
|
+
{ given: 'C.', family: 'Bannwarth' },
|
|
11
|
+
{ given: 'S.', family: 'Ehlert' },
|
|
12
|
+
{ given: 'S.', family: 'Grimme' },
|
|
13
|
+
],
|
|
14
|
+
title:
|
|
15
|
+
'GFN2-xTB — an accurate and broadly parametrized self-consistent tight-binding quantum chemical method with multipole electrostatics and density-dependent dispersion contributions',
|
|
16
|
+
journal: 'Journal of Chemical Theory and Computation',
|
|
17
|
+
journalAbbreviation: 'J. Chem. Theory Comput.',
|
|
18
|
+
year: 2019,
|
|
19
|
+
volume: '15',
|
|
20
|
+
issue: '3',
|
|
21
|
+
firstPage: '1652',
|
|
22
|
+
lastPage: '1671',
|
|
23
|
+
doi: '10.1021/acs.jctc.8b01176',
|
|
24
|
+
publisher: 'American Chemical Society',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** GFN2-xTB, for a site that computes an energy or a geometry with it. */
|
|
28
|
+
export const GFN2_XTB_WORK: CitedWork = {
|
|
29
|
+
reference: GFN2_XTB_PAPER,
|
|
30
|
+
what: 'GFN2-xTB',
|
|
31
|
+
note: 'Cite it for the method behind every refined geometry and energy.',
|
|
32
|
+
};
|
|
@@ -12,6 +12,7 @@ export {
|
|
|
12
12
|
citationFilename,
|
|
13
13
|
formatCitation,
|
|
14
14
|
} from './formats.ts';
|
|
15
|
+
export { GFN2_XTB_PAPER, GFN2_XTB_WORK } from './gfn2Paper.ts';
|
|
15
16
|
export { OPENCHEMLIB_PAPER, OPENCHEMLIB_WORK } from './openchemlibPaper.ts';
|
|
16
17
|
export { PLATFORM_PAPER, PLATFORM_WORK } from './platformPaper.ts';
|
|
17
18
|
export type { Reference, ReferenceAuthor } from './reference.ts';
|
|
@@ -24,7 +24,7 @@ export interface ClickToCopyProps {
|
|
|
24
24
|
* function is called only when the value is clicked.
|
|
25
25
|
*/
|
|
26
26
|
value: ClipboardContent | (() => ClipboardContent);
|
|
27
|
-
/** What is shown; the pointer turns into
|
|
27
|
+
/** What is shown; the pointer turns into a clipboard over it. */
|
|
28
28
|
children: ReactNode;
|
|
29
29
|
/**
|
|
30
30
|
* What the value is, named in the hover title: `Copy the SMILES (C=CC=O)`.
|
|
@@ -46,9 +46,10 @@ export interface ClickToCopyProps {
|
|
|
46
46
|
*/
|
|
47
47
|
as?: ClickToCopyElement;
|
|
48
48
|
/**
|
|
49
|
-
* Whether the value is a tab stop and a button of its own, with
|
|
50
|
-
* Off when a copy button beside it
|
|
51
|
-
*
|
|
49
|
+
* Whether the value is a tab stop and a button of its own, with the glyph a
|
|
50
|
+
* keyboard is shown instead of the cursor. Off when a copy button beside it
|
|
51
|
+
* already copies the same value, so the keyboard and a screen reader meet
|
|
52
|
+
* one control.
|
|
52
53
|
* @default true
|
|
53
54
|
*/
|
|
54
55
|
focusable?: boolean;
|
|
@@ -83,9 +84,9 @@ const NESTED_CONTROL =
|
|
|
83
84
|
* A value that is copied by clicking it.
|
|
84
85
|
*
|
|
85
86
|
* Text in a tool is not selectable — a drag across a viewer must not paint the
|
|
86
|
-
* page — so what is worth taking away is copied this way instead:
|
|
87
|
-
*
|
|
88
|
-
*
|
|
87
|
+
* page — so what is worth taking away is copied this way instead: a cursor
|
|
88
|
+
* carrying a clipboard and a tint announce it on hover, a click or `Enter` puts
|
|
89
|
+
* it on the clipboard, and a tick confirms it. The click stops there, so
|
|
89
90
|
* a value inside a clickable row copies without also opening the row, and a
|
|
90
91
|
* link or a button nested in the value keeps its own click.
|
|
91
92
|
* @param props - See {@link ClickToCopyProps}.
|