@kubohiroya/turbowarp-plus-editor-git 0.16.0 → 0.16.1

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.
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ /** A button drawn as an X, named by `label` for screen readers and in its tooltip. */
3
+ export declare function CloseButton({ label, onClick }: {
4
+ label: string;
5
+ onClick(): void;
6
+ }): React.JSX.Element;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as parseProjectSource, a as openProjectSourceTabs, b as useCostumeImage, c as gitHubRepositoryFromOrigin, f as organizeProjectChanges, i as createScratchBlocksDiffLocator, l as ProjectSourceComparison, n as openProjectComparison, o as PullRequestError, p as projectPropertyLabel, r as createScratchBlocksDiffRenderer, s as createGitHubPullRequests, u as ProjectSourceReview, w as readProjectSourceDiff, y as useAssetImage } from "./project-comparison-MU0qD2wo.js";
1
+ import { C as parseProjectSource, T as CloseButton, a as openProjectSourceTabs, b as useCostumeImage, c as gitHubRepositoryFromOrigin, f as organizeProjectChanges, i as createScratchBlocksDiffLocator, l as ProjectSourceComparison, n as openProjectComparison, o as PullRequestError, p as projectPropertyLabel, r as createScratchBlocksDiffRenderer, s as createGitHubPullRequests, u as ProjectSourceReview, w as readProjectSourceDiff, y as useAssetImage } from "./project-comparison-1rggIJse.js";
2
2
  import { n as init_objectSpread2, r as __commonJSMin, t as _objectSpread2$1 } from "./objectSpread2-Dkd68nJH.js";
3
3
  import { a as createReadOnlyFs, i as GitPanelError, n as openRepository } from "./repository-BYno-5f8.js";
4
4
  import * as m from "react";
@@ -4569,7 +4569,10 @@ function GitPanel({ vm, document, host, controller }) {
4569
4569
  type: "button",
4570
4570
  disabled: state.busy,
4571
4571
  onClick: () => setReview(!review)
4572
- }, review ? labels.localChanges : labels.pullRequests), /* @__PURE__ */ React.createElement("button", { onClick: closePanel }, labels.close)), /* @__PURE__ */ React.createElement("div", { className: "twgit-context" }, /* @__PURE__ */ React.createElement("span", null, labels.repository, " · ", ((_state$repository = state.repository) === null || _state$repository === void 0 ? void 0 : _state$repository.root.name) || "—"), /* @__PURE__ */ React.createElement("span", null, labels.project, " · ", state.project === null ? labels.none : state.project || labels.root), /* @__PURE__ */ React.createElement("span", { "data-git-dirty": "" }, dirty ? labels.dirty : labels.saved), state.snapshot && /* @__PURE__ */ React.createElement("span", {
4572
+ }, review ? labels.localChanges : labels.pullRequests), /* @__PURE__ */ React.createElement(CloseButton, {
4573
+ label: labels.close,
4574
+ onClick: closePanel
4575
+ })), /* @__PURE__ */ React.createElement("div", { className: "twgit-context" }, /* @__PURE__ */ React.createElement("span", null, labels.repository, " · ", ((_state$repository = state.repository) === null || _state$repository === void 0 ? void 0 : _state$repository.root.name) || "—"), /* @__PURE__ */ React.createElement("span", null, labels.project, " · ", state.project === null ? labels.none : state.project || labels.root), /* @__PURE__ */ React.createElement("span", { "data-git-dirty": "" }, dirty ? labels.dirty : labels.saved), state.snapshot && /* @__PURE__ */ React.createElement("span", {
4573
4576
  "data-git-upstream": state.snapshot.upstream.state,
4574
4577
  title: labels.checkedAt
4575
4578
  }, upstreamText(state.snapshot, labels)), !review && host.connectionSettings && /* @__PURE__ */ React.createElement(ConnectionSettings, {
@@ -2,6 +2,29 @@ import { n as init_objectSpread2, t as _objectSpread2 } from "./objectSpread2-Dk
2
2
  import { a as createTwoFilesPatch, i as isAssetName, n as assetsDirectoryParts, o as hasOnlyUnixLineEndings, r as folderSettingsLimit, s as hasOnlyWinLineEndings, t as assetLimit } from "./project-asset-paths-KV715791.js";
3
3
  import React, { useEffect, useMemo, useRef, useState } from "react";
4
4
  import { render, unmountComponentAtNode } from "react-dom";
5
+ // src/close-button.tsx
6
+ /** A button drawn as an X, named by `label` for screen readers and in its tooltip. */
7
+ function CloseButton({ label, onClick }) {
8
+ return /* @__PURE__ */ React.createElement("button", {
9
+ type: "button",
10
+ className: "twgit-close",
11
+ "aria-label": label,
12
+ title: label,
13
+ onClick
14
+ }, /* @__PURE__ */ React.createElement("svg", {
15
+ viewBox: "0 0 16 16",
16
+ width: "18",
17
+ height: "18",
18
+ "aria-hidden": "true",
19
+ focusable: "false"
20
+ }, /* @__PURE__ */ React.createElement("path", {
21
+ d: "M4 4l8 8M12 4l-8 8",
22
+ stroke: "currentColor",
23
+ strokeWidth: "1.6",
24
+ strokeLinecap: "round",
25
+ fill: "none"
26
+ })));
27
+ }
5
28
  // node_modules/diff/libesm/patch/line-endings.js
6
29
  function unixToWin(patch) {
7
30
  if (Array.isArray(patch)) return patch.map((p) => unixToWin(p));
@@ -2670,7 +2693,7 @@ function createScratchBlocksDiffRenderer(options) {
2670
2693
  init_objectSpread2();
2671
2694
  var focusable = "button:not(:disabled), input:not(:disabled), select:not(:disabled), a[href], summary, [tabindex=\"0\"]";
2672
2695
  /** A modal that lays project comparisons side by side in sections and asks the user to choose an action. */
2673
- function ProjectComparisonDialog({ title, description, notes = [], sections, actions, closeLabel = "Close", renderBlock, locale = "en", onChoose }) {
2696
+ function ProjectComparisonDialog({ title, description, notes = [], sections, actions, closeLabel, renderBlock, locale = "en", onChoose }) {
2674
2697
  const dialog = useRef(null);
2675
2698
  const first = useRef(null);
2676
2699
  useEffect(() => {
@@ -2707,10 +2730,10 @@ function ProjectComparisonDialog({ title, description, notes = [], sections, act
2707
2730
  "aria-modal": "true",
2708
2731
  "aria-label": title,
2709
2732
  onKeyDown: keyDown
2710
- }, /* @__PURE__ */ React.createElement("header", null, /* @__PURE__ */ React.createElement("h2", null, title), /* @__PURE__ */ React.createElement("button", {
2711
- type: "button",
2733
+ }, /* @__PURE__ */ React.createElement("header", null, /* @__PURE__ */ React.createElement("h2", null, title), /* @__PURE__ */ React.createElement(CloseButton, {
2734
+ label: closeLabel !== null && closeLabel !== void 0 ? closeLabel : locale.startsWith("ja") ? "閉じる" : "Close",
2712
2735
  onClick: () => onChoose(null)
2713
- }, closeLabel)), /* @__PURE__ */ React.createElement("div", { className: "twgit-comparison-body" }, description && /* @__PURE__ */ React.createElement("p", null, description), notes.map((note) => /* @__PURE__ */ React.createElement("p", {
2736
+ })), /* @__PURE__ */ React.createElement("div", { className: "twgit-comparison-body" }, description && /* @__PURE__ */ React.createElement("p", null, description), notes.map((note) => /* @__PURE__ */ React.createElement("p", {
2714
2737
  key: note,
2715
2738
  role: "note"
2716
2739
  }, note)), sections.map((section) => /* @__PURE__ */ React.createElement("section", {
@@ -2743,4 +2766,4 @@ function openProjectComparison(document, options) {
2743
2766
  render(/* @__PURE__ */ React.createElement(ProjectComparisonDialog, _objectSpread2(_objectSpread2({}, options), {}, { onChoose: choose })), root);
2744
2767
  });
2745
2768
  }
2746
- export { parseProjectSource as C, createProjectSourceDiff as S, usePreviewSync as _, openProjectSourceTabs as a, useCostumeImage as b, gitHubRepositoryFromOrigin as c, assetFileName as d, organizeProjectChanges as f, createPreviewSync as g, BlockPreview as h, createScratchBlocksDiffLocator as i, ProjectSourceComparison as l, compareProjectForReview as m, openProjectComparison as n, PullRequestError as o, projectPropertyLabel as p, createScratchBlocksDiffRenderer as r, createGitHubPullRequests as s, ProjectComparisonDialog as t, ProjectSourceReview as u, currentCostume as v, readProjectSourceDiff as w, compareProjectBlocks as x, useAssetImage as y };
2769
+ export { parseProjectSource as C, createProjectSourceDiff as S, CloseButton as T, usePreviewSync as _, openProjectSourceTabs as a, useCostumeImage as b, gitHubRepositoryFromOrigin as c, assetFileName as d, organizeProjectChanges as f, createPreviewSync as g, BlockPreview as h, createScratchBlocksDiffLocator as i, ProjectSourceComparison as l, compareProjectForReview as m, openProjectComparison as n, PullRequestError as o, projectPropertyLabel as p, createScratchBlocksDiffRenderer as r, createGitHubPullRequests as s, ProjectComparisonDialog as t, ProjectSourceReview as u, currentCostume as v, readProjectSourceDiff as w, compareProjectBlocks as x, useAssetImage as y };
@@ -18,6 +18,7 @@ export interface ProjectComparisonOptions {
18
18
  sections: readonly ProjectComparisonSection[];
19
19
  /** The first action is the one the dialog focuses. Closing the dialog or pressing Escape chooses none. */
20
20
  actions: readonly ProjectComparisonAction[];
21
+ /** The tooltip and accessible name of the X button that closes the dialog. By default, "Close" in the locale. */
21
22
  closeLabel?: string;
22
23
  renderBlock: ProjectBlockRenderer;
23
24
  locale?: string;
@@ -1,4 +1,4 @@
1
- import { S as createProjectSourceDiff, _ as usePreviewSync, a as openProjectSourceTabs, c as gitHubRepositoryFromOrigin, d as assetFileName, f as organizeProjectChanges, g as createPreviewSync, h as BlockPreview, i as createScratchBlocksDiffLocator, l as ProjectSourceComparison, m as compareProjectForReview, n as openProjectComparison, p as projectPropertyLabel, r as createScratchBlocksDiffRenderer, s as createGitHubPullRequests, t as ProjectComparisonDialog, u as ProjectSourceReview, v as currentCostume, w as readProjectSourceDiff, x as compareProjectBlocks } from "./project-comparison-MU0qD2wo.js";
1
+ import { S as createProjectSourceDiff, _ as usePreviewSync, a as openProjectSourceTabs, c as gitHubRepositoryFromOrigin, d as assetFileName, f as organizeProjectChanges, g as createPreviewSync, h as BlockPreview, i as createScratchBlocksDiffLocator, l as ProjectSourceComparison, m as compareProjectForReview, n as openProjectComparison, p as projectPropertyLabel, r as createScratchBlocksDiffRenderer, s as createGitHubPullRequests, t as ProjectComparisonDialog, u as ProjectSourceReview, v as currentCostume, w as readProjectSourceDiff, x as compareProjectBlocks } from "./project-comparison-1rggIJse.js";
2
2
  import { n as init_objectSpread2, t as _objectSpread2 } from "./objectSpread2-Dkd68nJH.js";
3
3
  import React, { useEffect, useMemo, useRef, useState } from "react";
4
4
  // src/project-source-diff.tsx
package/dist/style.css CHANGED
@@ -124,6 +124,10 @@
124
124
  .twgit-panel { width: 94vw; height: 90vh; display: flex; flex-direction: column; background: Canvas; color: CanvasText; border: 1px solid GrayText; border-radius: 8px; box-shadow: 0 12px 48px #0005; font: 14px/1.5 system-ui, sans-serif; overflow: hidden; }
125
125
  .twgit-panel > header { display: flex; gap: 8px; align-items: center; padding: 10px 16px; border-bottom: 1px solid GrayText; }
126
126
  .twgit-panel > header h2 { margin: 0 auto 0 0; font-size: 18px; }
127
+ .twgit-panel .twgit-close, .twgit-close { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0;
128
+ border: 1px solid transparent; border-radius: 4px; background: transparent; color: inherit; cursor: pointer; }
129
+ .twgit-panel .twgit-close:hover, .twgit-close:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
130
+ .twgit-panel .twgit-close:focus-visible, .twgit-close:focus-visible { outline: 2px solid Highlight; outline-offset: 1px; }
127
131
  .twgit-panel h3 { font-size: 14px; margin: 12px 0 5px; }
128
132
  .twgit-panel button { color: inherit; background: Canvas; border: 1px solid GrayText; border-radius: 4px; padding: 4px 8px; cursor: pointer; font: inherit; text-align: start; }
129
133
  .twgit-panel button:disabled { opacity: .5; cursor: default; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-plus-editor-git",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "Read-only local Git panel for TurboWarp Plus Editor",
5
5
  "type": "module",
6
6
  "license": "MPL-2.0",
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+
3
+ /** A button drawn as an X, named by `label` for screen readers and in its tooltip. */
4
+ export function CloseButton({label, onClick}: {label: string; onClick(): void}) {
5
+ return <button type="button" className="twgit-close" aria-label={label} title={label} onClick={onClick}>
6
+ <svg viewBox="0 0 16 16" width="18" height="18" aria-hidden="true" focusable="false">
7
+ <path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" fill="none"/>
8
+ </svg>
9
+ </button>;
10
+ }
package/src/index.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import React, {useEffect, useMemo, useRef, useState} from 'react';
2
2
  import {createPortal, render, unmountComponentAtNode} from 'react-dom';
3
+ import {CloseButton} from './close-button.js';
3
4
  import {FileDiffView} from './file-diff-view.js';
4
5
  import {findElement, ProjectChangeListView, ProjectElementView, projectChangeLabels, useProjectChanges} from './project-change-list.js';
5
6
  import type {ChangedFile} from './project-change-model.js';
@@ -485,7 +486,7 @@ function GitPanel({vm, document, host, controller}: {vm: object; document: Docum
485
486
  {!review && state.project !== null && <button disabled={state.busy} onClick={() => void openProject(state.project!)}>{labels.reload}</button>}
486
487
  {state.repository && host.renderReviewBlock && <button type="button" disabled={state.busy}
487
488
  onClick={() => setReview(!review)}>{review ? labels.localChanges : labels.pullRequests}</button>}
488
- <button onClick={closePanel}>{labels.close}</button>
489
+ <CloseButton label={labels.close} onClick={closePanel}/>
489
490
  </header>
490
491
  <div className="twgit-context">
491
492
  <span>{labels.repository} · {state.repository?.root.name || '—'}</span>
@@ -1,4 +1,5 @@
1
1
  import React, {useEffect, useRef} from 'react';
2
+ import {CloseButton} from './close-button.js';
2
3
  import {render, unmountComponentAtNode} from 'react-dom';
3
4
  import {ProjectSourceComparison} from './project-source-review.js';
4
5
  import type {ProjectBlockRenderer} from './scratch-block-diff-renderer.js';
@@ -21,6 +22,7 @@ export interface ProjectComparisonOptions {
21
22
  sections: readonly ProjectComparisonSection[];
22
23
  /** The first action is the one the dialog focuses. Closing the dialog or pressing Escape chooses none. */
23
24
  actions: readonly ProjectComparisonAction[];
25
+ /** The tooltip and accessible name of the X button that closes the dialog. By default, "Close" in the locale. */
24
26
  closeLabel?: string;
25
27
  renderBlock: ProjectBlockRenderer;
26
28
  locale?: string;
@@ -32,7 +34,7 @@ export interface ProjectComparisonDialogProps extends ProjectComparisonOptions {
32
34
  const focusable = 'button:not(:disabled), input:not(:disabled), select:not(:disabled), a[href], summary, [tabindex="0"]';
33
35
 
34
36
  /** A modal that lays project comparisons side by side in sections and asks the user to choose an action. */
35
- export function ProjectComparisonDialog({title, description, notes = [], sections, actions, closeLabel = 'Close',
37
+ export function ProjectComparisonDialog({title, description, notes = [], sections, actions, closeLabel,
36
38
  renderBlock, locale = 'en', onChoose}: ProjectComparisonDialogProps) {
37
39
  const dialog = useRef<HTMLDivElement>(null);
38
40
  const first = useRef<HTMLButtonElement>(null);
@@ -55,7 +57,7 @@ export function ProjectComparisonDialog({title, description, notes = [], section
55
57
  aria-label={title} onKeyDown={keyDown}>
56
58
  <header>
57
59
  <h2>{title}</h2>
58
- <button type="button" onClick={() => onChoose(null)}>{closeLabel}</button>
60
+ <CloseButton label={closeLabel ?? (locale.startsWith('ja') ? '閉じる' : 'Close')} onClick={() => onChoose(null)}/>
59
61
  </header>
60
62
  <div className="twgit-comparison-body">
61
63
  {description && <p>{description}</p>}
package/src/style.css CHANGED
@@ -2,6 +2,10 @@
2
2
  .twgit-panel { width: 94vw; height: 90vh; display: flex; flex-direction: column; background: Canvas; color: CanvasText; border: 1px solid GrayText; border-radius: 8px; box-shadow: 0 12px 48px #0005; font: 14px/1.5 system-ui, sans-serif; overflow: hidden; }
3
3
  .twgit-panel > header { display: flex; gap: 8px; align-items: center; padding: 10px 16px; border-bottom: 1px solid GrayText; }
4
4
  .twgit-panel > header h2 { margin: 0 auto 0 0; font-size: 18px; }
5
+ .twgit-panel .twgit-close, .twgit-close { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0;
6
+ border: 1px solid transparent; border-radius: 4px; background: transparent; color: inherit; cursor: pointer; }
7
+ .twgit-panel .twgit-close:hover, .twgit-close:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
8
+ .twgit-panel .twgit-close:focus-visible, .twgit-close:focus-visible { outline: 2px solid Highlight; outline-offset: 1px; }
5
9
  .twgit-panel h3 { font-size: 14px; margin: 12px 0 5px; }
6
10
  .twgit-panel button { color: inherit; background: Canvas; border: 1px solid GrayText; border-radius: 4px; padding: 4px 8px; cursor: pointer; font: inherit; text-align: start; }
7
11
  .twgit-panel button:disabled { opacity: .5; cursor: default; }