@punica/editor 1.10.2 → 1.10.3

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": "@punica/editor",
3
- "version": "1.10.2",
3
+ "version": "1.10.3",
4
4
  "description": "Punica Editor",
5
5
  "private": false,
6
6
  "type": "module",
@@ -112,6 +112,14 @@ declare module 'punica' {
112
112
  children?: HTMLElement[];
113
113
  style?: Record<string, string> | string;
114
114
  className?: string;
115
+ /**
116
+ * Listeners bound as the element is built, keyed by event name:
117
+ * `{ click: fn, mousedown: fn }`. The component factories already
118
+ * take an `onClick`; this is the same thing for the plain tags a
119
+ * view builds by hand, so a tree stays one expression instead of
120
+ * breaking into a variable plus an `addEventListener` line.
121
+ */
122
+ on?: Record<string, EventListener>;
115
123
  }
116
124
 
117
125
  interface ButtonOptions {
@@ -183,6 +191,31 @@ declare module 'punica' {
183
191
  variant?: 'filled' | 'outlined';
184
192
  color?: 'primary' | 'secondary' | 'error' | 'success' | 'warning';
185
193
  size?: 'small' | 'medium';
194
+ /**
195
+ * Icon class placed before the label, wrapped in an `<i>`. Same
196
+ * contract as `createIcon`'s `iconClass`.
197
+ */
198
+ icon?: string;
199
+ /**
200
+ * Extra content after the label — a chevron on a chip that opens a
201
+ * menu, a count, a thumbnail. `punica-chip` slots its children, so
202
+ * these land next to the label rather than replacing it.
203
+ */
204
+ children?: HTMLElement[];
205
+ /**
206
+ * A dismiss control in the component's `delete` slot. Without this
207
+ * no slot content is written, so a plain chip is unchanged.
208
+ */
209
+ onDelete?: (e: Event) => void;
210
+ /**
211
+ * Makes the chip act as a button: `role="button"`, `tabindex="0"`
212
+ * and Enter/Space alongside the click. The component styles itself
213
+ * `cursor: unset`, so a chip is inert until this is given.
214
+ */
215
+ onClick?: (e: Event) => void;
216
+ attrs?: Record<string, string>;
217
+ style?: Record<string, string> | string;
218
+ className?: string;
186
219
  }
187
220
 
188
221
  interface BoxOptions {
@@ -371,6 +404,24 @@ declare module 'punica' {
371
404
  className?: string;
372
405
  }
373
406
 
407
+ /**
408
+ * Where an anchored menu opens. An element is measured with
409
+ * `getBoundingClientRect`; a bare rect is for the cursor-driven case
410
+ * (a context menu opens at the pointer, which has no element).
411
+ */
412
+ interface MenuAnchorOptions {
413
+ anchor:
414
+ | HTMLElement
415
+ | {
416
+ top: number;
417
+ left: number;
418
+ bottom?: number;
419
+ width?: number;
420
+ height?: number;
421
+ };
422
+ placement?: 'top' | 'bottom' | 'left' | 'right';
423
+ }
424
+
374
425
  interface MenuItemOptions {
375
426
  text?: string;
376
427
  attrs?: Record<string, string>;
@@ -504,6 +555,21 @@ declare module 'punica' {
504
555
 
505
556
  function createMenuItem(options?: MenuItemOptions): HTMLElement;
506
557
 
558
+ /**
559
+ * Opens a `punica-menu` beside something. The component does the rest
560
+ * — backdrop, Escape, and flipping when the menu does not fit — but it
561
+ * reads the position off `top`/`left`/`width`/`height`/`bottom`/
562
+ * `placement` attributes, which every caller was measuring and writing
563
+ * by hand.
564
+ */
565
+ function openMenuAt(
566
+ menu: HTMLElement,
567
+ options: MenuAnchorOptions
568
+ ): void;
569
+
570
+ /** Closes an open menu. The component fires `close` as it hides. */
571
+ function closeMenu(menu: HTMLElement): void;
572
+
507
573
  /** A resizable pane container. Children become the panes, in order. */
508
574
  function createSplit(options?: SplitOptions): HTMLElement;
509
575