@formicoidea/labre-ddd-shared 0.29.1 → 0.31.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.
@@ -9,7 +9,13 @@ import type { GfxController } from '@formicoidea/labre-core/std/gfx';
9
9
  type Surface = NonNullable<GfxController['surface']>;
10
10
  /** Group several element ids; returns the group id (or the first id on failure). */
11
11
  export declare function groupIds(std: BlockStdScope, ids: string[]): string;
12
- /** A post-it: faux-shadow rect + coloured face + centred handwriting label, grouped. */
12
+ /**
13
+ * A post-it: faux-shadow rect + coloured face whose label is the face's OWN
14
+ * shape text in `contained` fit mode — like a real post-it, the box size is
15
+ * fixed and the handwriting shrinks to fit. Grouped so shadow and face move
16
+ * together. (Stickies created before the text-fit feature carry a separate
17
+ * text element; they keep working untouched.)
18
+ */
13
19
  export declare function addSticky(surface: Surface, std: BlockStdScope, cx: number, cy: number, opts: {
14
20
  fill: string;
15
21
  text: string;
@@ -17,8 +23,12 @@ export declare function addSticky(surface: Surface, std: BlockStdScope, cx: numb
17
23
  shapeType?: 'rect' | 'diamond';
18
24
  size?: number;
19
25
  }): string;
20
- /** A Context Map bounded-context bubble (rounded pill + centred label). */
21
- export declare function addBubble(surface: Surface, std: BlockStdScope, cx: number, cy: number, label: string): string;
26
+ /**
27
+ * A Context Map bounded-context bubble: a rounded pill whose label is the
28
+ * pill's own shape text in `overflow` fit mode (fixed pill, fixed font — a
29
+ * long context name may spill out rather than deform the map).
30
+ */
31
+ export declare function addBubble(surface: Surface, cx: number, cy: number, label: string): string;
22
32
  /** A Core Domain dot (sub-domain / bounded context); optional label to its right. */
23
33
  export declare function addDot(surface: Surface, std: BlockStdScope, cx: number, cy: number, fill: string, label?: string): string;
24
34
  /** A free-floating label. */
@@ -1,7 +1,8 @@
1
1
  import { createGroupCommand } from '@formicoidea/labre-core/gfx/group';
2
- import { ConnectorMode, FontWeight, PointStyle, ShapeStyle, StrokeStyle, } from '@formicoidea/labre-core/model';
2
+ import { ConnectorMode, FontWeight, PointStyle, ShapeStyle, StrokeStyle, TextFitMode, } from '@formicoidea/labre-core/model';
3
3
  import { Bound } from '@formicoidea/labre-core/global/gfx';
4
- import { CLOUD, CLOUD_VERTICES, CM_BUBBLE, DOT_SIZE, LABEL_COLOR, LABEL_FONT, LABEL_FONT_SIZE, MARKER_SIZE, SHADOW_COLOR, SHADOW_OFFSET, STICKY_FONT, STICKY_FONT_SIZE, STICKY_RADIUS, STICKY_SIZE, } from './consts';
4
+ import * as Y from 'yjs';
5
+ import { CLOUD, CLOUD_VERTICES, CM_BUBBLE, DOT_SIZE, LABEL_COLOR, LABEL_FONT, LABEL_FONT_SIZE, MARKER_SIZE, SHADOW_COLOR, SHADOW_OFFSET, STICKY_FONT, STICKY_FONT_SIZE, STICKY_RADIUS, STICKY_SIZE, } from './consts.js';
5
6
  const NO_STROKE = '#00000000';
6
7
  /** Group several element ids; returns the group id (or the first id on failure). */
7
8
  export function groupIds(std, ids) {
@@ -9,7 +10,7 @@ export function groupIds(std, ids) {
9
10
  return result.groupId || ids[0];
10
11
  }
11
12
  function addShape(surface, x, y, w, h, opts) {
12
- const { shapeType = 'rect', fill, stroke = NO_STROKE, strokeWidth = 0, radius = 0 } = opts;
13
+ const { shapeType = 'rect', fill, stroke = NO_STROKE, strokeWidth = 0, radius = 0, label } = opts;
13
14
  return surface.addElement({
14
15
  type: 'shape',
15
16
  shapeType,
@@ -21,6 +22,16 @@ function addShape(surface, x, y, w, h, opts) {
21
22
  roughness: 0,
22
23
  radius,
23
24
  xywh: new Bound(x, y, w, h).serialize(),
25
+ ...(label
26
+ ? {
27
+ text: new Y.Text(label.text),
28
+ color: label.color,
29
+ fontFamily: label.fontFamily,
30
+ fontSize: label.fontSize,
31
+ textAlign: 'center',
32
+ textFitMode: label.fit,
33
+ }
34
+ : {}),
24
35
  });
25
36
  }
26
37
  function addText(surface, x, y, w, text, color, fontFamily, fontSize, textAlign = 'center', bold = false) {
@@ -35,7 +46,13 @@ function addText(surface, x, y, w, text, color, fontFamily, fontSize, textAlign
35
46
  xywh: new Bound(x, y, w, fontSize + 10).serialize(),
36
47
  });
37
48
  }
38
- /** A post-it: faux-shadow rect + coloured face + centred handwriting label, grouped. */
49
+ /**
50
+ * A post-it: faux-shadow rect + coloured face whose label is the face's OWN
51
+ * shape text in `contained` fit mode — like a real post-it, the box size is
52
+ * fixed and the handwriting shrinks to fit. Grouped so shadow and face move
53
+ * together. (Stickies created before the text-fit feature carry a separate
54
+ * text element; they keep working untouched.)
55
+ */
39
56
  export function addSticky(surface, std, cx, cy, opts) {
40
57
  const { fill, text, label, shapeType = 'rect', size = STICKY_SIZE } = opts;
41
58
  const half = size / 2;
@@ -45,21 +62,40 @@ export function addSticky(surface, std, cx, cy, opts) {
45
62
  fill: SHADOW_COLOR,
46
63
  radius,
47
64
  });
48
- const face = addShape(surface, cx - half, cy - half, size, size, { shapeType, fill, radius });
49
- const lbl = addText(surface, cx - half + 10, cy - STICKY_FONT_SIZE / 2, size - 20, label, text, STICKY_FONT, STICKY_FONT_SIZE);
50
- return groupIds(std, [shadow, face, lbl]);
65
+ const face = addShape(surface, cx - half, cy - half, size, size, {
66
+ shapeType,
67
+ fill,
68
+ radius,
69
+ label: {
70
+ text: label,
71
+ color: text,
72
+ fontFamily: STICKY_FONT,
73
+ fontSize: STICKY_FONT_SIZE,
74
+ fit: TextFitMode.Contained,
75
+ },
76
+ });
77
+ return groupIds(std, [shadow, face]);
51
78
  }
52
- /** A Context Map bounded-context bubble (rounded pill + centred label). */
53
- export function addBubble(surface, std, cx, cy, label) {
79
+ /**
80
+ * A Context Map bounded-context bubble: a rounded pill whose label is the
81
+ * pill's own shape text in `overflow` fit mode (fixed pill, fixed font — a
82
+ * long context name may spill out rather than deform the map).
83
+ */
84
+ export function addBubble(surface, cx, cy, label) {
54
85
  const { w, h, radius, fill, stroke, text } = CM_BUBBLE;
55
- const box = addShape(surface, cx - w / 2, cy - h / 2, w, h, {
86
+ return addShape(surface, cx - w / 2, cy - h / 2, w, h, {
56
87
  fill,
57
88
  stroke,
58
89
  strokeWidth: 1.5,
59
90
  radius,
91
+ label: {
92
+ text: label,
93
+ color: text,
94
+ fontFamily: LABEL_FONT,
95
+ fontSize: LABEL_FONT_SIZE,
96
+ fit: TextFitMode.Overflow,
97
+ },
60
98
  });
61
- const lbl = addText(surface, cx - w / 2 + 8, cy - LABEL_FONT_SIZE / 2, w - 16, label, text, LABEL_FONT, LABEL_FONT_SIZE);
62
- return groupIds(std, [box, lbl]);
63
99
  }
64
100
  /** A Core Domain dot (sub-domain / bounded context); optional label to its right. */
65
101
  export function addDot(surface, std, cx, cy, fill, label) {
@@ -1,6 +1,6 @@
1
1
  import { makeTemplateSnapshot, surfaceText, } from '@formicoidea/labre-core/gfx/template';
2
2
  import { ConnectorMode, FontFamily, PointStyle, ShapeStyle, StrokeStyle, TextAlign, } from '@formicoidea/labre-core/model';
3
- import { CD_SUBDOMAINS, CLOUD, CLOUD_VERTICES, CM_BUBBLE, CM_RELATIONSHIPS, ES_HOTSPOT, ES_STICKIES, MOVEMENT_COLOR, TEAM_TOPOLOGIES, } from '../shared/consts';
3
+ import { CD_SUBDOMAINS, CLOUD, CLOUD_VERTICES, CM_BUBBLE, CM_RELATIONSHIPS, ES_HOTSPOT, ES_STICKIES, MOVEMENT_COLOR, TEAM_TOPOLOGIES, } from '../shared/consts.js';
4
4
  /**
5
5
  * Every DDD component (the things the three senior menus create) re-expressed as
6
6
  * an insertable Template, so the whole toolbox is also available from the
@@ -26,6 +26,8 @@ export class DddSeniorButtonBase extends EdgelessToolbarToolMixin(SignalWatcher(
26
26
  width: 100%;
27
27
  height: 64px;
28
28
  cursor: pointer;
29
+ /* no double-tap-zoom / 300ms tap delay on touch screens */
30
+ touch-action: manipulation;
29
31
  display: flex;
30
32
  align-items: flex-end;
31
33
  justify-content: center;
@@ -44,7 +46,8 @@ export class DddSeniorButtonBase extends EdgelessToolbarToolMixin(SignalWatcher(
44
46
  width: 100%;
45
47
  height: 100%;
46
48
  }
47
- .ddd-root:hover .ddd-card {
49
+ .ddd-root:hover .ddd-card,
50
+ .ddd-root:active .ddd-card {
48
51
  --y: -10px;
49
52
  --s: 1.07;
50
53
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formicoidea/labre-ddd-shared",
3
3
  "description": "Labre ddd-shared — shared building blocks for @formicoidea/labre-core frameworks.",
4
- "version": "0.29.1",
4
+ "version": "0.31.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "author": "lajola",
@@ -19,7 +19,7 @@
19
19
  "dist"
20
20
  ],
21
21
  "dependencies": {
22
- "@formicoidea/labre-core": "0.29.1",
22
+ "@formicoidea/labre-core": "0.31.0",
23
23
  "lit": "^3.2.0"
24
24
  }
25
25
  }