@punica/editor 1.10.2 → 1.10.4

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.4",
4
4
  "description": "Punica Editor",
5
5
  "private": false,
6
6
  "type": "module",
@@ -112,52 +112,48 @@ 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 {
118
126
  variant?: 'filled' | 'outlined' | 'text';
119
- color?: 'primary' | 'secondary' | 'error';
127
+ color?:
128
+ | 'primary'
129
+ | 'secondary'
130
+ | 'error'
131
+ | 'warning'
132
+ | 'info'
133
+ | 'success'
134
+ | 'ghost';
120
135
  size?: 'small' | 'medium' | 'large';
121
136
  disabled?: boolean;
122
137
  rounded?: boolean;
123
138
  icon?: string;
124
139
  fullwidth?: boolean;
140
+ attrs?: Record<string, string>;
141
+ style?: Record<string, string> | string;
142
+ className?: string;
125
143
  }
126
144
 
127
145
  interface IconButtonOptions {
128
146
  title?: string;
129
- size?: 'x-small' | 'small' | 'medium';
147
+ size?: 'x-small' | 'small' | 'medium' | 'large';
130
148
  variant?: 'text' | 'outlined' | 'filled';
131
149
  disabled?: boolean;
132
150
  attrs?: Record<string, string>;
133
151
  style?: Record<string, string> | string;
134
152
  className?: string;
135
- /**
136
- * Finished icon markup, for the cases the positional `iconClass`
137
- * cannot express — a toolbar action declares its icon as ready
138
- * `<i>`/`<svg>` markup rather than a class name, so wrapping it in
139
- * another `<i class=…>` would nest it wrongly.
140
- *
141
- * Same contract as `IconOptions`: a non-empty `iconClass` wins, and
142
- * this is used only when the caller passes an empty one.
143
- */
144
153
  innerHTML?: string;
145
154
  }
146
155
 
147
156
  interface TypographyOptions {
148
- /**
149
- * Every variant `punica-typography` ships a `:host([variant=…])`
150
- * rule for, and nothing else.
151
- *
152
- * This list was previously `'h1'..'h6' | 'body' | 'caption'`, of
153
- * which only `caption` was real. An unknown variant is not a
154
- * harmless no-op: the component stamps `variant="body1"` on any
155
- * element created *without* one, so passing a name it does not
156
- * implement suppresses that default and leaves the text at the
157
- * inherited size, `inline`, with no `role=heading` and no
158
- * `aria-level`. `createTypography` therefore drops anything outside
159
- * this list rather than writing it to the DOM.
160
- */
161
157
  variant?:
162
158
  | 'headline1'
163
159
  | 'headline2'
@@ -183,6 +179,31 @@ declare module 'punica' {
183
179
  variant?: 'filled' | 'outlined';
184
180
  color?: 'primary' | 'secondary' | 'error' | 'success' | 'warning';
185
181
  size?: 'small' | 'medium';
182
+ /**
183
+ * Icon class placed before the label, wrapped in an `<i>`. Same
184
+ * contract as `createIcon`'s `iconClass`.
185
+ */
186
+ icon?: string;
187
+ /**
188
+ * Extra content after the label — a chevron on a chip that opens a
189
+ * menu, a count, a thumbnail. `punica-chip` slots its children, so
190
+ * these land next to the label rather than replacing it.
191
+ */
192
+ children?: HTMLElement[];
193
+ /**
194
+ * A dismiss control in the component's `delete` slot. Without this
195
+ * no slot content is written, so a plain chip is unchanged.
196
+ */
197
+ onDelete?: (e: Event) => void;
198
+ /**
199
+ * Makes the chip act as a button: `role="button"`, `tabindex="0"`
200
+ * and Enter/Space alongside the click. The component styles itself
201
+ * `cursor: unset`, so a chip is inert until this is given.
202
+ */
203
+ onClick?: (e: Event) => void;
204
+ attrs?: Record<string, string>;
205
+ style?: Record<string, string> | string;
206
+ className?: string;
186
207
  }
187
208
 
188
209
  interface BoxOptions {
@@ -371,6 +392,24 @@ declare module 'punica' {
371
392
  className?: string;
372
393
  }
373
394
 
395
+ /**
396
+ * Where an anchored menu opens. An element is measured with
397
+ * `getBoundingClientRect`; a bare rect is for the cursor-driven case
398
+ * (a context menu opens at the pointer, which has no element).
399
+ */
400
+ interface MenuAnchorOptions {
401
+ anchor:
402
+ | HTMLElement
403
+ | {
404
+ top: number;
405
+ left: number;
406
+ bottom?: number;
407
+ width?: number;
408
+ height?: number;
409
+ };
410
+ placement?: 'top' | 'bottom' | 'left' | 'right';
411
+ }
412
+
374
413
  interface MenuItemOptions {
375
414
  text?: string;
376
415
  attrs?: Record<string, string>;
@@ -445,6 +484,11 @@ declare module 'punica' {
445
484
  * `onClick` receives the click event. It was declared `() => void`,
446
485
  * which no handler that needs the event (to stop propagation, or to
447
486
  * position a flyout off the cursor) could satisfy.
487
+ *
488
+ * A `label` containing `<` is written as **markup**, not text — an
489
+ * activity-bar entry declares its icon that way. Any label that comes
490
+ * from an LLM, a file path or user input must not go through it: pass
491
+ * an empty label and a `createTypography` child instead.
448
492
  */
449
493
  function createButton(
450
494
  label: string,
@@ -504,6 +548,21 @@ declare module 'punica' {
504
548
 
505
549
  function createMenuItem(options?: MenuItemOptions): HTMLElement;
506
550
 
551
+ /**
552
+ * Opens a `punica-menu` beside something. The component does the rest
553
+ * — backdrop, Escape, and flipping when the menu does not fit — but it
554
+ * reads the position off `top`/`left`/`width`/`height`/`bottom`/
555
+ * `placement` attributes, which every caller was measuring and writing
556
+ * by hand.
557
+ */
558
+ function openMenuAt(
559
+ menu: HTMLElement,
560
+ options: MenuAnchorOptions
561
+ ): void;
562
+
563
+ /** Closes an open menu. The component fires `close` as it hides. */
564
+ function closeMenu(menu: HTMLElement): void;
565
+
507
566
  /** A resizable pane container. Children become the panes, in order. */
508
567
  function createSplit(options?: SplitOptions): HTMLElement;
509
568