@penwin/discord-components-core 4.6.0 → 4.7.1

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 (24) hide show
  1. package/custom-elements.json +526 -43
  2. package/dist/bundle/index.mjs +802 -621
  3. package/dist/bundle/index.mjs.map +1 -1
  4. package/dist/bundle/styles/base.css +1 -1
  5. package/dist/components/discord-media-fullscreen-previewer/DiscordMediaFullscreenPreviewer.d.ts +10 -0
  6. package/dist/components/discord-media-fullscreen-previewer/DiscordMediaFullscreenPreviewer.d.ts.map +1 -1
  7. package/dist/components/discord-media-fullscreen-previewer/DiscordMediaFullscreenPreviewer.js +266 -168
  8. package/dist/components/discord-media-fullscreen-previewer/DiscordMediaFullscreenPreviewer.js.map +1 -1
  9. package/dist/components/discord-separator/DiscordSeparator.d.ts +4 -0
  10. package/dist/components/discord-separator/DiscordSeparator.d.ts.map +1 -1
  11. package/dist/components/discord-separator/DiscordSeparator.js +10 -1
  12. package/dist/components/discord-separator/DiscordSeparator.js.map +1 -1
  13. package/dist/components/discord-text-display/DiscordTextDisplay.d.ts.map +1 -1
  14. package/dist/components/discord-text-display/DiscordTextDisplay.js +9 -1
  15. package/dist/components/discord-text-display/DiscordTextDisplay.js.map +1 -1
  16. package/dist/components/discord-text-file-attachment-previewer/DiscordTextFileAttachmentPreviewer.d.ts +91 -15
  17. package/dist/components/discord-text-file-attachment-previewer/DiscordTextFileAttachmentPreviewer.d.ts.map +1 -1
  18. package/dist/components/discord-text-file-attachment-previewer/DiscordTextFileAttachmentPreviewer.js +465 -130
  19. package/dist/components/discord-text-file-attachment-previewer/DiscordTextFileAttachmentPreviewer.js.map +1 -1
  20. package/dist/components/svgs/TextFilePreview.d.ts +25 -0
  21. package/dist/components/svgs/TextFilePreview.d.ts.map +1 -0
  22. package/dist/components/svgs/TextFilePreview.js +69 -0
  23. package/dist/components/svgs/TextFilePreview.js.map +1 -0
  24. package/package.json +1 -1
@@ -14,6 +14,10 @@ import '../discord-custom-emoji/DiscordCustomEmoji.js';
14
14
  let DiscordSeparator = class DiscordSeparator extends LitElement {
15
15
  constructor() {
16
16
  super(...arguments);
17
+ /**
18
+ * Whether a line is drawn, as in Discord's `divider` field. It defaults to `true`, so a
19
+ * plain boolean attribute could never turn it off: `divider="false"` does.
20
+ */
17
21
  this.divider = true;
18
22
  this.spacing = 1;
19
23
  }
@@ -35,7 +39,12 @@ let DiscordSeparator = class DiscordSeparator extends LitElement {
35
39
  }
36
40
  };
37
41
  __decorate([
38
- property({ type: Boolean }),
42
+ property({
43
+ converter: {
44
+ fromAttribute: (value) => value !== 'false',
45
+ toAttribute: (value) => (value ? '' : 'false')
46
+ }
47
+ }),
39
48
  __metadata("design:type", Object)
40
49
  ], DiscordSeparator.prototype, "divider", void 0);
41
50
  __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"DiscordSeparator.js","sourceRoot":"","sources":["../../../src/components/discord-separator/DiscordSeparator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,+CAA+C,CAAC;AAGhD,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,UAAU;IAAzC;;QAgBC,YAAO,GAAG,IAAI,CAAC;QAGf,YAAO,GAAU,CAAC,CAAC;IAK3B,CAAC;IAvBA;;OAEG;aAC6B,WAAM,GAAG,GAAG,CAAA;;;;;;;;;EAS3C,AATqC,CASpC;IAQiB,MAAM;QACxB,OAAO,IAAI,CAAA,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAA,wCAAwC,CAAC,GAAG,CAAC;IAC1F,CAAC;CACD,CAAA;AARO;IADN,QAAQ,CAA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AI,EAAE,CAAC;;iDAChB;AA5Bd,gBAAgB;IAD5B,aAAa,CAAC,mBAAmB,CAAC;GACtB,gBAAgB,CAiC5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"DiscordTextDisplay.d.ts","sourceRoot":"","sources":["../../../src/components/discord-text-display/DiscordTextDisplay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAE5C,OAAO,+CAA+C,CAAC;AAEvD,qBACa,kBAAmB,SAAQ,UAAU;IACjD;;OAEG;IACH,gBAAgC,MAAM,0BAUpC;IAEF,UAAmB,MAAM,oCAExB;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,sBAAsB,EAAE,kBAAkB,CAAC;KAC3C;CACD"}
1
+ {"version":3,"file":"DiscordTextDisplay.d.ts","sourceRoot":"","sources":["../../../src/components/discord-text-display/DiscordTextDisplay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAE5C,OAAO,+CAA+C,CAAC;AAEvD,qBACa,kBAAmB,SAAQ,UAAU;IACjD;;OAEG;IACH,gBAAgC,MAAM,0BAkBpC;IAEF,UAAmB,MAAM,oCAExB;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,sBAAsB,EAAE,kBAAkB,CAAC;KAC3C;CACD"}
@@ -21,9 +21,17 @@ let DiscordTextDisplay = class DiscordTextDisplay extends LitElement {
21
21
  font-family: 'gg sans', 'Noto Sans', Whitney, 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;
22
22
  justify-content: var(--justify-content, flex-start);
23
23
  }
24
+
25
+ /* One block for all the slotted content, so text, formatting and emojis flow inline as they
26
+ do in a message instead of each becoming its own flex row. */
27
+ .discord-text-display-content {
28
+ display: block;
29
+ min-width: 0;
30
+ overflow-wrap: anywhere;
31
+ }
24
32
  `; }
25
33
  render() {
26
- return html `<slot></slot>`;
34
+ return html `<div class="discord-text-display-content"><slot></slot></div>`;
27
35
  }
28
36
  };
29
37
  DiscordTextDisplay = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"DiscordTextDisplay.js","sourceRoot":"","sources":["../../../src/components/discord-text-display/DiscordTextDisplay.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,+CAA+C,CAAC;AAGhD,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,UAAU;IACjD;;OAEG;aAC6B,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;EAU3C,AAVqC,CAUpC;IAEiB,MAAM;QACxB,OAAO,IAAI,CAAA,eAAe,CAAC;IAC5B,CAAC;CACD,CAAA;AAnBY,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CAmB9B"}
1
+ {"version":3,"file":"DiscordTextDisplay.js","sourceRoot":"","sources":["../../../src/components/discord-text-display/DiscordTextDisplay.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,+CAA+C,CAAC;AAGhD,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,UAAU;IACjD;;OAEG;aAC6B,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;EAkB3C,AAlBqC,CAkBpC;IAEiB,MAAM;QACxB,OAAO,IAAI,CAAA,+DAA+D,CAAC;IAC5E,CAAC;CACD,CAAA;AA3BY,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CA2B9B"}
@@ -2,7 +2,6 @@ import { LitElement, type PropertyValues } from 'lit';
2
2
  import type { LightTheme } from '../../types.js';
3
3
  import '../discord-link/DiscordLink.js';
4
4
  export declare class DiscordTextFileAttachmentPreviewer extends LitElement implements LightTheme {
5
- constructor();
6
5
  /**
7
6
  * The name of the file
8
7
  *
@@ -12,7 +11,18 @@ export declare class DiscordTextFileAttachmentPreviewer extends LitElement imple
12
11
  * ```
13
12
  */
14
13
  name: string;
14
+ /**
15
+ * The language used to highlight the content. Viewers can change it from the preview.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * 'ts'
20
+ * ```
21
+ */
15
22
  language: string;
23
+ /**
24
+ * The text content of the file
25
+ */
16
26
  content: string;
17
27
  /**
18
28
  * The size of the file in bytes
@@ -35,7 +45,7 @@ export declare class DiscordTextFileAttachmentPreviewer extends LitElement imple
35
45
  */
36
46
  bytesUnit: string;
37
47
  /**
38
- * The URL to the file, this is passed to `<discord-link>`
48
+ * The URL to the file, used by the "Download" menu item
39
49
  *
40
50
  * @example
41
51
  * ```ts
@@ -43,24 +53,90 @@ export declare class DiscordTextFileAttachmentPreviewer extends LitElement imple
43
53
  * ```
44
54
  */
45
55
  href: string;
56
+ /**
57
+ * Whether long lines wrap instead of scrolling sideways, as Discord does by default. Viewers can
58
+ * toggle it from the menu. Set `wrap-text="false"` to start with it off.
59
+ */
60
+ wrapText: boolean;
46
61
  lightTheme: boolean;
47
- protected createRenderRoot(): this;
62
+ /**
63
+ * Whether the inline preview shows more lines.
64
+ */
65
+ private expanded;
66
+ /**
67
+ * Whether the full view (a modal dialog) is open.
68
+ */
69
+ private fullView;
70
+ /**
71
+ * The open popup, and the footer (inline or full view) that opened it.
72
+ */
73
+ private popup;
48
74
  private currentSearch;
49
- private handleSearchInput;
50
- private clearSearch;
51
- private selectLanguage;
52
- inputRef: import("lit/directives/ref.js").Ref<HTMLInputElement>;
53
- languageSelectorContainer: import("lit/directives/ref.js").Ref<HTMLDivElement>;
54
- languageSelectorButton: import("lit/directives/ref.js").Ref<HTMLButtonElement>;
55
- private isLanguageSelectorVisible;
75
+ /**
76
+ * Whether the collapsed preview hides content, measured once rendered.
77
+ */
78
+ private overflowing;
79
+ private lines;
80
+ private popper;
81
+ /**
82
+ * The trigger pressed while its popup was open. Light dismiss may already have closed the popup by
83
+ * the time its click arrives, so the click must not open it again.
84
+ */
85
+ private pressedOpenTrigger;
86
+ /**
87
+ * Whether the open popup was opened from the keyboard, which moves focus into it.
88
+ */
89
+ private openedFromKeyboard;
90
+ private wrapCloseTimeout;
91
+ /**
92
+ * Whether the pointer went down outside the full view, for the light-dismiss fallback.
93
+ */
94
+ private pressedOutsideDialog;
95
+ private readonly dialogRef;
96
+ private readonly inlineBodyRef;
97
+ private readonly inputRef;
98
+ protected createRenderRoot(): this;
99
+ /**
100
+ * Open the language selector of the inline preview. Kept for the 4.x API.
101
+ */
56
102
  showSelector(): void;
103
+ /**
104
+ * Close any open popup. Kept for the 4.x API.
105
+ */
57
106
  hideSelector(): void;
58
- private popper;
59
- private isFirstClickDispatch;
60
- private removeHandleClickOutside;
61
107
  disconnectedCallback(): void;
62
- private handleClickOutside;
63
- updated(changed: PropertyValues): void;
108
+ protected willUpdate(changed: PropertyValues): void;
109
+ protected updated(changed: PropertyValues): void;
110
+ private isPopupOpen;
111
+ private openPopup;
112
+ /**
113
+ * Close the open popup. Focus goes back to its trigger when it was inside the popup, without a
114
+ * focus ring after a pointer action.
115
+ */
116
+ private closePopup;
117
+ private popupElements;
118
+ private showPopup;
119
+ private handlePopupToggle;
120
+ private handleTriggerPointerDown;
121
+ private handleTriggerClick;
122
+ private handleMenuTriggerKeydown;
123
+ private handleMenuKeydown;
124
+ private toggleExpanded;
125
+ private openFullView;
126
+ private closeFullView;
127
+ private handleDialogClose;
128
+ private isOutsideDialog;
129
+ private handleDialogPointerDown;
130
+ private handleDialogPointerUp;
131
+ private toggleWrap;
132
+ private selectLanguage;
133
+ private handleSearchInput;
134
+ private clearSearch;
135
+ private renderLines;
136
+ private renderHeader;
137
+ private renderLanguageSelector;
138
+ private renderMenu;
139
+ private renderFooter;
64
140
  protected render(): import("lit").TemplateResult<1>;
65
141
  }
66
142
  declare global {
@@ -1 +1 @@
1
- {"version":3,"file":"DiscordTextFileAttachmentPreviewer.d.ts","sourceRoot":"","sources":["../../../src/components/discord-text-file-attachment-previewer/DiscordTextFileAttachmentPreviewer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAQ,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAM5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,gCAAgC,CAAC;AA0BxC,qBACa,kCAAmC,SAAQ,UAAW,YAAW,UAAU;IACvF,cAGC;IAED;;;;;;;OAOG;IAEI,IAAI,EAAE,MAAM,CAAC;IAGb,QAAQ,EAAE,MAAM,CAAC;IAGjB,OAAO,EAAE,MAAM,CAAC;IAEvB;;;;;;;;;OASG;IAEI,KAAK,EAAE,MAAM,CAAC;IAErB;;;;;;;OAOG;IAEI,SAAS,EAAE,MAAM,CAAC;IAEzB;;;;;;;OAOG;IAEI,IAAI,EAAE,MAAM,CAAC;IAIb,UAAU,UAAS;IAE1B,UAAmB,gBAAgB,SAGlC;IAGD,OAAO,CAAC,aAAa,CAAM;IAE3B,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,cAAc;IAKf,QAAQ,wDAAiC;IAEzC,yBAAyB,sDAA+B;IAExD,sBAAsB,yDAAkC;IAG/D,OAAO,CAAC,yBAAyB,CAAS;IAEnC,YAAY,SAGlB;IAEM,YAAY,SAIlB;IAED,OAAO,CAAC,MAAM,CAAgD;IAE9D,OAAO,CAAC,oBAAoB,CAAQ;IAEpC,OAAO,CAAC,wBAAwB;IAMhB,oBAAoB,IAAI,IAAI,CAG3C;IAED,OAAO,CAAC,kBAAkB;IA0BV,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CA0BrD;IAED,UAAmB,MAAM,oCAiFxB;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,wCAAwC,EAAE,kCAAkC,CAAC;KAC7E;CACD"}
1
+ {"version":3,"file":"DiscordTextFileAttachmentPreviewer.d.ts","sourceRoot":"","sources":["../../../src/components/discord-text-file-attachment-previewer/DiscordTextFileAttachmentPreviewer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAA2B,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAM/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,gCAAgC,CAAC;AA2FxC,qBACa,kCAAmC,SAAQ,UAAW,YAAW,UAAU;IACvF;;;;;;;OAOG;IAEI,IAAI,EAAE,MAAM,CAAC;IAEpB;;;;;;;OAOG;IAEI,QAAQ,EAAE,MAAM,CAAC;IAExB;;OAEG;IAEI,OAAO,EAAE,MAAM,CAAC;IAEvB;;;;;;;;;OASG;IAEI,KAAK,EAAE,MAAM,CAAC;IAErB;;;;;;;OAOG;IAEI,SAAS,EAAE,MAAM,CAAC;IAEzB;;;;;;;OAOG;IAEI,IAAI,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IASI,QAAQ,UAAQ;IAIhB,UAAU,UAAS;IAE1B;;OAEG;IAEH,OAAO,CAAC,QAAQ,CAAS;IAEzB;;OAEG;IAEH,OAAO,CAAC,QAAQ,CAAS;IAEzB;;OAEG;IAEH,OAAO,CAAC,KAAK,CAA8C;IAG3D,OAAO,CAAC,aAAa,CAAM;IAE3B;;OAEG;IAEH,OAAO,CAAC,WAAW,CAAsB;IAEzC,OAAO,CAAC,KAAK,CAAgB;IAE7B,OAAO,CAAC,MAAM,CAA+B;IAE7C;;;OAGG;IACH,OAAO,CAAC,kBAAkB,CAAuB;IAEjD;;OAEG;IACH,OAAO,CAAC,kBAAkB,CAAS;IAEnC,OAAO,CAAC,gBAAgB,CAAqB;IAE7C;;OAEG;IACH,OAAO,CAAC,oBAAoB,CAAS;IAErC,OAAO,CAA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