moxule-components 0.1.0 → 0.1.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.
package/README.md CHANGED
@@ -1162,3 +1162,7 @@ Calendar highlights Saturday and Sunday with a subtle muted fill by default. Use
1162
1162
  `Drawing` provides a responsive canvas with an icon-only pencil/eraser, size slider, and color/background pickers in its bottom toolbar. It supports pointer and keyboard drawing. Use controlled `value`/`onChange` or `defaultValue` to keep the editable document. A `DrawingHandle` ref exposes `await ref.current.toBlob()` to export a PNG bitmap; the consumer owns saving/uploading. Default bitmap dimensions are 960×600; `width`, `height`, and `disabled` are supported. The Writing Components demo includes a working PNG export.
1163
1163
 
1164
1164
  MarkdownEditor supports optional `textAlign="left" | "center"` and `onTextAlignChange` for whole-document presentation controls. Alignment is reported separately and never inserts HTML or rewrites Markdown.
1165
+
1166
+ On small screens Drawing wraps its tools, size slider and color controls into
1167
+ separate rows. The Scroll canvas hand tool allows vertical touch scrolling over
1168
+ the canvas without adding strokes; choose Pencil or Erase to resume drawing.
package/dist/index.cjs CHANGED
@@ -1648,6 +1648,7 @@ var Drawing = (0, import_react10.forwardRef)(function Drawing2({ value, defaultV
1648
1648
  setFuture([]);
1649
1649
  }
1650
1650
  function begin(point) {
1651
+ if (tool === "pan") return;
1651
1652
  checkpoint();
1652
1653
  change({ ...draft.current, strokes: [...draft.current.strokes, { tool, color, size, points: [point] }] });
1653
1654
  }
@@ -1672,15 +1673,16 @@ var Drawing = (0, import_react10.forwardRef)(function Drawing2({ value, defaultV
1672
1673
  width: w,
1673
1674
  height: h,
1674
1675
  className: "mx-drawing-canvas",
1676
+ "data-panning": tool === "pan" || void 0,
1675
1677
  role: "img",
1676
1678
  "aria-label": "Drawing canvas",
1677
1679
  "aria-describedby": help,
1678
1680
  "aria-disabled": blocked || void 0,
1679
1681
  tabIndex: blocked ? -1 : 0,
1680
1682
  onPointerDown: (event) => {
1681
- if (blocked || event.button !== 0 || active.current !== null) return;
1683
+ if (blocked || tool === "pan" || event.button !== 0 || active.current !== null) return;
1682
1684
  event.preventDefault();
1683
- event.currentTarget.focus();
1685
+ event.currentTarget.focus({ preventScroll: true });
1684
1686
  event.currentTarget.setPointerCapture(event.pointerId);
1685
1687
  active.current = event.pointerId;
1686
1688
  cursor.current = position(event);
@@ -1709,7 +1711,7 @@ var Drawing = (0, import_react10.forwardRef)(function Drawing2({ value, defaultV
1709
1711
  active.current = null;
1710
1712
  },
1711
1713
  onKeyDown: (event) => {
1712
- if (blocked) return;
1714
+ if (blocked || tool === "pan") return;
1713
1715
  const delta = event.shiftKey ? 20 : 4;
1714
1716
  const directions = { ArrowLeft: [-delta, 0], ArrowRight: [delta, 0], ArrowUp: [0, -delta], ArrowDown: [0, delta] };
1715
1717
  if (event.key === " ") {
@@ -1738,6 +1740,7 @@ var Drawing = (0, import_react10.forwardRef)(function Drawing2({ value, defaultV
1738
1740
  image && !imageReady && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "mx-drawing-image-status", role: raster?.source === image && raster.failed ? "alert" : "status", children: raster?.source === image && raster.failed ? "Original drawing couldn\u2019t load. Reopen the note to retry." : "Loading drawing\u2026" }),
1739
1741
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "mx-drawing-toolbar", role: "group", "aria-label": "Drawing tools", children: [
1740
1742
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "mx-drawing-tools", children: [
1743
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Button, { size: "sm", variant: tool === "pan" ? "secondary" : "ghost", "aria-label": "Scroll canvas", title: "Scroll without drawing", "aria-pressed": tool === "pan", disabled: blocked, onClick: () => setTool("pan"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("svg", { viewBox: "0 0 24 24", width: "18", height: "18", fill: "none", stroke: "currentColor", strokeWidth: "1.6", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "M8 13V6a2 2 0 0 1 4 0v6-8a2 2 0 0 1 4 0v8-5a2 2 0 0 1 4 0v9c0 4-3 6-7 6-3 0-5-2-6-4l-3-5a2 2 0 0 1 3-2l3 3" }) }) }),
1741
1744
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Button, { size: "sm", variant: "ghost", "aria-label": "Undo drawing", title: "Undo", disabled: blocked || !past.length, onClick: () => {
1742
1745
  const previous = past[past.length - 1];
1743
1746
  if (!previous) return;
package/dist/index.css CHANGED
@@ -3385,6 +3385,58 @@
3385
3385
  .mx-calendar-day-preview {
3386
3386
  border-radius: var(--mx-control-radius,12px);
3387
3387
  }
3388
+ .mx-drawing {
3389
+ width: 100%;
3390
+ max-width: 100%;
3391
+ }
3392
+ .mx-drawing-canvas[data-panning=true] {
3393
+ touch-action: pan-y;
3394
+ cursor: grab;
3395
+ }
3396
+ @media (max-width: 650px) {
3397
+ .mx-drawing-toolbar {
3398
+ display: grid;
3399
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
3400
+ gap: 12px;
3401
+ overflow: visible;
3402
+ padding: 12px;
3403
+ }
3404
+ .mx-drawing-tools {
3405
+ grid-column: 1 / -1;
3406
+ display: grid;
3407
+ grid-template-columns: repeat(6, minmax(0, 1fr));
3408
+ gap: 4px;
3409
+ }
3410
+ .mx-drawing-tools .mx-button {
3411
+ width: 100%;
3412
+ min-width: 0;
3413
+ min-height: 44px;
3414
+ padding: 8px;
3415
+ }
3416
+ .mx-drawing-toolbar > .mx-text-input-field {
3417
+ grid-column: 1 / -1;
3418
+ width: 100%;
3419
+ min-width: 0;
3420
+ }
3421
+ .mx-drawing-toolbar .mx-drawing-color {
3422
+ min-width: 0;
3423
+ justify-content: space-between;
3424
+ gap: 4px;
3425
+ white-space: normal;
3426
+ }
3427
+ .mx-drawing-toolbar .mx-color-picker-swatch {
3428
+ width: 44px;
3429
+ height: 44px;
3430
+ flex-shrink: 0;
3431
+ }
3432
+ }
3433
+ @media (max-width: 380px) {
3434
+ .mx-drawing-toolbar .mx-drawing-color {
3435
+ flex-direction: column;
3436
+ align-items: flex-start;
3437
+ gap: 8px;
3438
+ }
3439
+ }
3388
3440
 
3389
3441
  /* src/theme/themes.css */
3390
3442
  .mx-theme[data-mx-theme=primary][data-mx-mode=light] {
package/dist/index.js CHANGED
@@ -1556,6 +1556,7 @@ var Drawing = forwardRef5(function Drawing2({ value, defaultValue, width = 960,
1556
1556
  setFuture([]);
1557
1557
  }
1558
1558
  function begin(point) {
1559
+ if (tool === "pan") return;
1559
1560
  checkpoint();
1560
1561
  change({ ...draft.current, strokes: [...draft.current.strokes, { tool, color, size, points: [point] }] });
1561
1562
  }
@@ -1580,15 +1581,16 @@ var Drawing = forwardRef5(function Drawing2({ value, defaultValue, width = 960,
1580
1581
  width: w,
1581
1582
  height: h,
1582
1583
  className: "mx-drawing-canvas",
1584
+ "data-panning": tool === "pan" || void 0,
1583
1585
  role: "img",
1584
1586
  "aria-label": "Drawing canvas",
1585
1587
  "aria-describedby": help,
1586
1588
  "aria-disabled": blocked || void 0,
1587
1589
  tabIndex: blocked ? -1 : 0,
1588
1590
  onPointerDown: (event) => {
1589
- if (blocked || event.button !== 0 || active.current !== null) return;
1591
+ if (blocked || tool === "pan" || event.button !== 0 || active.current !== null) return;
1590
1592
  event.preventDefault();
1591
- event.currentTarget.focus();
1593
+ event.currentTarget.focus({ preventScroll: true });
1592
1594
  event.currentTarget.setPointerCapture(event.pointerId);
1593
1595
  active.current = event.pointerId;
1594
1596
  cursor.current = position(event);
@@ -1617,7 +1619,7 @@ var Drawing = forwardRef5(function Drawing2({ value, defaultValue, width = 960,
1617
1619
  active.current = null;
1618
1620
  },
1619
1621
  onKeyDown: (event) => {
1620
- if (blocked) return;
1622
+ if (blocked || tool === "pan") return;
1621
1623
  const delta = event.shiftKey ? 20 : 4;
1622
1624
  const directions = { ArrowLeft: [-delta, 0], ArrowRight: [delta, 0], ArrowUp: [0, -delta], ArrowDown: [0, delta] };
1623
1625
  if (event.key === " ") {
@@ -1646,6 +1648,7 @@ var Drawing = forwardRef5(function Drawing2({ value, defaultValue, width = 960,
1646
1648
  image && !imageReady && /* @__PURE__ */ jsx11("span", { className: "mx-drawing-image-status", role: raster?.source === image && raster.failed ? "alert" : "status", children: raster?.source === image && raster.failed ? "Original drawing couldn\u2019t load. Reopen the note to retry." : "Loading drawing\u2026" }),
1647
1649
  /* @__PURE__ */ jsxs9("div", { className: "mx-drawing-toolbar", role: "group", "aria-label": "Drawing tools", children: [
1648
1650
  /* @__PURE__ */ jsxs9("div", { className: "mx-drawing-tools", children: [
1651
+ /* @__PURE__ */ jsx11(Button, { size: "sm", variant: tool === "pan" ? "secondary" : "ghost", "aria-label": "Scroll canvas", title: "Scroll without drawing", "aria-pressed": tool === "pan", disabled: blocked, onClick: () => setTool("pan"), children: /* @__PURE__ */ jsx11("svg", { viewBox: "0 0 24 24", width: "18", height: "18", fill: "none", stroke: "currentColor", strokeWidth: "1.6", "aria-hidden": "true", children: /* @__PURE__ */ jsx11("path", { d: "M8 13V6a2 2 0 0 1 4 0v6-8a2 2 0 0 1 4 0v8-5a2 2 0 0 1 4 0v9c0 4-3 6-7 6-3 0-5-2-6-4l-3-5a2 2 0 0 1 3-2l3 3" }) }) }),
1649
1652
  /* @__PURE__ */ jsx11(Button, { size: "sm", variant: "ghost", "aria-label": "Undo drawing", title: "Undo", disabled: blocked || !past.length, onClick: () => {
1650
1653
  const previous = past[past.length - 1];
1651
1654
  if (!previous) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moxule-components",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "A TypeScript React component library.",
5
5
  "license": "MIT",
6
6
  "type": "module",