@samtv12345/etherpad-webcomponents 0.0.13 → 0.0.15

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.
Files changed (73) hide show
  1. package/README.md +52 -10
  2. package/dist/EpAvatar.d.ts +25 -0
  3. package/dist/EpAvatar.d.ts.map +1 -0
  4. package/dist/EpAvatar.js +115 -0
  5. package/dist/EpAvatar.js.map +1 -0
  6. package/dist/EpButton.js +4 -4
  7. package/dist/EpCard.js +2 -2
  8. package/dist/EpChatMessage.d.ts.map +1 -1
  9. package/dist/EpChatMessage.js +3 -1
  10. package/dist/EpChatMessage.js.map +1 -1
  11. package/dist/EpChatPanel.d.ts +81 -0
  12. package/dist/EpChatPanel.d.ts.map +1 -0
  13. package/dist/EpChatPanel.js +368 -0
  14. package/dist/EpChatPanel.js.map +1 -0
  15. package/dist/EpCheckbox.d.ts +3 -0
  16. package/dist/EpCheckbox.d.ts.map +1 -1
  17. package/dist/EpCheckbox.js +11 -3
  18. package/dist/EpCheckbox.js.map +1 -1
  19. package/dist/EpColorPicker.js +2 -2
  20. package/dist/EpDropdown.js +2 -2
  21. package/dist/EpDropdownItem.js +1 -1
  22. package/dist/EpInput.js +3 -3
  23. package/dist/EpModal.js +6 -6
  24. package/dist/EpModal.js.map +1 -1
  25. package/dist/EpNotification.js +6 -6
  26. package/dist/EpPopup.d.ts +57 -0
  27. package/dist/EpPopup.d.ts.map +1 -0
  28. package/dist/EpPopup.js +323 -0
  29. package/dist/EpPopup.js.map +1 -0
  30. package/dist/EpSegmented.d.ts +35 -0
  31. package/dist/EpSegmented.d.ts.map +1 -0
  32. package/dist/EpSegmented.js +149 -0
  33. package/dist/EpSegmented.js.map +1 -0
  34. package/dist/EpSelect.js +3 -3
  35. package/dist/EpSettings.d.ts +47 -0
  36. package/dist/EpSettings.d.ts.map +1 -0
  37. package/dist/EpSettings.js +226 -0
  38. package/dist/EpSettings.js.map +1 -0
  39. package/dist/EpTabs.d.ts +64 -0
  40. package/dist/EpTabs.d.ts.map +1 -0
  41. package/dist/EpTabs.js +296 -0
  42. package/dist/EpTabs.js.map +1 -0
  43. package/dist/EpTheme.d.ts +23 -16
  44. package/dist/EpTheme.d.ts.map +1 -1
  45. package/dist/EpTheme.js +91 -64
  46. package/dist/EpTheme.js.map +1 -1
  47. package/dist/EpToast.js +7 -7
  48. package/dist/EpToast.js.map +1 -1
  49. package/dist/EpToolbar.d.ts +90 -0
  50. package/dist/EpToolbar.d.ts.map +1 -0
  51. package/dist/EpToolbar.js +431 -0
  52. package/dist/EpToolbar.js.map +1 -0
  53. package/dist/EpToolbarSelect.js +2 -2
  54. package/dist/EpUserBadge.d.ts.map +1 -1
  55. package/dist/EpUserBadge.js +3 -1
  56. package/dist/EpUserBadge.js.map +1 -1
  57. package/dist/EpUserList.d.ts +52 -0
  58. package/dist/EpUserList.d.ts.map +1 -0
  59. package/dist/EpUserList.js +225 -0
  60. package/dist/EpUserList.js.map +1 -0
  61. package/dist/index.d.ts +13 -1
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +10 -1
  64. package/dist/index.js.map +1 -1
  65. package/dist/internal/color.d.ts +15 -0
  66. package/dist/internal/color.d.ts.map +1 -0
  67. package/dist/internal/color.js +44 -0
  68. package/dist/internal/color.js.map +1 -0
  69. package/dist/themes.d.ts +81 -0
  70. package/dist/themes.d.ts.map +1 -0
  71. package/dist/themes.js +227 -0
  72. package/dist/themes.js.map +1 -0
  73. package/package.json +24 -23
package/README.md CHANGED
@@ -13,8 +13,8 @@ Because they are standard custom elements, the components work in any page or fr
13
13
  ## Install
14
14
 
15
15
  ```bash
16
- pnpm add etherpad-webcomponents
17
- # or: npm install etherpad-webcomponents
16
+ pnpm add @samtv12345/etherpad-webcomponents
17
+ # or: npm install @samtv12345/etherpad-webcomponents
18
18
  ```
19
19
 
20
20
  ## Usage
@@ -23,10 +23,10 @@ Import the whole library, or just the components you need (each is individually
23
23
 
24
24
  ```js
25
25
  // everything
26
- import 'etherpad-webcomponents';
26
+ import '@samtv12345/etherpad-webcomponents';
27
27
 
28
28
  // or a single component
29
- import 'etherpad-webcomponents/EpButton.js';
29
+ import '@samtv12345/etherpad-webcomponents/EpButton.js';
30
30
  ```
31
31
 
32
32
  ```html
@@ -42,7 +42,7 @@ import 'etherpad-webcomponents/EpButton.js';
42
42
  The named exports (classes) are also available for programmatic use:
43
43
 
44
44
  ```js
45
- import { EpButton, EpTheme, themes } from 'etherpad-webcomponents';
45
+ import { EpButton, EpTheme, themes } from '@samtv12345/etherpad-webcomponents';
46
46
  ```
47
47
 
48
48
  ---
@@ -64,18 +64,60 @@ import { EpButton, EpTheme, themes } from 'etherpad-webcomponents';
64
64
  | `<ep-toast-container>` / `<ep-toast-item>` | `EpToastContainer` / `EpToastItem` | `position`, `type`, `message`, `duration` | — |
65
65
  | `<ep-toolbar-select>` | `EpToolbarSelect` | `options[]`, `value`, `icon-class`, `label`, `placeholder` | `ep-toolbar-select:change` |
66
66
  | `<ep-user-badge>` | `EpUserBadge` | `name`, `color`, `size`, `online` | — |
67
- | `<ep-theme>` | `EpTheme` | `name` — applies a token set to its subtree | — |
67
+ | `<ep-avatar>` | `EpAvatar` | `name`, `color`, `src`, `size`, `status` (`online`/`idle`/`offline`) | — |
68
+ | `<ep-toolbar>` / `<ep-toolbar-button>` / `<ep-toolbar-separator>` | `EpToolbar` / `EpToolbarButton` / `EpToolbarSeparator` | toolbar: `label`, `breakpoint`, `more-label`, slot `end`; button: `key`, `label`, `toggle`, `pressed`, `active`, `expanded`, `badge`, `priority="low"` | `ep-toolbar-action` |
69
+ | `<ep-user-list>` | `EpUserList` | `.users` (`{ id, name, color, self, status }`), `heading`, `selectable`, `readonly` | `ep-user-rename`, `ep-user-color-request`, `ep-user-select` |
70
+ | `<ep-chat-panel>` | `EpChatPanel` | `.messages` or slotted `<ep-chat-message slot="messages">`, `show-close`, `show-sticky`, `sticky`, `has-more`, `loading`, `readonly`, `floating` | `ep-chat-send`, `ep-chat-close`, `ep-chat-sticky`, `ep-chat-load-more` |
71
+ | `<ep-popup>` | `EpPopup` | `open`, `heading`, `anchor`, `align`, `persistent`, slot `footer`; `show()`/`hide()`/`toggle()` | `ep-popup-open`, `ep-popup-close` |
72
+ | `<ep-settings-section>` / `<ep-settings-row>` | `EpSettingsSection` / `EpSettingsRow` | section: `heading`, `description`; row: `label`, `description`, `stacked`, `divided`, `disabled` | — |
73
+ | `<ep-segmented>` | `EpSegmented` | `.options` (`{ value, label, icon?, disabled? }`), `value`, `label` | `ep-change` |
74
+ | `<ep-tabs>` / `<ep-tab>` | `EpTabs` / `EpTab` | `value`, `variant` (`underline`/`pills`); tab: `value`, `label`, `disabled` | `ep-tab-change` |
75
+ | `<ep-theme>` | `EpTheme` | `name` (incl. `auto`), `light`, `dark`, `.tokens` — applies a token set to its subtree | `ep-theme-change` |
68
76
  | `<ep-editor>` | `EpEditor` | `content`, `readonly`, `wrap`, `author-id` | `ready`, `content-changed`, `selection-changed` |
69
77
 
70
78
  ### Theming
71
79
 
72
- Components read CSS custom properties (`--text-color`, `--primary-color`, `--bg-soft-color`, …). Wrap a subtree in `<ep-theme name="…">` to apply a token set. Built-in themes: **`colibris`** (default, matches Etherpad's skin), **`colibris-dark`**, **`high-contrast`**, and **`warm`**. Register your own at runtime:
80
+ Components only read CSS custom properties, so every colour, radius and shadow can be changed without touching the components. Built-in themes: **`colibris`** (default, Etherpad's light-green skin), **`colibris-dark`**, **`high-contrast`** and **`warm`**.
81
+
82
+ | Token | Used for |
83
+ | --- | --- |
84
+ | `--bg-color`, `--bg-soft-color`, `--light-color`, `--super-light-color` | surfaces |
85
+ | `--text-color`, `--text-soft-color`, `--dark-color`, `--super-dark-color` | text, icons |
86
+ | `--middle-color` | borders |
87
+ | `--primary-color`, `--primary-text-color` | accent and text on the accent |
88
+ | `--danger-color`, `--success-color`, `--warning-color` | states |
89
+ | `--focus-color` | focus ring |
90
+ | `--radius`, `--radius-large`, `--shadow` | shape and elevation |
91
+ | `--main-font-family` | font |
92
+
93
+ A theme only needs to state what differs from its base:
73
94
 
74
95
  ```js
75
- import { EpTheme } from 'etherpad-webcomponents';
76
- EpTheme.registerTheme('brand', { '--primary-color': '#ff5722', /* …all ThemeTokens */ });
96
+ import { defineTheme } from '@samtv12345/etherpad-webcomponents';
97
+
98
+ defineTheme('acme', { '--primary-color': '#7c3aed' }); // based on colibris
99
+ defineTheme('acme-dark', { '--primary-color': '#a78bfa' }, 'colibris-dark');
100
+ ```
101
+
102
+ ```html
103
+ <!-- fixed theme -->
104
+ <ep-theme name="acme">…</ep-theme>
105
+
106
+ <!-- follow the operating system -->
107
+ <ep-theme name="auto" light="acme" dark="acme-dark">…</ep-theme>
77
108
  ```
78
109
 
110
+ `<ep-theme>` sets `data-scheme="light|dark"` on itself, fires `ep-theme-change` and updates live when a theme is redefined. Single tokens can be overridden per element with the `tokens` property. Without the element:
111
+
112
+ - `applyTheme(document.documentElement, 'acme')` sets the tokens on any element (and removes tokens of the previous call that the new set lacks),
113
+ - `themeToCss('acme', ':root')` returns the tokens as a CSS rule, e.g. for rendering them server-side.
114
+
115
+ `@samtv12345/etherpad-webcomponents/themes.js` contains only these functions and the token sets, without any custom element.
116
+
117
+ ### Pad building blocks
118
+
119
+ The pad, timeslider and sheet pages are put together from `ep-toolbar`, `ep-popup` + `ep-settings-*`, `ep-user-list` and `ep-chat-panel`; the story **Pad/Layout** shows them together. All of them only emit events – the app decides what a toolbar action, a sent chat message or a rename does. Every visible text is an attribute, so pages can pass in their translations. Toolbar colours can be set separately via `--toolbar-bg-color`, `--toolbar-text-color`, `--toolbar-border-color`, `--toolbar-hover-color`, `--toolbar-active-color` and `--toolbar-active-text-color`.
120
+
79
121
  ### The editor (`<ep-editor>`)
80
122
 
81
123
  `<ep-editor>` embeds Etherpad's Ace editor engine (under `src/editor/`: `Changeset`, `AttributePool`, `changesettracker`, content collector, op assemblers, etc.) as a self-contained element. It supports bold/italic/underline/strikethrough, ordered & unordered lists, indentation, undo/redo, and changeset-based collaboration.
@@ -99,7 +141,7 @@ const pending = ed.prepareUserChangeset(); // { changeset, apool } to send to
99
141
  The lower-level engine pieces are also exported for advanced use:
100
142
 
101
143
  ```js
102
- import { AceEditor, AttributePool, makeChangesetTracker } from 'etherpad-webcomponents';
144
+ import { AceEditor, AttributePool, makeChangesetTracker } from '@samtv12345/etherpad-webcomponents';
103
145
  ```
104
146
 
105
147
  ---
@@ -0,0 +1,25 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ * Round user avatar: a picture if `src` is set and loads, otherwise the
4
+ * initials on the author colour (with readable text colour).
5
+ */
6
+ export declare class EpAvatar extends LitElement {
7
+ static styles: import("lit").CSSResult;
8
+ name: string;
9
+ /** Background colour (author colour). */
10
+ color: string;
11
+ /** Optional picture URL. */
12
+ src: string;
13
+ size: 'small' | 'medium' | 'large';
14
+ /** Small status dot: `online`, `idle`, `offline` or empty for none. */
15
+ status: '' | 'online' | 'idle' | 'offline';
16
+ private _imgFailed;
17
+ updated(changed: Map<string, unknown>): void;
18
+ render(): import("lit-html").TemplateResult<1>;
19
+ }
20
+ declare global {
21
+ interface HTMLElementTagNameMap {
22
+ 'ep-avatar': EpAvatar;
23
+ }
24
+ }
25
+ //# sourceMappingURL=EpAvatar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EpAvatar.d.ts","sourceRoot":"","sources":["../src/EpAvatar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAKrD;;;GAGG;AACH,qBACa,QAAS,SAAQ,UAAU;IACtC,MAAM,CAAC,MAAM,0BA4CX;IAEU,IAAI,SAAM;IACtB,yCAAyC;IAC7B,KAAK,SAAM;IACvB,4BAA4B;IAChB,GAAG,SAAM;IACQ,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAY;IAC3E,uEAAuE;IAC1C,MAAM,EAAE,EAAE,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAM;IAEpE,OAAO,CAAC,UAAU,CAAS;IAEpC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAIrC,MAAM;CAeP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
@@ -0,0 +1,115 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { LitElement, html, css, nothing } from 'lit';
8
+ import { customElement, property, state } from 'lit/decorators.js';
9
+ import { styleMap } from 'lit/directives/style-map.js';
10
+ import { initialsOf, readableTextOn, safeColor } from './internal/color.js';
11
+ /**
12
+ * Round user avatar: a picture if `src` is set and loads, otherwise the
13
+ * initials on the author colour (with readable text colour).
14
+ */
15
+ let EpAvatar = class EpAvatar extends LitElement {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.name = '';
19
+ /** Background colour (author colour). */
20
+ this.color = '';
21
+ /** Optional picture URL. */
22
+ this.src = '';
23
+ this.size = 'medium';
24
+ /** Small status dot: `online`, `idle`, `offline` or empty for none. */
25
+ this.status = '';
26
+ this._imgFailed = false;
27
+ }
28
+ updated(changed) {
29
+ if (changed.has('src'))
30
+ this._imgFailed = false;
31
+ }
32
+ render() {
33
+ const color = safeColor(this.color);
34
+ const bg = color || 'var(--text-soft-color, #576273)';
35
+ const fg = color ? readableTextOn(color) : 'var(--bg-color, #ffffff)';
36
+ const showImg = this.src && !this._imgFailed;
37
+ return html `
38
+ <div class="circle" part="circle" role="img" aria-label=${this.name || nothing}
39
+ style=${styleMap({ background: bg, color: fg })}>
40
+ ${showImg
41
+ ? html `<img src=${this.src} alt="" @error=${() => { this._imgFailed = true; }} />`
42
+ : html `<span aria-hidden="true">${initialsOf(this.name)}</span>`}
43
+ </div>
44
+ ${this.status ? html `<span class="status ${this.status}" part="status"></span>` : nothing}
45
+ `;
46
+ }
47
+ };
48
+ EpAvatar.styles = css `
49
+ :host {
50
+ --ep-avatar-size: 28px;
51
+ display: inline-block;
52
+ position: relative;
53
+ width: var(--ep-avatar-size);
54
+ height: var(--ep-avatar-size);
55
+ flex-shrink: 0;
56
+ font-family: var(--main-font-family, Quicksand, Cantarell, "Open Sans", "Helvetica Neue", sans-serif);
57
+ }
58
+ :host([size="small"]) { --ep-avatar-size: 20px; }
59
+ :host([size="large"]) { --ep-avatar-size: 40px; }
60
+
61
+ .circle {
62
+ width: 100%;
63
+ height: 100%;
64
+ border-radius: 50%;
65
+ overflow: hidden;
66
+ display: flex;
67
+ align-items: center;
68
+ justify-content: center;
69
+ font-weight: 700;
70
+ font-size: calc(var(--ep-avatar-size) * 0.4);
71
+ line-height: 1;
72
+ user-select: none;
73
+ box-sizing: border-box;
74
+ }
75
+ img { width: 100%; height: 100%; object-fit: cover; display: block; }
76
+
77
+ .status {
78
+ position: absolute;
79
+ right: -1px;
80
+ bottom: -1px;
81
+ width: calc(var(--ep-avatar-size) * 0.3);
82
+ height: calc(var(--ep-avatar-size) * 0.3);
83
+ min-width: 7px;
84
+ min-height: 7px;
85
+ border-radius: 50%;
86
+ border: 2px solid var(--bg-color, #ffffff);
87
+ box-sizing: content-box;
88
+ }
89
+ .status.online { background: var(--success-color, var(--primary-color, #64d29b)); }
90
+ .status.idle { background: var(--warning-color, #d4a72c); }
91
+ .status.offline { background: var(--middle-color, #d2d2d2); }
92
+ `;
93
+ __decorate([
94
+ property()
95
+ ], EpAvatar.prototype, "name", void 0);
96
+ __decorate([
97
+ property()
98
+ ], EpAvatar.prototype, "color", void 0);
99
+ __decorate([
100
+ property()
101
+ ], EpAvatar.prototype, "src", void 0);
102
+ __decorate([
103
+ property({ reflect: true })
104
+ ], EpAvatar.prototype, "size", void 0);
105
+ __decorate([
106
+ property({ reflect: true })
107
+ ], EpAvatar.prototype, "status", void 0);
108
+ __decorate([
109
+ state()
110
+ ], EpAvatar.prototype, "_imgFailed", void 0);
111
+ EpAvatar = __decorate([
112
+ customElement('ep-avatar')
113
+ ], EpAvatar);
114
+ export { EpAvatar };
115
+ //# sourceMappingURL=EpAvatar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EpAvatar.js","sourceRoot":"","sources":["../src/EpAvatar.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE5E;;;GAGG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU;IAAjC;;QA+CO,SAAI,GAAG,EAAE,CAAC;QACtB,yCAAyC;QAC7B,UAAK,GAAG,EAAE,CAAC;QACvB,4BAA4B;QAChB,QAAG,GAAG,EAAE,CAAC;QACQ,SAAI,GAAiC,QAAQ,CAAC;QAC3E,uEAAuE;QAC1C,WAAM,GAAuC,EAAE,CAAC;QAE5D,eAAU,GAAG,KAAK,CAAC;IAqBtC,CAAC;IAnBC,OAAO,CAAC,OAA6B;QACnC,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAClD,CAAC;IAED,MAAM;QACJ,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC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@ EpButton.styles = css `
40
40
  button {
41
41
  font-family: var(--ep-font);
42
42
  padding: 5px 20px;
43
- border-radius: 4px;
43
+ border-radius: var(--radius, 4px);
44
44
  font-size: 14px;
45
45
  font-weight: 700;
46
46
  cursor: pointer;
@@ -62,7 +62,7 @@ EpButton.styles = css `
62
62
  }
63
63
 
64
64
  button:focus-visible {
65
- outline: 2px solid var(--dark-color, #576273);
65
+ outline: 2px solid var(--focus-color, var(--dark-color, #576273));
66
66
  outline-offset: 2px;
67
67
  }
68
68
 
@@ -87,7 +87,7 @@ EpButton.styles = css `
87
87
  background with bg-coloured (white) text. */
88
88
  :host([variant="primary"]) button {
89
89
  background: var(--primary-color, #64d29b);
90
- color: var(--bg-color, #ffffff);
90
+ color: var(--primary-text-color, var(--bg-color, #ffffff));
91
91
  border: none;
92
92
  transition: filter 0.15s ease, opacity 0.15s ease;
93
93
  }
@@ -118,7 +118,7 @@ EpButton.styles = css `
118
118
  color: var(--text-color, #485365);
119
119
  border: none;
120
120
  padding: 4px;
121
- border-radius: 3px;
121
+ border-radius: calc(var(--radius, 4px) - 1px);
122
122
  min-width: 28px;
123
123
  min-height: 28px;
124
124
  justify-content: center;
package/dist/EpCard.js CHANGED
@@ -45,8 +45,8 @@ EpCard.styles = css `
45
45
 
46
46
  .card {
47
47
  background: var(--bg-color, white);
48
- border-radius: 5px;
49
- box-shadow: 0 0 0 1px rgba(99, 114, 130, 0.16), 0 8px 16px rgba(27, 39, 51, 0.08);
48
+ border-radius: var(--radius-large, 5px);
49
+ box-shadow: var(--shadow, 0 0 0 1px rgba(99, 114, 130, 0.16), 0 8px 16px rgba(27, 39, 51, 0.08));
50
50
  overflow: hidden;
51
51
  }
52
52
 
@@ -1 +1 @@
1
- {"version":3,"file":"EpChatMessage.d.ts","sourceRoot":"","sources":["../src/EpChatMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAG5C,qBACa,aAAc,SAAQ,UAAU;IAC3C,MAAM,CAAC,MAAM,0BAmCX;IAEU,MAAM,SAAM;IACiB,WAAW,SAAM;IAC9C,IAAI,SAAM;IACsB,GAAG,UAAS;IAExD,MAAM;CAKP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,aAAa,CAAC;KAClC;CACF"}
1
+ {"version":3,"file":"EpChatMessage.d.ts","sourceRoot":"","sources":["../src/EpChatMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAK5C,qBACa,aAAc,SAAQ,UAAU;IAC3C,MAAM,CAAC,MAAM,0BAmCX;IAEU,MAAM,SAAM;IACiB,WAAW,SAAM;IAC9C,IAAI,SAAM;IACsB,GAAG,UAAS;IAExD,MAAM;CAKP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,aAAa,CAAC;KAClC;CACF"}
@@ -6,6 +6,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { LitElement, html, css } from 'lit';
8
8
  import { customElement, property } from 'lit/decorators.js';
9
+ import { styleMap } from 'lit/directives/style-map.js';
10
+ import { safeColor } from './internal/color.js';
9
11
  let EpChatMessage = class EpChatMessage extends LitElement {
10
12
  constructor() {
11
13
  super(...arguments);
@@ -16,7 +18,7 @@ let EpChatMessage = class EpChatMessage extends LitElement {
16
18
  }
17
19
  render() {
18
20
  return html `
19
- <b class="author" style="${this.authorColor ? `color: ${this.authorColor}` : ''}">${this.author}</b>${this.time ? html `<span class="time">${this.time}</span>` : html `<span class="time"></span>`}<span class="body"><slot></slot></span>
21
+ <b class="author" style=${styleMap({ color: safeColor(this.authorColor) })}>${this.author}</b>${this.time ? html `<span class="time">${this.time}</span>` : html `<span class="time"></span>`}<span class="body"><slot></slot></span>
20
22
  `;
21
23
  }
22
24
  };
@@ -1 +1 @@
1
- {"version":3,"file":"EpChatMessage.js","sourceRoot":"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C;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGzC,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,UAAU;IAAtC;;QAsCO,WAAM,GAAG,EAAE,CAAC;QACiB,gBAAW,GAAG,EAAE,CAAC;QAC9C,SAAI,GAAG,EAAE,CAAC;QACsB,QAAG,GAAG,KAAK,CAAC;IAO1D,CAAC;IALC,MAAM;QACJ,OAAO,IAAI,CAAA;gCACiB,QAAQ,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA,sBAAsB,IAAI,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,CAAA,4BAA4B;KAC5L,CAAC;IACJ,CAAC;;AA9CM,oBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmClB,AAnCY,CAmCX;AAEU;IAAX,QAAQ,EAAE;6CAAa;AACiB;IAAxC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;kDAAkB;AAC9C;IAAX,QAAQ,EAAE;2CAAW;AACsB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAa;AAzC7C,aAAa;IADzB,aAAa,CAAC,iBAAiB,CAAC;GACpB,aAAa,CAgDzB"}
@@ -0,0 +1,81 @@
1
+ import { LitElement } from 'lit';
2
+ import './EpChatMessage.js';
3
+ export interface EpChatEntry {
4
+ id?: string;
5
+ author: string;
6
+ authorColor?: string;
7
+ time?: string;
8
+ text: string;
9
+ own?: boolean;
10
+ }
11
+ /**
12
+ * Chat box: header, scrolling message list and input.
13
+ *
14
+ * Messages come either from the `messages` property or as
15
+ * `<ep-chat-message>` children (slot `messages`), whatever suits the app.
16
+ * The list stays at the bottom when new messages arrive, unless the user
17
+ * scrolled up.
18
+ *
19
+ * Events: `ep-chat-send` (detail `{ text }`), `ep-chat-close`,
20
+ * `ep-chat-sticky` (detail `{ sticky }`), `ep-chat-load-more` (scrolled to
21
+ * the top while `has-more` is set).
22
+ */
23
+ export declare class EpChatPanel extends LitElement {
24
+ static styles: import("lit").CSSResult;
25
+ heading: string;
26
+ messages: EpChatEntry[];
27
+ placeholder: string;
28
+ sendLabel: string;
29
+ closeLabel: string;
30
+ stickyLabel: string;
31
+ emptyLabel: string;
32
+ loadingLabel: string;
33
+ /** Shows the sticky (pin) button and its state. */
34
+ sticky: boolean;
35
+ showSticky: boolean;
36
+ showClose: boolean;
37
+ /** Card look with shadow, for a floating chat box. */
38
+ floating: boolean;
39
+ /** Older messages can be loaded (`ep-chat-load-more` at the top). */
40
+ hasMore: boolean;
41
+ /** Set while older messages are loading. */
42
+ loading: boolean;
43
+ /** Hides the input (read-only pad or chat disabled). */
44
+ readonly: boolean;
45
+ maxlength: number;
46
+ private _log;
47
+ private _input?;
48
+ private _atBottom;
49
+ private _loadingOlder;
50
+ private _resize?;
51
+ /** Message that stays in place while the reader is scrolled up. */
52
+ private _anchor?;
53
+ private _slotted;
54
+ /** Focuses the input. */
55
+ focus(options?: FocusOptions): void;
56
+ /** Scrolls to the newest message. */
57
+ scrollToBottom(): void;
58
+ protected firstUpdated(): void;
59
+ disconnectedCallback(): void;
60
+ protected updated(changed: Map<string, unknown>): void;
61
+ /** Waits until the message elements have rendered, then keeps position. */
62
+ private _afterRender;
63
+ private _messageElements;
64
+ /** At the bottom: follow new messages. Scrolled up: keep the anchor still. */
65
+ private _keepPosition;
66
+ private _offsetOf;
67
+ private _recordAnchor;
68
+ private _onSlotChange;
69
+ private _onScroll;
70
+ private _send;
71
+ private _onKeydown;
72
+ private _autosize;
73
+ private _toggleSticky;
74
+ render(): import("lit-html").TemplateResult<1>;
75
+ }
76
+ declare global {
77
+ interface HTMLElementTagNameMap {
78
+ 'ep-chat-panel': EpChatPanel;
79
+ }
80
+ }
81
+ //# sourceMappingURL=EpChatPanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EpChatPanel.d.ts","sourceRoot":"","sources":["../src/EpChatPanel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAGrD,OAAO,oBAAoB,CAAC;AAE5B,MAAM,WAAW,WAAW;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;;;;;;;;;;GAWG;AACH,qBACa,WAAY,SAAQ,UAAU;IACzC,MAAM,CAAC,MAAM,0BAqGX;IAEU,OAAO,SAAU;IACG,QAAQ,EAAE,WAAW,EAAE,CAAM;IACjD,WAAW,SAAqB;IACL,SAAS,SAAU;IAClB,UAAU,SAAW;IACpB,WAAW,SAAoB;IAChC,UAAU,SAAM;IACd,YAAY,SAAc;IACpE,mDAAmD;IACP,MAAM,UAAS;IACJ,UAAU,UAAS;IACpB,SAAS,UAAS;IACxE,sDAAsD;IACV,QAAQ,UAAS;IAC7D,qEAAqE;IACjB,OAAO,UAAS;IACpE,4CAA4C;IACf,OAAO,UAAS;IAC7C,wDAAwD;IACZ,QAAQ,UAAS;IACjC,SAAS,SAAQ;IAE9B,OAAO,CAAC,IAAI,CAAe;IACvB,OAAO,CAAC,MAAM,CAAC,CAAsB;IAExD,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,OAAO,CAAC,CAAiB;IACjC,mEAAmE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