@canopy-iiif/app 1.6.5 → 1.6.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canopy-iiif/app",
3
- "version": "1.6.5",
3
+ "version": "1.6.7",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "Mat Jordan <mat@northwestern.edu>",
@@ -1326,7 +1326,7 @@ function ContentNavigation({
1326
1326
  "svg",
1327
1327
  {
1328
1328
  xmlns: "http://www.w3.org/2000/svg",
1329
- class: "ionicon",
1329
+ className: "ionicon",
1330
1330
  viewBox: "0 0 512 512"
1331
1331
  },
1332
1332
  /* @__PURE__ */ React12.createElement(
@@ -1334,9 +1334,9 @@ function ContentNavigation({
1334
1334
  {
1335
1335
  fill: "none",
1336
1336
  stroke: "currentColor",
1337
- "stroke-linecap": "round",
1338
- "stroke-linejoin": "round",
1339
- "stroke-width": "50",
1337
+ strokeLinecap: "round",
1338
+ strokeLinejoin: "round",
1339
+ strokeWidth: "50",
1340
1340
  d: "M160 144h288M160 256h288M160 368h288"
1341
1341
  }
1342
1342
  ),
@@ -1348,9 +1348,9 @@ function ContentNavigation({
1348
1348
  r: "16",
1349
1349
  fill: "none",
1350
1350
  stroke: "currentColor",
1351
- "stroke-linecap": "round",
1352
- "stroke-linejoin": "round",
1353
- "stroke-width": "32"
1351
+ strokeLinecap: "round",
1352
+ strokeLinejoin: "round",
1353
+ strokeWidth: "32"
1354
1354
  }
1355
1355
  ),
1356
1356
  /* @__PURE__ */ React12.createElement(
@@ -1361,9 +1361,9 @@ function ContentNavigation({
1361
1361
  r: "16",
1362
1362
  fill: "none",
1363
1363
  stroke: "currentColor",
1364
- "stroke-linecap": "round",
1365
- "stroke-linejoin": "round",
1366
- "stroke-width": "32"
1364
+ strokeLinecap: "round",
1365
+ strokeLinejoin: "round",
1366
+ strokeWidth: "32"
1367
1367
  }
1368
1368
  ),
1369
1369
  /* @__PURE__ */ React12.createElement(
@@ -1374,9 +1374,9 @@ function ContentNavigation({
1374
1374
  r: "16",
1375
1375
  fill: "none",
1376
1376
  stroke: "currentColor",
1377
- "stroke-linecap": "round",
1378
- "stroke-linejoin": "round",
1379
- "stroke-width": "32"
1377
+ strokeLinecap: "round",
1378
+ strokeLinejoin: "round",
1379
+ strokeWidth: "32"
1380
1380
  }
1381
1381
  )
1382
1382
  )
@@ -4619,8 +4619,9 @@ function DocsCodeBlock(props = {}) {
4619
4619
  const copyAttr = codeProps["data-copy"];
4620
4620
  const enableCopy = copyAttr !== void 0 ? copyAttr === true || copyAttr === "true" || copyAttr === "" : false;
4621
4621
  const [copied, setCopied] = React41.useState(false);
4622
+ const buttonRef = React41.useRef(null);
4622
4623
  const handleCopy = React41.useCallback(async () => {
4623
- const text = rawCode;
4624
+ const text = trimmedCode;
4624
4625
  try {
4625
4626
  if (typeof navigator !== "undefined" && navigator.clipboard && navigator.clipboard.writeText) {
4626
4627
  await navigator.clipboard.writeText(text);
@@ -4636,11 +4637,21 @@ function DocsCodeBlock(props = {}) {
4636
4637
  document.body.removeChild(textarea);
4637
4638
  }
4638
4639
  setCopied(true);
4639
- setTimeout(() => setCopied(false), 1500);
4640
+ setTimeout(() => setCopied(false), 5e3);
4640
4641
  } catch (_) {
4641
4642
  setCopied(false);
4642
4643
  }
4643
- }, [rawCode]);
4644
+ }, [trimmedCode]);
4645
+ React41.useEffect(() => {
4646
+ if (buttonRef.current) {
4647
+ buttonRef.current.setAttribute("data-docs-copy-hydrated", "true");
4648
+ }
4649
+ }, []);
4650
+ React41.useEffect(() => {
4651
+ if (!buttonRef.current) return;
4652
+ if (copied) buttonRef.current.setAttribute("data-docs-copy-active", "true");
4653
+ else buttonRef.current.removeAttribute("data-docs-copy-active");
4654
+ }, [copied]);
4644
4655
  const containerStyle = {
4645
4656
  borderRadius: "12px",
4646
4657
  overflow: "hidden",
@@ -4667,6 +4678,21 @@ function DocsCodeBlock(props = {}) {
4667
4678
  padding: "1rem 0",
4668
4679
  overflowX: "auto"
4669
4680
  };
4681
+ const buttonStyle = {
4682
+ border: "1px solid var(--color-accent-200, )",
4683
+ borderRadius: "6px",
4684
+ padding: "0.25rem 0.65rem",
4685
+ fontSize: "0.7rem",
4686
+ fontWeight: 600,
4687
+ color: "var(--color-accent-default)",
4688
+ cursor: "pointer",
4689
+ display: "inline-flex",
4690
+ alignItems: "center",
4691
+ gap: "0.3rem",
4692
+ background: "var(--docs-copy-bg, rgba(255,255,255,0.08))",
4693
+ transform: "var(--docs-copy-transform, scale(1))",
4694
+ transition: "transform 150ms ease, background-color 150ms ease, color 150ms ease"
4695
+ };
4670
4696
  const codeStyle = {
4671
4697
  display: "block",
4672
4698
  padding: 0
@@ -4686,13 +4712,20 @@ function DocsCodeBlock(props = {}) {
4686
4712
  const displayLine = line === "" ? " " : line;
4687
4713
  return React41.createElement(
4688
4714
  "span",
4689
- { key: lineNumber, style },
4715
+ {
4716
+ key: lineNumber,
4717
+ style,
4718
+ "data-docs-code-line": line
4719
+ },
4690
4720
  React41.createElement("span", { style: lineContentStyle }, displayLine)
4691
4721
  );
4692
4722
  });
4693
4723
  return React41.createElement(
4694
4724
  "div",
4695
- { style: containerStyle },
4725
+ {
4726
+ style: containerStyle,
4727
+ "data-docs-code-block": "true"
4728
+ },
4696
4729
  showHeader ? React41.createElement(
4697
4730
  "div",
4698
4731
  { style: headerStyle },
@@ -4700,23 +4733,40 @@ function DocsCodeBlock(props = {}) {
4700
4733
  enableCopy ? React41.createElement(
4701
4734
  "button",
4702
4735
  {
4736
+ ref: buttonRef,
4703
4737
  type: "button",
4704
4738
  onClick: handleCopy,
4705
4739
  "aria-live": "polite",
4706
4740
  "aria-label": copied ? "Copied to clipboard" : "Copy code to clipboard",
4707
- style: {
4708
- border: "1px solid var(--color-accent-200, )",
4709
- borderRadius: "6px",
4710
- padding: "0.2rem 0.55rem",
4711
- fontSize: "0.7rem",
4712
- fontWeight: 500,
4713
- color: "var(--color-accent-default)",
4714
- cursor: "pointer"
4715
- }
4741
+ "data-docs-copy-button": "true",
4742
+ style: buttonStyle
4716
4743
  },
4717
- copied ? "Copied" : "Copy"
4744
+ React41.createElement("span", null, "Copy"),
4745
+ React41.createElement(
4746
+ "span",
4747
+ {
4748
+ "aria-hidden": "true",
4749
+ "data-docs-copy-icon": "true"
4750
+ },
4751
+ "\u2713"
4752
+ )
4718
4753
  ) : null
4719
4754
  ) : null,
4755
+ enableCopy ? React41.createElement("textarea", {
4756
+ "data-docs-copy-source": "true",
4757
+ tabIndex: -1,
4758
+ readOnly: true,
4759
+ "aria-hidden": "true",
4760
+ defaultValue: trimmedCode,
4761
+ style: {
4762
+ position: "absolute",
4763
+ left: "-9999px",
4764
+ width: 1,
4765
+ height: 1,
4766
+ opacity: 0,
4767
+ pointerEvents: "none"
4768
+ }
4769
+ }) : null,
4720
4770
  React41.createElement(
4721
4771
  "pre",
4722
4772
  { ...preRest, className: preClassName, style: mergedPreStyle },