@h-k-dev/angular-email-editor 0.0.6 → 0.0.8
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 +2 -1
- package/fesm2022/h-k-dev-angular-email-editor-toggle-button-group.mjs +342 -0
- package/fesm2022/h-k-dev-angular-email-editor-toggle-button-group.mjs.map +1 -0
- package/fesm2022/h-k-dev-angular-email-editor.mjs +1591 -110
- package/fesm2022/h-k-dev-angular-email-editor.mjs.map +1 -1
- package/package.json +5 -1
- package/types/h-k-dev-angular-email-editor-toggle-button-group.d.ts +172 -0
- package/types/h-k-dev-angular-email-editor.d.ts +502 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-k-dev/angular-email-editor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "An email editor for Angular on ProseMirror — a visual composer and an HTML source editor over one schema that is the vocabulary of email HTML.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "h-k-dev",
|
|
@@ -131,6 +131,10 @@
|
|
|
131
131
|
"./suggestion-menu": {
|
|
132
132
|
"types": "./types/h-k-dev-angular-email-editor-suggestion-menu.d.ts",
|
|
133
133
|
"default": "./fesm2022/h-k-dev-angular-email-editor-suggestion-menu.mjs"
|
|
134
|
+
},
|
|
135
|
+
"./toggle-button-group": {
|
|
136
|
+
"types": "./types/h-k-dev-angular-email-editor-toggle-button-group.d.ts",
|
|
137
|
+
"default": "./fesm2022/h-k-dev-angular-email-editor-toggle-button-group.mjs"
|
|
134
138
|
}
|
|
135
139
|
},
|
|
136
140
|
"sideEffects": false,
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { InjectionToken, Signal } from '@angular/core';
|
|
3
|
+
import { FormValueControl } from '@angular/forms/signals';
|
|
4
|
+
|
|
5
|
+
/** What an item needs of the group it stands in — `hk-tgb` provides it, so
|
|
6
|
+
an item finds its group without importing it. */
|
|
7
|
+
interface ToggleButtonGroupHost<T = unknown> {
|
|
8
|
+
readonly value: Signal<T>;
|
|
9
|
+
readonly disabled: Signal<boolean>;
|
|
10
|
+
readonly tabStop: Signal<ToggleButtonGroupItem<T> | undefined>;
|
|
11
|
+
select(value: T): void;
|
|
12
|
+
}
|
|
13
|
+
declare const TOGGLE_BUTTON_GROUP: InjectionToken<ToggleButtonGroupHost<unknown>>;
|
|
14
|
+
/**
|
|
15
|
+
* What every choice of an `hk-tgb` is, whichever shape it wears — the
|
|
16
|
+
* group finds its items by this class. Use one of the shapes:
|
|
17
|
+
* `hkTgbIcon` (round) or `hkTgbText` (a pill).
|
|
18
|
+
*
|
|
19
|
+
* An item makes its element — a `<button>`, an `<a>`, anything — a `radio`
|
|
20
|
+
* that carries a `value` and is `aria-checked` while the group holds it.
|
|
21
|
+
* The element and its content stay the host's: a font icon, a `mat-icon`,
|
|
22
|
+
* an SVG, a word. A click picks it, and Space and Enter do too (the
|
|
23
|
+
* group's keys), so a `<div>` works as well as a button. A `<button>`
|
|
24
|
+
* without a `type` gets `type="button"`, so an item in a form never
|
|
25
|
+
* submits it. `aria-disabled` takes it out of the choices and the arrow
|
|
26
|
+
* keys' way — it stays in the track, so the others keep their places —
|
|
27
|
+
* and stops a disabled link from being followed.
|
|
28
|
+
*/
|
|
29
|
+
declare abstract class ToggleButtonGroupItem<T = unknown> {
|
|
30
|
+
/** What the group's value is while this item is picked. */
|
|
31
|
+
readonly value: _angular_core.InputSignal<T>;
|
|
32
|
+
/** This one can't be picked. */
|
|
33
|
+
readonly disabled: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
34
|
+
protected readonly group: ToggleButtonGroupHost<T>;
|
|
35
|
+
readonly element: HTMLElement;
|
|
36
|
+
/** `button` for a `<button>` the host gave no type; the host's own type
|
|
37
|
+
otherwise, and none on any other element. */
|
|
38
|
+
protected readonly type: string | null;
|
|
39
|
+
/** The group holds this item's value. */
|
|
40
|
+
readonly checked: Signal<boolean>;
|
|
41
|
+
/** Out of the choices: its own `aria-disabled`, or the group's. */
|
|
42
|
+
readonly blocked: Signal<boolean>;
|
|
43
|
+
focus(options?: FocusOptions): void;
|
|
44
|
+
protected onClick(event: MouseEvent): void;
|
|
45
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ToggleButtonGroupItem<any>, never>;
|
|
46
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<ToggleButtonGroupItem<any>, never, never, { "value": { "alias": "value"; "required": true; "isSignal": true; }; "disabled": { "alias": "aria-disabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A round choice holding an icon: a circle as wide as the track is tall
|
|
50
|
+
* (`--hk-tgb-size`). The icon sits in a box of the item's own
|
|
51
|
+
* (`[data-slot=icon]`, `--hk-tgb-icon-size`), whose font size and colour it
|
|
52
|
+
* takes: a `mat-icon` marked `inline`, a font icon's `<i>`, or an SVG sized
|
|
53
|
+
* `1em` fits with no rule of the host's. It has no words, so name it:
|
|
54
|
+
* `aria-label` (and a `title` for a tooltip).
|
|
55
|
+
*
|
|
56
|
+
* ```html
|
|
57
|
+
* <button hkTgbIcon value="light" aria-label="Light"><mat-icon inline>light_mode</mat-icon></button>
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* A component on the host's element, not a directive: it brings its own
|
|
61
|
+
* encapsulated look (`:host`), which nothing outside could give an element
|
|
62
|
+
* the host wrote.
|
|
63
|
+
*/
|
|
64
|
+
declare class ToggleButtonGroupIcon<T = unknown> extends ToggleButtonGroupItem<T> {
|
|
65
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ToggleButtonGroupIcon<any>, never>;
|
|
66
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ToggleButtonGroupIcon<any>, "[hkTgbIcon]", ["hkTgbIcon"], {}, {}, never, ["*"], true, never>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A pill-shaped choice holding words — as wide as its text, padded by
|
|
70
|
+
* `--hk-tgb-padding`.
|
|
71
|
+
*
|
|
72
|
+
* ```html
|
|
73
|
+
* <button hkTgbText value="auto">Auto</button>
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare class ToggleButtonGroupText<T = unknown> extends ToggleButtonGroupItem<T> {
|
|
77
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ToggleButtonGroupText<any>, never>;
|
|
78
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ToggleButtonGroupText<any>, "[hkTgbText]", ["hkTgbText"], {}, {}, never, ["*"], true, never>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A toggle button group: one of a few choices on a track, the picked one
|
|
83
|
+
* under a thumb that slides — and changes shape — to whichever is picked
|
|
84
|
+
* next. The pricing page's Monthly | Yearly; a theme's ☀ | ☾ | Auto.
|
|
85
|
+
*
|
|
86
|
+
* ```html
|
|
87
|
+
* <hk-tgb aria-label="Appearance" [(value)]="appearance">
|
|
88
|
+
* <button hkTgbIcon value="light" aria-label="Light"><i class="icon-sun"></i></button>
|
|
89
|
+
* <a hkTgbIcon value="dark" aria-label="Dark" href="?theme=dark"><mat-icon inline>dark_mode</mat-icon></a>
|
|
90
|
+
* <button hkTgbText value="auto">Auto</button>
|
|
91
|
+
* </hk-tgb>
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* **The group is the control; the items are the host's own elements.** Any
|
|
95
|
+
* element becomes a choice by wearing one of two attributes — `hkTgbIcon`,
|
|
96
|
+
* a circle around an icon, or `hkTgbText`, a pill around words — and
|
|
97
|
+
* registers by being content, so the host writes the items as it would
|
|
98
|
+
* plain buttons or links. A pick is all a click does: a group inside a
|
|
99
|
+
* menu leaves the menu open.
|
|
100
|
+
*
|
|
101
|
+
* **A signal-forms control, optionally.** It implements `FormValueControl`:
|
|
102
|
+
* bind a field with `[formField]="settings.theme"` and the directive drives
|
|
103
|
+
* `value` both ways, pushes `disabled`, `readonly`, `required`, `invalid`
|
|
104
|
+
* and `touched` in, and hears `touch` when focus leaves the group. Without
|
|
105
|
+
* a form, `[(value)]` alone is the whole contract. The value is whatever
|
|
106
|
+
* the items carry — strings, an enum, objects — matched by identity; a
|
|
107
|
+
* value no item carries picks none.
|
|
108
|
+
*
|
|
109
|
+
* **Radio semantics.** The group is a `radiogroup`, each item a `radio`
|
|
110
|
+
* with `aria-checked`, and one tab stop: the picked item (the first
|
|
111
|
+
* enabled one while none is). The arrow keys of the group's `orientation`
|
|
112
|
+
* move the pick — Left and Right across, mirrored right to left; Up and
|
|
113
|
+
* Down down a vertical group — Home and End go to the ends, Space and
|
|
114
|
+
* Enter pick in place. The arrows across the other way are left alone for
|
|
115
|
+
* whatever the group sits in: a vertical menu moves on with them. A key
|
|
116
|
+
* the group acted on is spent: it does not travel on to a menu or toolbar
|
|
117
|
+
* around it, whose Space or Enter would act a second time.
|
|
118
|
+
*
|
|
119
|
+
* **The thumb follows the picked item's box.** Items differ in size — a
|
|
120
|
+
* circle, a pill as wide as its words — so the group reads the picked
|
|
121
|
+
* item's box once per pick, and again only when an item resizes (a font
|
|
122
|
+
* arriving, a language switched); the thumb slides there by CSS, its size
|
|
123
|
+
* and corner easing from one shape to the other, and stands still for
|
|
124
|
+
* reduced motion. It takes its first place without sliding.
|
|
125
|
+
*
|
|
126
|
+
* **Each part styles itself, encapsulated.** The group draws the track
|
|
127
|
+
* and the thumb; each item is a component on the host's element and brings
|
|
128
|
+
* its shape with it, so nothing reaches past an encapsulation boundary.
|
|
129
|
+
* Every look is a `--hk-tgb-*` token, defaulting to Material's system
|
|
130
|
+
* tokens, then a light-dark() pair.
|
|
131
|
+
*
|
|
132
|
+
* **State on the host:** `aria-disabled`, `aria-readonly`,
|
|
133
|
+
* `aria-required`, `aria-invalid` (invalid *and* touched, so nothing
|
|
134
|
+
* shouts early), `data-orientation`, and `data-empty` while nothing is
|
|
135
|
+
* picked. No Material, no icon font, no headless library.
|
|
136
|
+
*/
|
|
137
|
+
declare class ToggleButtonGroup<T = unknown> implements FormValueControl<T> {
|
|
138
|
+
#private;
|
|
139
|
+
/** The picked item's value. Two-way; the form's value. */
|
|
140
|
+
readonly value: _angular_core.ModelSignal<T>;
|
|
141
|
+
/** Which way the items line up, and so which arrow keys are the
|
|
142
|
+
group's. */
|
|
143
|
+
readonly orientation: _angular_core.InputSignal<"horizontal" | "vertical">;
|
|
144
|
+
readonly disabled: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
145
|
+
/** The pick holds: the items can be reached and read, not changed. */
|
|
146
|
+
readonly readonly: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
147
|
+
readonly required: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
148
|
+
readonly invalid: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
149
|
+
readonly touched: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
150
|
+
/** Focus left the group. The directive marks the field touched on it. */
|
|
151
|
+
readonly touch: _angular_core.OutputEmitterRef<void>;
|
|
152
|
+
/** The items, in the order they stand. */
|
|
153
|
+
protected readonly items: _angular_core.Signal<readonly ToggleButtonGroupItem<T>[]>;
|
|
154
|
+
/** The item the group's value picks, if any. */
|
|
155
|
+
protected readonly picked: _angular_core.Signal<ToggleButtonGroupItem<T> | undefined>;
|
|
156
|
+
/** The one item Tab lands on: the picked one, else the first that can be
|
|
157
|
+
picked — none while every one is disabled. */
|
|
158
|
+
readonly tabStop: _angular_core.Signal<ToggleButtonGroupItem<T>>;
|
|
159
|
+
constructor();
|
|
160
|
+
/** Picks a value — an item's click, a key. A no-op while disabled or
|
|
161
|
+
read-only. */
|
|
162
|
+
select(value: T): void;
|
|
163
|
+
/** Puts focus on the group's tab stop. */
|
|
164
|
+
focus(options?: FocusOptions): void;
|
|
165
|
+
protected onKeydown(event: KeyboardEvent): void;
|
|
166
|
+
protected onFocusout(event: FocusEvent): void;
|
|
167
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ToggleButtonGroup<any>, never>;
|
|
168
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ToggleButtonGroup<any>, "hk-tgb", never, { "value": { "alias": "value"; "required": true; "isSignal": true; }; "orientation": { "alias": "orientation"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "invalid": { "alias": "invalid"; "required": false; "isSignal": true; }; "touched": { "alias": "touched"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "touch": "touch"; }, ["items"], ["*"], true, never>;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export { TOGGLE_BUTTON_GROUP, ToggleButtonGroup, ToggleButtonGroupIcon, ToggleButtonGroupItem, ToggleButtonGroupText };
|
|
172
|
+
export type { ToggleButtonGroupHost };
|