react-cheminfo 0.27.0 → 0.28.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.
@@ -3,7 +3,7 @@ import type { ReactElement, ReactNode } from 'react';
3
3
  export interface CopyableValueProps {
4
4
  /** What the value is, written above it, e.g. `InChIKey`. */
5
5
  label: string;
6
- /** The value itself, which is also what the button copies. */
6
+ /** The value itself, which is what a click on it copies. */
7
7
  value: string;
8
8
  /**
9
9
  * A longer explanation of the label, shown on hover.
@@ -22,8 +22,9 @@ export interface CopyableValueProps {
22
22
  */
23
23
  maxHeight?: number | string;
24
24
  /**
25
- * What the pointer and a screen reader are told the button does.
26
- * @default `Copy the ${label}`
25
+ * What the pointer and a screen reader are told, replacing the title built
26
+ * from the label and the value.
27
+ * @default undefined — `Copy the ${label} (${value})`
27
28
  */
28
29
  copyTitle?: string;
29
30
  /**
@@ -38,14 +39,16 @@ export interface CopyableValueProps {
38
39
  className?: string;
39
40
  }
40
41
  /**
41
- * One read-only value, named, with the button that copies it.
42
+ * One read-only value, named, copied by clicking it.
42
43
  *
43
- * A derived notation — a SMILES, an InChIKey, an accession — is only useful
44
- * somewhere else, so a click on the value or on its button puts it on the
45
- * clipboard. An empty value reads as the missing marker and offers nothing to
46
- * copy.
44
+ * A derived notation — a SMILES, an InChIKey, an accession, a computed energy
45
+ * — is only useful somewhere else, so the value is the button that copies it:
46
+ * the cursor carries a clipboard over it, a click or `Enter` puts it on the
47
+ * clipboard, and a tick confirms. Nothing is drawn beside the label, which
48
+ * names the value and no more. An empty value reads as the missing marker and
49
+ * offers nothing to copy.
47
50
  * @param props - See {@link CopyableValueProps}.
48
- * @returns The labelled value and its copy button.
51
+ * @returns The labelled value.
49
52
  */
50
53
  export declare function CopyableValue(props: CopyableValueProps): ReactElement;
51
54
  //# sourceMappingURL=CopyableValue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CopyableValue.d.ts","sourceRoot":"","sources":["../../../src/clipboard/ui/CopyableValue.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAUpE,0DAA0D;AAC1D,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,CAmDrE"}
1
+ {"version":3,"file":"CopyableValue.d.ts","sourceRoot":"","sources":["../../../src/clipboard/ui/CopyableValue.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASpE,0DAA0D;AAC1D,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,CA0CrE"}
@@ -2,32 +2,28 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { MISSING_VALUE } from "../../format/core/missing.js";
3
3
  import { TOKEN } from "../../tokens/core/familyTokens.js";
4
4
  import { ClickToCopy } from "./ClickToCopy.js";
5
- import { CopyButton } from "./CopyButton.js";
6
5
  const DEFAULT_BLOCK_HEIGHT = 160;
7
6
  /**
8
- * One read-only value, named, with the button that copies it.
7
+ * One read-only value, named, copied by clicking it.
9
8
  *
10
- * A derived notation — a SMILES, an InChIKey, an accession — is only useful
11
- * somewhere else, so a click on the value or on its button puts it on the
12
- * clipboard. An empty value reads as the missing marker and offers nothing to
13
- * copy.
9
+ * A derived notation — a SMILES, an InChIKey, an accession, a computed energy
10
+ * — is only useful somewhere else, so the value is the button that copies it:
11
+ * the cursor carries a clipboard over it, a click or `Enter` puts it on the
12
+ * clipboard, and a tick confirms. Nothing is drawn beside the label, which
13
+ * names the value and no more. An empty value reads as the missing marker and
14
+ * offers nothing to copy.
14
15
  * @param props - See {@link CopyableValueProps}.
15
- * @returns The labelled value and its copy button.
16
+ * @returns The labelled value.
16
17
  */
17
18
  export function CopyableValue(props) {
18
- const { label, value, hint, block = false, maxHeight = DEFAULT_BLOCK_HEIGHT, copyTitle = `Copy the ${label}`, children, className, } = props;
19
+ const { label, value, hint, block = false, maxHeight = DEFAULT_BLOCK_HEIGHT, copyTitle, children, className, } = props;
19
20
  const isEmpty = value === '';
20
21
  return (_jsxs("div", { className: className === undefined
21
22
  ? 'copyable-value'
22
- : `copyable-value ${className}`, children: [_jsxs("div", { style: HEADER_STYLE, children: [_jsx("span", { className: "copyable-value__label", style: hint === undefined ? LABEL_STYLE : HINTED_LABEL_STYLE, title: hint, children: label }), _jsx(CopyButton, { content: value, title: copyTitle, disabled: isEmpty, minimal: true, small: true })] }), _jsx(ClickToCopy, { as: "code", value: value, label: label, focusable: false, disabled: isEmpty, className: "copyable-value__value", style: block ? { ...BLOCK_VALUE_STYLE, maxHeight } : VALUE_STYLE, children: isEmpty ? MISSING_VALUE : value }), children] }));
23
+ : `copyable-value ${className}`, children: [_jsx("span", { className: "copyable-value__label", style: hint === undefined ? LABEL_STYLE : HINTED_LABEL_STYLE, title: hint, children: label }), _jsx(ClickToCopy, { as: "code", value: value, label: label, title: copyTitle, disabled: isEmpty, className: "copyable-value__value", style: block ? { ...BLOCK_VALUE_STYLE, maxHeight } : VALUE_STYLE, children: isEmpty ? MISSING_VALUE : value }), children] }));
23
24
  }
24
- const HEADER_STYLE = {
25
- display: 'flex',
26
- alignItems: 'center',
27
- justifyContent: 'space-between',
28
- gap: 8,
29
- };
30
25
  const LABEL_STYLE = {
26
+ display: 'block',
31
27
  color: TOKEN.textMuted,
32
28
  fontSize: 12,
33
29
  fontWeight: 600,
@@ -1 +1 @@
1
- {"version":3,"file":"CopyableValue.js","sourceRoot":"","sources":["../../../src/clipboard/ui/CopyableValue.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAkB,CAAC;AAE9C,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAyCjC;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,MAAM,EACJ,KAAK,EACL,KAAK,EACL,IAAI,EACJ,KAAK,GAAG,KAAK,EACb,SAAS,GAAG,oBAAoB,EAChC,SAAS,GAAG,YAAY,KAAK,EAAE,EAC/B,QAAQ,EACR,SAAS,GACV,GAAG,KAAK,CAAC;IACV,MAAM,OAAO,GAAG,KAAK,KAAK,EAAE,CAAC;IAE7B,OAAO,CACL,e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AC,CAAC,WAAW,YAE/D,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,GACpB,EACb,QAAQ,IACL,CACP,CAAC;AACJ,CAAC;AAED,MAAM,WAAW,GAAG;IAClB,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,KAAK,CAAC,SAAS;IACtB,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE,GAAG;CACiB,CAAC;AAEnC,MAAM,kBAAkB,GAAG;IACzB,GAAG,WAAW;IACd,MAAM,EAAE,MAAM;CACkB,CAAC;AAEnC,MAAM,WAAW,GAAG;IAClB,OAAO,EAAE,OAAO;IAChB,UAAU,EAAE,gDAAgD;IAC5D,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,UAAU;CACQ,CAAC;AAEnC,MAAM,iBAAiB,GAAG;IACxB,GAAG,WAAW;IACd,UAAU,EAAE,KAAK;IACjB,YAAY,EAAE,QAAQ;IACtB,QAAQ,EAAE,MAAM;CACgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-cheminfo",
3
- "version": "0.27.0",
3
+ "version": "0.28.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",
@@ -4,7 +4,6 @@ import { MISSING_VALUE } from '../../format/core/missing.ts';
4
4
  import { TOKEN } from '../../tokens/core/familyTokens.ts';
5
5
 
6
6
  import { ClickToCopy } from './ClickToCopy.tsx';
7
- import { CopyButton } from './CopyButton.tsx';
8
7
 
9
8
  const DEFAULT_BLOCK_HEIGHT = 160;
10
9
 
@@ -12,7 +11,7 @@ const DEFAULT_BLOCK_HEIGHT = 160;
12
11
  export interface CopyableValueProps {
13
12
  /** What the value is, written above it, e.g. `InChIKey`. */
14
13
  label: string;
15
- /** The value itself, which is also what the button copies. */
14
+ /** The value itself, which is what a click on it copies. */
16
15
  value: string;
17
16
  /**
18
17
  * A longer explanation of the label, shown on hover.
@@ -31,8 +30,9 @@ export interface CopyableValueProps {
31
30
  */
32
31
  maxHeight?: number | string;
33
32
  /**
34
- * What the pointer and a screen reader are told the button does.
35
- * @default `Copy the ${label}`
33
+ * What the pointer and a screen reader are told, replacing the title built
34
+ * from the label and the value.
35
+ * @default undefined — `Copy the ${label} (${value})`
36
36
  */
37
37
  copyTitle?: string;
38
38
  /**
@@ -48,14 +48,16 @@ export interface CopyableValueProps {
48
48
  }
49
49
 
50
50
  /**
51
- * One read-only value, named, with the button that copies it.
51
+ * One read-only value, named, copied by clicking it.
52
52
  *
53
- * A derived notation — a SMILES, an InChIKey, an accession — is only useful
54
- * somewhere else, so a click on the value or on its button puts it on the
55
- * clipboard. An empty value reads as the missing marker and offers nothing to
56
- * copy.
53
+ * A derived notation — a SMILES, an InChIKey, an accession, a computed energy
54
+ * — is only useful somewhere else, so the value is the button that copies it:
55
+ * the cursor carries a clipboard over it, a click or `Enter` puts it on the
56
+ * clipboard, and a tick confirms. Nothing is drawn beside the label, which
57
+ * names the value and no more. An empty value reads as the missing marker and
58
+ * offers nothing to copy.
57
59
  * @param props - See {@link CopyableValueProps}.
58
- * @returns The labelled value and its copy button.
60
+ * @returns The labelled value.
59
61
  */
60
62
  export function CopyableValue(props: CopyableValueProps): ReactElement {
61
63
  const {
@@ -64,7 +66,7 @@ export function CopyableValue(props: CopyableValueProps): ReactElement {
64
66
  hint,
65
67
  block = false,
66
68
  maxHeight = DEFAULT_BLOCK_HEIGHT,
67
- copyTitle = `Copy the ${label}`,
69
+ copyTitle,
68
70
  children,
69
71
  className,
70
72
  } = props;
@@ -78,27 +80,18 @@ export function CopyableValue(props: CopyableValueProps): ReactElement {
78
80
  : `copyable-value ${className}`
79
81
  }
80
82
  >
81
- <div style={HEADER_STYLE}>
82
- <span
83
- className="copyable-value__label"
84
- style={hint === undefined ? LABEL_STYLE : HINTED_LABEL_STYLE}
85
- title={hint}
86
- >
87
- {label}
88
- </span>
89
- <CopyButton
90
- content={value}
91
- title={copyTitle}
92
- disabled={isEmpty}
93
- minimal
94
- small
95
- />
96
- </div>
83
+ <span
84
+ className="copyable-value__label"
85
+ style={hint === undefined ? LABEL_STYLE : HINTED_LABEL_STYLE}
86
+ title={hint}
87
+ >
88
+ {label}
89
+ </span>
97
90
  <ClickToCopy
98
91
  as="code"
99
92
  value={value}
100
93
  label={label}
101
- focusable={false}
94
+ title={copyTitle}
102
95
  disabled={isEmpty}
103
96
  className="copyable-value__value"
104
97
  style={block ? { ...BLOCK_VALUE_STYLE, maxHeight } : VALUE_STYLE}
@@ -110,14 +103,8 @@ export function CopyableValue(props: CopyableValueProps): ReactElement {
110
103
  );
111
104
  }
112
105
 
113
- const HEADER_STYLE = {
114
- display: 'flex',
115
- alignItems: 'center',
116
- justifyContent: 'space-between',
117
- gap: 8,
118
- } as const satisfies CSSProperties;
119
-
120
106
  const LABEL_STYLE = {
107
+ display: 'block',
121
108
  color: TOKEN.textMuted,
122
109
  fontSize: 12,
123
110
  fontWeight: 600,