@fluid-topics/ft-reader-navigation-button 0.3.17

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 ADDED
@@ -0,0 +1,20 @@
1
+ Button used to navigate between pages in an integrated reader context.
2
+
3
+
4
+ ## Install
5
+
6
+ ```shell
7
+ npm install @fluid-topics/ft-reader-navigation-button
8
+ yarn add @fluid-topics/ft-reader-navigation-button
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { html } from "lit"
15
+ import "@fluid-topics/ft-reader-navigation-button"
16
+
17
+ function render() {
18
+ return html` <ft-reader-navigation-button foo="bar"></ft-reader-navigation-button> `
19
+ }
20
+ ```
@@ -0,0 +1,3 @@
1
+ export declare const FtReaderNavigationButtonCssVariables: {};
2
+ export declare const styles: import("lit").CSSResult;
3
+ //# sourceMappingURL=ft-reader-navigation-button.css.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { css } from "lit";
2
+ export const FtReaderNavigationButtonCssVariables = {};
3
+ // language=CSS
4
+ export const styles = css `
5
+ `;
6
+ //# sourceMappingURL=ft-reader-navigation-button.css.js.map
@@ -0,0 +1,27 @@
1
+ import { nothing, PropertyValues } from "lit";
2
+ import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
3
+ import { FtReaderNavigationButtonProperties, FtReaderNavigationTarget } from "./ft-reader-navigation-button.properties";
4
+ import { Position } from "@fluid-topics/ft-tooltip";
5
+ import { FtReaderComponent } from "@fluid-topics/ft-reader-context/build/registration";
6
+ import { FtIconVariants } from "@fluid-topics/ft-icon";
7
+ export declare class FtReaderNavigationButton extends FtReaderComponent implements FtReaderNavigationButtonProperties {
8
+ static elementDefinitions: ElementDefinitionsMap;
9
+ static styles: import("lit").CSSResult;
10
+ target: FtReaderNavigationTarget;
11
+ content?: string;
12
+ tooltipPosition?: Position;
13
+ hideTooltip: boolean;
14
+ iconVariant?: FtIconVariants;
15
+ icon?: string;
16
+ trailingIcon: boolean;
17
+ keepVisible: boolean;
18
+ private currentPage?;
19
+ private targetPage?;
20
+ get isReady(): boolean;
21
+ private get defaultContent();
22
+ private get defaultIcon();
23
+ protected render(): typeof nothing | import("lit-html").TemplateResult<1>;
24
+ protected update(props: PropertyValues): void;
25
+ private updateTarget;
26
+ }
27
+ //# sourceMappingURL=ft-reader-navigation-button.d.ts.map
@@ -0,0 +1,110 @@
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 { html, nothing } from "lit";
8
+ import { property, state } from "lit/decorators.js";
9
+ import { redux } from "@fluid-topics/ft-wc-utils";
10
+ import { styles } from "./ft-reader-navigation-button.css";
11
+ import { FtButton } from "@fluid-topics/ft-button";
12
+ import { FtReaderInternalLink } from "@fluid-topics/ft-reader-internal-link";
13
+ import { FtReaderComponent } from "@fluid-topics/ft-reader-context/build/registration";
14
+ import { FtIcons, FtIconVariants } from "@fluid-topics/ft-icon";
15
+ export class FtReaderNavigationButton extends FtReaderComponent {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.target = "next";
19
+ this.tooltipPosition = "bottom";
20
+ this.hideTooltip = false;
21
+ this.iconVariant = FtIconVariants.fluid_topics;
22
+ this.trailingIcon = false;
23
+ this.keepVisible = false;
24
+ }
25
+ get isReady() {
26
+ return this.currentPage != null;
27
+ }
28
+ get defaultContent() {
29
+ return this.target.substring(0, 1).toUpperCase() + this.target.substring(1);
30
+ }
31
+ get defaultIcon() {
32
+ return this.target === "next" ? FtIcons.THIN_ARROW_RIGHT : FtIcons.THIN_ARROW_LEFT;
33
+ }
34
+ render() {
35
+ var _a, _b, _c, _d, _e;
36
+ if (this.targetPage == null && !this.keepVisible) {
37
+ return nothing;
38
+ }
39
+ return html `
40
+ <ft-reader-internal-link .tocId=${(_a = this.targetPage) === null || _a === void 0 ? void 0 : _a.rootTocId}>
41
+ <ft-button ?forceTooltip=${!this.hideTooltip}
42
+ ?hideTooltip=${this.hideTooltip}
43
+ ?trailingIcon=${this.trailingIcon}
44
+ .label=${(_c = (_b = this.targetPage) === null || _b === void 0 ? void 0 : _b.title) !== null && _c !== void 0 ? _c : ""}
45
+ .tooltipPosition=${this.tooltipPosition}
46
+ .iconVariant=${this.iconVariant}
47
+ .icon=${(_d = this.icon) !== null && _d !== void 0 ? _d : this.defaultIcon}>
48
+ ${(_e = this.content) !== null && _e !== void 0 ? _e : this.defaultContent}
49
+ </ft-button>
50
+ </ft-reader-internal-link>
51
+ `;
52
+ }
53
+ update(props) {
54
+ super.update(props);
55
+ if (props.has("currentPage")) {
56
+ this.updateTarget();
57
+ }
58
+ }
59
+ async updateTarget() {
60
+ var _a, _b;
61
+ if (this.currentPage) {
62
+ const targetPageNumber = this.currentPage.number + (this.target === "next" ? 1 : -1);
63
+ this.targetPage = await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.getPage(targetPageNumber));
64
+ if (((_b = this.targetPage) === null || _b === void 0 ? void 0 : _b.number) !== targetPageNumber) {
65
+ this.targetPage = undefined;
66
+ }
67
+ }
68
+ else {
69
+ this.targetPage = undefined;
70
+ }
71
+ }
72
+ }
73
+ // Uncomment to use scoped web components
74
+ FtReaderNavigationButton.elementDefinitions = {
75
+ "ft-button": FtButton,
76
+ "ft-reader-internal-link": FtReaderInternalLink
77
+ };
78
+ // language=CSS
79
+ FtReaderNavigationButton.styles = styles;
80
+ __decorate([
81
+ property()
82
+ ], FtReaderNavigationButton.prototype, "target", void 0);
83
+ __decorate([
84
+ property()
85
+ ], FtReaderNavigationButton.prototype, "content", void 0);
86
+ __decorate([
87
+ property()
88
+ ], FtReaderNavigationButton.prototype, "tooltipPosition", void 0);
89
+ __decorate([
90
+ property({ type: Boolean })
91
+ ], FtReaderNavigationButton.prototype, "hideTooltip", void 0);
92
+ __decorate([
93
+ property()
94
+ ], FtReaderNavigationButton.prototype, "iconVariant", void 0);
95
+ __decorate([
96
+ property()
97
+ ], FtReaderNavigationButton.prototype, "icon", void 0);
98
+ __decorate([
99
+ property({ type: Boolean })
100
+ ], FtReaderNavigationButton.prototype, "trailingIcon", void 0);
101
+ __decorate([
102
+ property({ type: Boolean, attribute: false })
103
+ ], FtReaderNavigationButton.prototype, "keepVisible", void 0);
104
+ __decorate([
105
+ redux()
106
+ ], FtReaderNavigationButton.prototype, "currentPage", void 0);
107
+ __decorate([
108
+ state()
109
+ ], FtReaderNavigationButton.prototype, "targetPage", void 0);
110
+ //# sourceMappingURL=ft-reader-navigation-button.js.map