@kubex/zinc 1.1.78 → 1.1.80
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/dist/custom-elements.json +1149 -130
- package/dist/vscode.html-custom-data.json +175 -1
- package/dist/web-types.json +396 -2
- package/dist/zn.d.ts +384 -0
- package/dist/zn.min.js +350 -295
- package/docs/pages/components/inline-edit.md +21 -0
- package/docs/pages/components/rating.md +2 -1
- package/docs/pages/components/slash-item.md +126 -0
- package/docs/pages/components/slash-menu.md +168 -0
- package/docs/pages/components/textarea.md +148 -0
- package/docs/pages/components/translations.md +34 -0
- package/package.json +1 -1
- package/src/components/inline-edit/inline-edit.component.ts +31 -0
- package/src/components/inline-edit/inline-edit.test.ts +83 -1
- package/src/components/rating/rating.component.ts +10 -1
- package/src/components/rating/rating.scss +6 -9
- package/src/components/slash-item/index.ts +12 -0
- package/src/components/slash-item/slash-item.component.ts +76 -0
- package/src/components/slash-item/slash-item.scss +5 -0
- package/src/components/slash-menu/index.ts +14 -0
- package/src/components/slash-menu/slash-menu-controller.ts +361 -0
- package/src/components/slash-menu/slash-menu-items.ts +122 -0
- package/src/components/slash-menu/slash-menu.component.ts +305 -0
- package/src/components/slash-menu/slash-menu.scss +120 -0
- package/src/components/slash-menu/slash-menu.test.ts +154 -0
- package/src/components/textarea/textarea.component.ts +143 -0
- package/src/components/textarea/textarea.test.ts +310 -2
- package/src/components/translations/translations.component.ts +31 -0
- package/src/components/translations/translations.test.ts +89 -1
- package/src/events/events.ts +2 -0
- package/src/events/zn-slash-insert.ts +9 -0
- package/src/events/zn-slash-select.ts +9 -0
- package/src/utilities/caret-position.ts +118 -0
- package/src/zinc.ts +3 -0
package/dist/zn.d.ts
CHANGED
|
@@ -4813,8 +4813,51 @@ declare module "components/icon-picker/index" {
|
|
|
4813
4813
|
}
|
|
4814
4814
|
}
|
|
4815
4815
|
}
|
|
4816
|
+
declare module "components/slash-menu/slash-menu-items" {
|
|
4817
|
+
export interface SlashMenuItem {
|
|
4818
|
+
/** The text shown in the menu. */
|
|
4819
|
+
label: string;
|
|
4820
|
+
/** The text inserted into the field. Omit for items handled entirely by the `zn-slash-select` event. */
|
|
4821
|
+
value?: string;
|
|
4822
|
+
/** Icon shown against the item, e.g. `tag@lu`. */
|
|
4823
|
+
icon?: string;
|
|
4824
|
+
/** Supporting text shown under the label. */
|
|
4825
|
+
description?: string;
|
|
4826
|
+
/** Extra terms the item can be found by. */
|
|
4827
|
+
keywords?: string | string[];
|
|
4828
|
+
/** Heading the item is listed under. Items without a group are listed first, in source order. */
|
|
4829
|
+
group?: string;
|
|
4830
|
+
/** Overrides the position of the item within its match band. Lower sorts first. */
|
|
4831
|
+
order?: number;
|
|
4832
|
+
/** Identifier passed through on `zn-slash-select`, for items that do something other than insert text. */
|
|
4833
|
+
action?: string;
|
|
4834
|
+
/** Where the caret lands after insertion, as an offset into `value`. Defaults to the end. */
|
|
4835
|
+
caretOffset?: number;
|
|
4836
|
+
/** Listed, but not selectable. */
|
|
4837
|
+
disabled?: boolean;
|
|
4838
|
+
}
|
|
4839
|
+
/**
|
|
4840
|
+
* Registers a named, reusable set of insertions, so a list defined once (e.g. the merge fields
|
|
4841
|
+
* allowed in legal copy) can be referenced from markup with `slash-preset="<name>"`.
|
|
4842
|
+
*/
|
|
4843
|
+
export function registerSlashMenuPreset(name: string, items: SlashMenuItem[]): void;
|
|
4844
|
+
/** Removes a preset registered with `registerSlashMenuPreset`. */
|
|
4845
|
+
export function unregisterSlashMenuPreset(name: string): void;
|
|
4846
|
+
/** The names of every registered preset. */
|
|
4847
|
+
export function slashMenuPresetNames(): string[];
|
|
4848
|
+
/** Resolves one or more preset names (comma separated, or an array) to their items. */
|
|
4849
|
+
export function getSlashMenuPreset(names: string | string[]): SlashMenuItem[];
|
|
4850
|
+
/**
|
|
4851
|
+
* Parses the `slash-items` attribute. Accepts a JSON array of items, or the shorthand
|
|
4852
|
+
* `Label={{TOKEN}}, Other={{OTHER}}` (the label may be omitted to use the token as its own label).
|
|
4853
|
+
*/
|
|
4854
|
+
export function parseSlashItems(value: string | null | undefined): SlashMenuItem[];
|
|
4855
|
+
/** Filters and ranks items against a query. An empty query keeps every item in its declared order. */
|
|
4856
|
+
export function filterSlashItems(items: SlashMenuItem[], query: string): SlashMenuItem[];
|
|
4857
|
+
}
|
|
4816
4858
|
declare module "components/inline-edit/inline-edit.component" {
|
|
4817
4859
|
import { type CSSResultGroup, type HTMLTemplateResult, type PropertyValues } from 'lit';
|
|
4860
|
+
import { type SlashMenuItem } from "components/slash-menu/slash-menu-items";
|
|
4818
4861
|
import ZincElement from "internal/zinc-element";
|
|
4819
4862
|
import ZnSelect from "components/select/index";
|
|
4820
4863
|
import type { ZincFormControl } from "internal/zinc-element";
|
|
@@ -4870,6 +4913,19 @@ declare module "components/inline-edit/inline-edit.component" {
|
|
|
4870
4913
|
step: number | 'any';
|
|
4871
4914
|
inputType: 'select' | 'text' | 'data-select' | 'number' | 'textarea';
|
|
4872
4915
|
textareaRows: 1;
|
|
4916
|
+
/**
|
|
4917
|
+
* Quick insertions offered by the slash menu of a `textarea` input. Accepts a JSON array of items, or the
|
|
4918
|
+
* shorthand `Brand name={{BRAND_NAME}}, Support email={{SUPPORT_EMAIL}}`. Forwarded to the inner `zn-textarea`.
|
|
4919
|
+
*/
|
|
4920
|
+
slashItems: SlashMenuItem[];
|
|
4921
|
+
/** Names of item sets registered with `registerSlashMenuPreset`, comma separated. */
|
|
4922
|
+
slashPreset: string;
|
|
4923
|
+
/** The characters that open the slash menu. */
|
|
4924
|
+
slashTrigger: string;
|
|
4925
|
+
/** The heading shown above the slash menu's items. */
|
|
4926
|
+
slashHeading: string;
|
|
4927
|
+
/** Resolves additional slash menu items each time the menu opens. JavaScript only. */
|
|
4928
|
+
slashItemsProvider?: (query: string) => SlashMenuItem[] | Promise<SlashMenuItem[]>;
|
|
4873
4929
|
options: {
|
|
4874
4930
|
[key: string]: string;
|
|
4875
4931
|
};
|
|
@@ -6206,9 +6262,250 @@ declare module "components/editor/modules/ai/tooltip/ai-tooltip.component" {
|
|
|
6206
6262
|
render(): import("lit-html").TemplateResult<1>;
|
|
6207
6263
|
}
|
|
6208
6264
|
}
|
|
6265
|
+
declare module "utilities/caret-position" {
|
|
6266
|
+
export interface CaretCoordinates {
|
|
6267
|
+
top: number;
|
|
6268
|
+
left: number;
|
|
6269
|
+
height: number;
|
|
6270
|
+
}
|
|
6271
|
+
export type TextField = HTMLTextAreaElement | HTMLInputElement;
|
|
6272
|
+
/**
|
|
6273
|
+
* Measures where the caret sits inside a text field, relative to the field's own top/left corner.
|
|
6274
|
+
* There is no browser API for this, so the field is mirrored into an off-screen div and the offset
|
|
6275
|
+
* of a marker span at `index` is read back.
|
|
6276
|
+
*/
|
|
6277
|
+
export function getCaretCoordinates(field: TextField, index: number): CaretCoordinates;
|
|
6278
|
+
/**
|
|
6279
|
+
* Projects measured caret coordinates onto the viewport, clamped to the field's box so a caret
|
|
6280
|
+
* scrolled out of view doesn't drag anchored content off with it. Split from the measurement so a
|
|
6281
|
+
* cached measurement can be re-projected as the field scrolls or moves.
|
|
6282
|
+
*/
|
|
6283
|
+
export function caretRectFrom(field: TextField, { top, left, height }: CaretCoordinates): DOMRect;
|
|
6284
|
+
/** The caret's position as a viewport rect. */
|
|
6285
|
+
export function getCaretRect(field: TextField, index: number): DOMRect;
|
|
6286
|
+
}
|
|
6287
|
+
declare module "components/slash-menu/slash-menu.component" {
|
|
6288
|
+
import ZincElement from "internal/zinc-element";
|
|
6289
|
+
import ZnIcon from "components/icon/index";
|
|
6290
|
+
import type { CSSResultGroup, PropertyValues } from 'lit';
|
|
6291
|
+
import type { Placement, VirtualElement } from '@floating-ui/dom';
|
|
6292
|
+
import type { SlashMenuItem } from "components/slash-menu/slash-menu-items";
|
|
6293
|
+
export const SLASH_ITEM_SELECT = "zn-slash-item-select";
|
|
6294
|
+
/**
|
|
6295
|
+
* @summary A keyboard-driven list of insertions, anchored to the caret of the field that opened it.
|
|
6296
|
+
* @documentation https://zinc.style/components/slash-menu
|
|
6297
|
+
* @status experimental
|
|
6298
|
+
* @since 1.1
|
|
6299
|
+
*
|
|
6300
|
+
* @dependency zn-icon
|
|
6301
|
+
*
|
|
6302
|
+
* @event zn-slash-item-select - Emitted when an item is chosen. Does not cross shadow boundaries; the
|
|
6303
|
+
* component driving the menu (e.g. `zn-textarea`) re-emits it as `zn-slash-select`.
|
|
6304
|
+
*
|
|
6305
|
+
* @csspart panel - The floating panel that holds the list.
|
|
6306
|
+
* @csspart heading - The panel's heading.
|
|
6307
|
+
* @csspart item - An item in the list.
|
|
6308
|
+
* @csspart group-heading - A group heading between items.
|
|
6309
|
+
* @csspart footer - The truncation footer, shown when not every match fits.
|
|
6310
|
+
*
|
|
6311
|
+
* @cssproperty --slash-menu-width - The width of the panel.
|
|
6312
|
+
* @cssproperty --slash-menu-max-height - The maximum height of the panel before it scrolls.
|
|
6313
|
+
*/
|
|
6314
|
+
export default class ZnSlashMenu extends ZincElement {
|
|
6315
|
+
static styles: CSSResultGroup;
|
|
6316
|
+
static dependencies: {
|
|
6317
|
+
'zn-icon': typeof ZnIcon;
|
|
6318
|
+
};
|
|
6319
|
+
private panel;
|
|
6320
|
+
private stopAutoUpdate?;
|
|
6321
|
+
/** Whether the menu is showing. */
|
|
6322
|
+
open: boolean;
|
|
6323
|
+
/** The items to list. Already filtered — the menu displays what it is given. */
|
|
6324
|
+
items: SlashMenuItem[];
|
|
6325
|
+
/** The query the items were matched against, shown in the heading. */
|
|
6326
|
+
query: string;
|
|
6327
|
+
/** The heading shown when there is no query. */
|
|
6328
|
+
heading: string;
|
|
6329
|
+
/** Shown in place of the list when there are no items. */
|
|
6330
|
+
emptyText: string;
|
|
6331
|
+
/** The most items to render at once. Remaining matches are reported in the footer. */
|
|
6332
|
+
maxItems: number;
|
|
6333
|
+
/** The element or caret rect the panel is positioned against. */
|
|
6334
|
+
anchor: Element | VirtualElement | null;
|
|
6335
|
+
/** The preferred placement of the panel. */
|
|
6336
|
+
placement: Placement;
|
|
6337
|
+
/** The gap between the caret and the panel. */
|
|
6338
|
+
distance: number;
|
|
6339
|
+
private activeIndex;
|
|
6340
|
+
private get visibleItems();
|
|
6341
|
+
/** The item that Enter would insert. */
|
|
6342
|
+
get activeItem(): SlashMenuItem | undefined;
|
|
6343
|
+
show(): void;
|
|
6344
|
+
hide(): void;
|
|
6345
|
+
/** Sets the active item by index, wrapping at both ends and skipping disabled items. */
|
|
6346
|
+
setActiveIndex(index: number): void;
|
|
6347
|
+
/** Moves the active item by `delta` places. */
|
|
6348
|
+
moveActive(delta: number): void;
|
|
6349
|
+
/** Chooses the active item, as pressing Enter would. */
|
|
6350
|
+
selectActive(): void;
|
|
6351
|
+
/** Recalculates the panel's position against its anchor. */
|
|
6352
|
+
reposition(): void;
|
|
6353
|
+
connectedCallback(): void;
|
|
6354
|
+
disconnectedCallback(): void;
|
|
6355
|
+
private startPositioner;
|
|
6356
|
+
private stopPositioner;
|
|
6357
|
+
private position;
|
|
6358
|
+
private selectItem;
|
|
6359
|
+
private scrollActiveIntoView;
|
|
6360
|
+
private readonly handleItemMouseDown;
|
|
6361
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
6362
|
+
protected updated(changed: PropertyValues): void;
|
|
6363
|
+
private renderItem;
|
|
6364
|
+
private renderItems;
|
|
6365
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
6366
|
+
}
|
|
6367
|
+
}
|
|
6368
|
+
declare module "components/slash-menu/slash-menu-controller" {
|
|
6369
|
+
import type { TextField } from "utilities/caret-position";
|
|
6370
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
6371
|
+
import type { SlashMenuItem } from "components/slash-menu/slash-menu-items";
|
|
6372
|
+
import type ZnSlashMenu from "components/slash-menu/slash-menu.component";
|
|
6373
|
+
export interface SlashMenuControllerOptions {
|
|
6374
|
+
/**
|
|
6375
|
+
* Resolves the menu to render results into. Called the first time the menu is needed, so the host
|
|
6376
|
+
* can render it lazily; may return a promise (e.g. after awaiting `updateComplete`).
|
|
6377
|
+
*/
|
|
6378
|
+
menu: () => ZnSlashMenu | null | Promise<ZnSlashMenu | null>;
|
|
6379
|
+
/** The available items, unfiltered. Receives the current query so lists can be resolved remotely. */
|
|
6380
|
+
items: (query: string) => SlashMenuItem[] | Promise<SlashMenuItem[]>;
|
|
6381
|
+
/** The characters that open the menu. Defaults to `/`. */
|
|
6382
|
+
trigger?: () => string;
|
|
6383
|
+
/** Called before an item is inserted. Return `false` to handle the item yourself. */
|
|
6384
|
+
onSelect?: (item: SlashMenuItem, query: string) => boolean;
|
|
6385
|
+
/** Called after an item's value has been written into the field. */
|
|
6386
|
+
onInsert?: (item: SlashMenuItem, value: string) => void;
|
|
6387
|
+
}
|
|
6388
|
+
/**
|
|
6389
|
+
* Drives a slash menu for a plain `<textarea>` or `<input>`: watches the caret for the trigger
|
|
6390
|
+
* sequence, resolves and filters items, and inserts the chosen value.
|
|
6391
|
+
*
|
|
6392
|
+
* The host owns the field and the menu element; this controller owns the interaction.
|
|
6393
|
+
*/
|
|
6394
|
+
export class SlashMenuController implements ReactiveController {
|
|
6395
|
+
private readonly host;
|
|
6396
|
+
private readonly options;
|
|
6397
|
+
private readonly caretAnchor;
|
|
6398
|
+
private field;
|
|
6399
|
+
private menu;
|
|
6400
|
+
private triggerIndex;
|
|
6401
|
+
private query;
|
|
6402
|
+
/** Trigger position the user dismissed with Escape; the menu stays shut until they move off it. */
|
|
6403
|
+
private dismissedIndex;
|
|
6404
|
+
private resolveToken;
|
|
6405
|
+
private inserting;
|
|
6406
|
+
private isOpen;
|
|
6407
|
+
private listening;
|
|
6408
|
+
/** Caret measurement is the expensive part of positioning, so the last one is reused. */
|
|
6409
|
+
private measured?;
|
|
6410
|
+
constructor(host: ReactiveControllerHost & HTMLElement, options: SlashMenuControllerOptions);
|
|
6411
|
+
/** Whether the menu is currently showing. */
|
|
6412
|
+
get open(): boolean;
|
|
6413
|
+
hostConnected(): void;
|
|
6414
|
+
hostDisconnected(): void;
|
|
6415
|
+
/** Starts watching a field. Safe to call repeatedly with the same field. */
|
|
6416
|
+
attach(field: TextField): void;
|
|
6417
|
+
/** Stops watching the current field and closes the menu. */
|
|
6418
|
+
detach(): void;
|
|
6419
|
+
private addListeners;
|
|
6420
|
+
private removeListeners;
|
|
6421
|
+
/** Closes the menu without marking the trigger as dismissed. */
|
|
6422
|
+
close(): void;
|
|
6423
|
+
/** Opens the menu at the caret, as a toolbar button or keyboard shortcut would. */
|
|
6424
|
+
requestOpen(): void;
|
|
6425
|
+
private caretRect;
|
|
6426
|
+
private readonly handleInput;
|
|
6427
|
+
private readonly handleCaretMove;
|
|
6428
|
+
private readonly handleKeyUp;
|
|
6429
|
+
private readonly handleBlur;
|
|
6430
|
+
private readonly handleScroll;
|
|
6431
|
+
private readonly handleKeyDown;
|
|
6432
|
+
private readonly handleItemSelect;
|
|
6433
|
+
private detect;
|
|
6434
|
+
private resolve;
|
|
6435
|
+
private select;
|
|
6436
|
+
private replace;
|
|
6437
|
+
}
|
|
6438
|
+
}
|
|
6439
|
+
declare module "components/slash-item/slash-item.component" {
|
|
6440
|
+
import ZincElement from "internal/zinc-element";
|
|
6441
|
+
import type { CSSResultGroup } from 'lit';
|
|
6442
|
+
import type { SlashMenuItem } from "components/slash-menu/slash-menu-items";
|
|
6443
|
+
/**
|
|
6444
|
+
* @summary Declares a single insertion for a slash menu. Renders nothing itself — it describes an
|
|
6445
|
+
* entry for the component it is slotted into, e.g. `<zn-textarea>`'s `slash-items` slot.
|
|
6446
|
+
* @documentation https://zinc.style/components/slash-item
|
|
6447
|
+
* @status experimental
|
|
6448
|
+
* @since 1.1
|
|
6449
|
+
*
|
|
6450
|
+
* @slot - The text to insert, for values that are long or span multiple lines. Ignored when the
|
|
6451
|
+
* `value` attribute is set.
|
|
6452
|
+
*/
|
|
6453
|
+
export default class ZnSlashItem extends ZincElement {
|
|
6454
|
+
static styles: CSSResultGroup;
|
|
6455
|
+
/** The text shown in the menu. */
|
|
6456
|
+
label: string;
|
|
6457
|
+
/** The text inserted into the field. Falls back to this element's text content. */
|
|
6458
|
+
value: string;
|
|
6459
|
+
/** Icon shown against the item, e.g. `tag@lu`. */
|
|
6460
|
+
icon: string;
|
|
6461
|
+
/** Supporting text shown under the label. */
|
|
6462
|
+
description: string;
|
|
6463
|
+
/** Extra terms the item can be found by, comma separated. */
|
|
6464
|
+
keywords: string;
|
|
6465
|
+
/** Heading the item is listed under. */
|
|
6466
|
+
group: string;
|
|
6467
|
+
/** Overrides the item's position in the menu. Lower sorts first. */
|
|
6468
|
+
order: number;
|
|
6469
|
+
/** Where the caret lands after insertion, as an offset into the inserted value. */
|
|
6470
|
+
caretOffset: number;
|
|
6471
|
+
/** Identifier passed through on `zn-slash-select`, for items that do something other than insert. */
|
|
6472
|
+
action: string;
|
|
6473
|
+
/** Listed, but not selectable. */
|
|
6474
|
+
disabled: boolean;
|
|
6475
|
+
/** The item as the slash menu consumes it. */
|
|
6476
|
+
toSlashMenuItem(): SlashMenuItem;
|
|
6477
|
+
private get insertValue();
|
|
6478
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
6479
|
+
}
|
|
6480
|
+
}
|
|
6481
|
+
declare module "components/slash-item/index" {
|
|
6482
|
+
import ZnSlashItem from "components/slash-item/slash-item.component";
|
|
6483
|
+
export * from "components/slash-item/slash-item.component";
|
|
6484
|
+
export default ZnSlashItem;
|
|
6485
|
+
global {
|
|
6486
|
+
interface HTMLElementTagNameMap {
|
|
6487
|
+
'zn-slash-item': ZnSlashItem;
|
|
6488
|
+
}
|
|
6489
|
+
}
|
|
6490
|
+
}
|
|
6491
|
+
declare module "components/slash-menu/index" {
|
|
6492
|
+
import ZnSlashMenu from "components/slash-menu/slash-menu.component";
|
|
6493
|
+
export * from "components/slash-menu/slash-menu.component";
|
|
6494
|
+
export * from "components/slash-menu/slash-menu-controller";
|
|
6495
|
+
export * from "components/slash-menu/slash-menu-items";
|
|
6496
|
+
export default ZnSlashMenu;
|
|
6497
|
+
global {
|
|
6498
|
+
interface HTMLElementTagNameMap {
|
|
6499
|
+
'zn-slash-menu': ZnSlashMenu;
|
|
6500
|
+
}
|
|
6501
|
+
}
|
|
6502
|
+
}
|
|
6209
6503
|
declare module "components/textarea/textarea.component" {
|
|
6210
6504
|
import { type CSSResultGroup } from 'lit';
|
|
6505
|
+
import { type SlashMenuItem } from "components/slash-menu/slash-menu-items";
|
|
6211
6506
|
import ZincElement, { type ZincFormControl } from "internal/zinc-element";
|
|
6507
|
+
import ZnSlashItem from "components/slash-item/index";
|
|
6508
|
+
import ZnSlashMenu from "components/slash-menu/index";
|
|
6212
6509
|
/**
|
|
6213
6510
|
* @summary Textareas collect data from the user and allow multiple lines of text.
|
|
6214
6511
|
* @documentation https://zinc.style/components/textarea
|
|
@@ -6219,12 +6516,22 @@ declare module "components/textarea/textarea.component" {
|
|
|
6219
6516
|
* @slot label-tooltip - Used to add text that is displayed in a tooltip next to the label. Alternatively, you can use the `label-tooltip` attribute.
|
|
6220
6517
|
* @slot context-note - Used to add contextual text that is displayed above the textarea, on the right. Alternatively, you can use the `context-note` attribute.
|
|
6221
6518
|
* @slot help-text - Text that describes how to use the input. Alternatively, you can use the `help-text` attribute.
|
|
6519
|
+
* @slot slash-items - `<zn-slash-item>` elements describing the insertions offered by the slash menu. Items are
|
|
6520
|
+
* picked up wherever they sit inside the textarea, so this slot name is optional.
|
|
6521
|
+
* @slot slash-menu - A `<zn-slash-menu>` to use instead of the built-in one, so its heading, sizing and styling can
|
|
6522
|
+
* be set in markup. Any `<zn-slash-item>` children of it become the menu's items.
|
|
6523
|
+
*
|
|
6524
|
+
* @dependency zn-slash-item
|
|
6525
|
+
* @dependency zn-slash-menu
|
|
6222
6526
|
*
|
|
6223
6527
|
* @event zn-blur - Emitted when the control loses focus.
|
|
6224
6528
|
* @event zn-change - Emitted when an alteration to the control's value is committed by the user.
|
|
6225
6529
|
* @event zn-focus - Emitted when the control gains focus.
|
|
6226
6530
|
* @event zn-input - Emitted when the control receives input.
|
|
6227
6531
|
* @event zn-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied.
|
|
6532
|
+
* @event zn-slash-select - Emitted when a slash menu item is chosen. Cancelable — call `preventDefault()` to
|
|
6533
|
+
* suppress the insertion and handle the item yourself.
|
|
6534
|
+
* @event zn-slash-insert - Emitted after a slash menu item's value has been inserted.
|
|
6228
6535
|
*
|
|
6229
6536
|
* @csspart form-control - The form control that wraps the label, input, and help text.
|
|
6230
6537
|
* @csspart form-control-label - The label's wrapper.
|
|
@@ -6232,17 +6539,26 @@ declare module "components/textarea/textarea.component" {
|
|
|
6232
6539
|
* @csspart form-control-help-text - The help text's wrapper.
|
|
6233
6540
|
* @csspart base - The component's base wrapper.
|
|
6234
6541
|
* @csspart textarea - The internal `<textarea>` control.
|
|
6542
|
+
* @csspart slash-menu - The slash menu shown at the caret.
|
|
6235
6543
|
*/
|
|
6236
6544
|
export default class ZnTextarea extends ZincElement implements ZincFormControl {
|
|
6237
6545
|
static styles: CSSResultGroup;
|
|
6546
|
+
static dependencies: {
|
|
6547
|
+
'zn-slash-item': typeof ZnSlashItem;
|
|
6548
|
+
'zn-slash-menu': typeof ZnSlashMenu;
|
|
6549
|
+
};
|
|
6238
6550
|
private readonly formControlController;
|
|
6239
6551
|
private readonly hasSlotController;
|
|
6240
6552
|
private readonly resizeObserver;
|
|
6241
6553
|
/** Ensures we only attempt to derive the initial value from light DOM content once */
|
|
6242
6554
|
private _didInitFromContent;
|
|
6555
|
+
private readonly slashController;
|
|
6243
6556
|
formControl: HTMLElement;
|
|
6244
6557
|
input: HTMLTextAreaElement;
|
|
6558
|
+
slashMenuElement: ZnSlashMenu | null;
|
|
6245
6559
|
hasFocus: boolean;
|
|
6560
|
+
/** Renders the slash menu only once it has been needed, keeping unused textareas cheap. */
|
|
6561
|
+
private hasSlashMenu;
|
|
6246
6562
|
title: string;
|
|
6247
6563
|
/** The name of the textarea, submitted as a name/value pair with form data. */
|
|
6248
6564
|
name: string;
|
|
@@ -6301,6 +6617,23 @@ declare module "components/textarea/textarea.component" {
|
|
|
6301
6617
|
* keyboard on supportive devices.
|
|
6302
6618
|
*/
|
|
6303
6619
|
inputmode: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';
|
|
6620
|
+
/**
|
|
6621
|
+
* Quick insertions offered by the slash menu. Accepts a JSON array of items, or the shorthand
|
|
6622
|
+
* `Brand name={{BRAND_NAME}}, Support email={{SUPPORT_EMAIL}}`. Can also be set as an array of
|
|
6623
|
+
* `SlashMenuItem` objects in JavaScript.
|
|
6624
|
+
*/
|
|
6625
|
+
slashItems: SlashMenuItem[];
|
|
6626
|
+
/** Names of item sets registered with `registerSlashMenuPreset`, comma separated. */
|
|
6627
|
+
slashPreset: string;
|
|
6628
|
+
/** The characters that open the slash menu. */
|
|
6629
|
+
slashTrigger: string;
|
|
6630
|
+
/** The heading shown above the slash menu's items. */
|
|
6631
|
+
slashHeading: string;
|
|
6632
|
+
/**
|
|
6633
|
+
* Resolves additional items each time the menu opens, for lists that come from elsewhere (e.g. an
|
|
6634
|
+
* API). Receives the current query and may return a promise. JavaScript only.
|
|
6635
|
+
*/
|
|
6636
|
+
slashItemsProvider?: (query: string) => SlashMenuItem[] | Promise<SlashMenuItem[]>;
|
|
6304
6637
|
/** The default value of the form control. Primarily used for resetting the form control. */
|
|
6305
6638
|
defaultValue: string;
|
|
6306
6639
|
transparent: boolean;
|
|
@@ -6310,6 +6643,14 @@ declare module "components/textarea/textarea.component" {
|
|
|
6310
6643
|
get validationMessage(): string;
|
|
6311
6644
|
connectedCallback(): void;
|
|
6312
6645
|
firstUpdated(): void;
|
|
6646
|
+
/** The insertions the slash menu offers, gathered from every source, in the order they were declared. */
|
|
6647
|
+
resolveSlashItems(search?: string): Promise<SlashMenuItem[]>;
|
|
6648
|
+
/** Opens the slash menu at the caret, inserting the trigger if it isn't already there. */
|
|
6649
|
+
showSlashMenu(): Promise<void>;
|
|
6650
|
+
/** Closes the slash menu. */
|
|
6651
|
+
hideSlashMenu(): void;
|
|
6652
|
+
private slottedSlashItems;
|
|
6653
|
+
private mountSlashMenu;
|
|
6313
6654
|
private handleBlur;
|
|
6314
6655
|
private handleChange;
|
|
6315
6656
|
private handleFocus;
|
|
@@ -8280,6 +8621,7 @@ declare module "components/audio-select/index" {
|
|
|
8280
8621
|
}
|
|
8281
8622
|
}
|
|
8282
8623
|
declare module "components/translations/translations.component" {
|
|
8624
|
+
import { type SlashMenuItem } from "components/slash-menu/slash-menu-items";
|
|
8283
8625
|
import ZincElement from "internal/zinc-element";
|
|
8284
8626
|
import ZnButton from "components/button/index";
|
|
8285
8627
|
import ZnButtonGroup from "components/button-group/index";
|
|
@@ -8309,6 +8651,19 @@ declare module "components/translations/translations.component" {
|
|
|
8309
8651
|
flush: boolean;
|
|
8310
8652
|
inputType: 'select' | 'text' | 'number' | 'textarea';
|
|
8311
8653
|
textareaRows: number | undefined;
|
|
8654
|
+
/**
|
|
8655
|
+
* Quick insertions offered by the slash menu when `input-type` is `textarea`. Accepts a JSON array of items, or
|
|
8656
|
+
* the shorthand `Brand name={{BRAND_NAME}}, Support email={{SUPPORT_EMAIL}}`. Every language shares the list.
|
|
8657
|
+
*/
|
|
8658
|
+
slashItems: SlashMenuItem[];
|
|
8659
|
+
/** Names of item sets registered with `registerSlashMenuPreset`, comma separated. */
|
|
8660
|
+
slashPreset: string;
|
|
8661
|
+
/** The characters that open the slash menu. */
|
|
8662
|
+
slashTrigger: string;
|
|
8663
|
+
/** The heading shown above the slash menu's items. */
|
|
8664
|
+
slashHeading: string;
|
|
8665
|
+
/** Resolves additional slash menu items each time the menu opens. JavaScript only. */
|
|
8666
|
+
slashItemsProvider?: (query: string) => SlashMenuItem[] | Promise<SlashMenuItem[]>;
|
|
8312
8667
|
/** When true, hides the individual language navbar and defers language control to a parent zn-translation-group. */
|
|
8313
8668
|
grouped: boolean;
|
|
8314
8669
|
languages: Record<string, string>;
|
|
@@ -11103,6 +11458,30 @@ declare module "events/zn-theme-submit" {
|
|
|
11103
11458
|
}
|
|
11104
11459
|
}
|
|
11105
11460
|
}
|
|
11461
|
+
declare module "events/zn-slash-select" {
|
|
11462
|
+
import type { SlashMenuItem } from "components/slash-menu/slash-menu-items";
|
|
11463
|
+
export type ZnSlashSelectEvent = CustomEvent<{
|
|
11464
|
+
item: SlashMenuItem;
|
|
11465
|
+
query: string;
|
|
11466
|
+
}>;
|
|
11467
|
+
global {
|
|
11468
|
+
interface GlobalEventHandlersEventMap {
|
|
11469
|
+
'zn-slash-select': ZnSlashSelectEvent;
|
|
11470
|
+
}
|
|
11471
|
+
}
|
|
11472
|
+
}
|
|
11473
|
+
declare module "events/zn-slash-insert" {
|
|
11474
|
+
import type { SlashMenuItem } from "components/slash-menu/slash-menu-items";
|
|
11475
|
+
export type ZnSlashInsertEvent = CustomEvent<{
|
|
11476
|
+
item: SlashMenuItem;
|
|
11477
|
+
value: string;
|
|
11478
|
+
}>;
|
|
11479
|
+
global {
|
|
11480
|
+
interface GlobalEventHandlersEventMap {
|
|
11481
|
+
'zn-slash-insert': ZnSlashInsertEvent;
|
|
11482
|
+
}
|
|
11483
|
+
}
|
|
11484
|
+
}
|
|
11106
11485
|
declare module "events/events" {
|
|
11107
11486
|
export type { ZnAfterHideEvent } from "events/zn-after-hide";
|
|
11108
11487
|
export type { ZnAfterShowEvent } from "events/zn-after-show";
|
|
@@ -11125,6 +11504,8 @@ declare module "events/events" {
|
|
|
11125
11504
|
export type { ZnPageSelectionChangeEvent } from "events/zn-page-selection-change";
|
|
11126
11505
|
export type { ZnThemeChangeEvent } from "events/zn-theme-change";
|
|
11127
11506
|
export type { ZnThemeSubmitEvent } from "events/zn-theme-submit";
|
|
11507
|
+
export type { ZnSlashSelectEvent } from "events/zn-slash-select";
|
|
11508
|
+
export type { ZnSlashInsertEvent } from "events/zn-slash-insert";
|
|
11128
11509
|
}
|
|
11129
11510
|
declare module "zinc" {
|
|
11130
11511
|
export { default as Button } from "components/button/index";
|
|
@@ -11240,11 +11621,14 @@ declare module "zinc" {
|
|
|
11240
11621
|
export { default as PageSectionCard } from "components/page-builder/modules/page-section-card/index";
|
|
11241
11622
|
export { default as PreviewFrame } from "components/preview-frame/index";
|
|
11242
11623
|
export { default as ThemeEditor } from "components/theme-editor/index";
|
|
11624
|
+
export { default as SlashMenu } from "components/slash-menu/index";
|
|
11625
|
+
export { default as SlashItem } from "components/slash-item/index";
|
|
11243
11626
|
export { default as ZincElement } from "internal/zinc-element";
|
|
11244
11627
|
export * from "utilities/on";
|
|
11245
11628
|
export * from "utilities/query";
|
|
11246
11629
|
export * from "utilities/lit-to-html";
|
|
11247
11630
|
export * from "utilities/form";
|
|
11631
|
+
export * from "utilities/caret-position";
|
|
11248
11632
|
export * from "events/events";
|
|
11249
11633
|
}
|
|
11250
11634
|
declare module "components/editor/modules/events/zn-command-select" {
|