@aquera/nile-elements 0.0.127 → 0.0.129

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.
@@ -1,18 +1,10 @@
1
- /**
2
- * Copyright Aquera Inc 2023
3
- *
4
- * This source code is licensed under the BSD-3-Clause license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- import { CSSResultArray, TemplateResult } from 'lit-element';
8
- import NileElement from '../internal/nile-element';
1
+ import { LitElement, CSSResultArray, TemplateResult } from 'lit-element';
9
2
  /**
10
3
  * Nile tour component.
11
4
  *
12
5
  * @tag nile-tour
13
- *
14
6
  */
15
- export declare class NileTour extends NileElement {
7
+ export declare class NileTour extends LitElement {
16
8
  private tourInstance;
17
9
  /**
18
10
  * The steps for the tour.
@@ -26,17 +18,31 @@ export declare class NileTour extends NileElement {
26
18
  beforeChange?: () => Promise<boolean> | boolean;
27
19
  afterChange?: () => Promise<void> | void;
28
20
  }>;
21
+ /**
22
+ * JSON string for steps.
23
+ */
24
+ stepsJson: string;
25
+ /**
26
+ * Whether to show the backdrop overlay.
27
+ */
28
+ showBackdrop: boolean;
29
+ /**
30
+ * Whether to disable interaction during the tour.
31
+ */
32
+ disableInteraction: boolean;
29
33
  static get styles(): CSSResultArray;
30
34
  createRenderRoot(): this;
31
35
  constructor();
36
+ updated(changedProperties: Map<string | number | symbol, unknown>): void;
32
37
  /**
33
- * Initializes and starts the Intro.js tour.
38
+ * Parses the JSON string and updates the steps array.
34
39
  */
35
- startTour(): void;
40
+ private parseStepsJson;
36
41
  /**
37
- * Render method
38
- * @slot This is a slot test
42
+ * Initializes and starts the Intro.js tour.
39
43
  */
44
+ startTour(): void;
45
+ private shakeTooltip;
40
46
  render(): TemplateResult;
41
47
  }
42
48
  export default NileTour;
@@ -1,23 +1,14 @@
1
- /**
2
- * Copyright Aquera Inc 2023
3
- *
4
- * This source code is licensed under the BSD-3-Clause license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
1
  import { __decorate } from "tslib";
8
- import { html, property } from 'lit-element';
2
+ import { LitElement, html, property } from 'lit-element';
9
3
  import { customElement } from 'lit/decorators.js';
10
4
  import { styles } from './nile-tour.css';
11
- import NileElement from '../internal/nile-element';
12
5
  import introJs from 'intro.js';
13
- // import 'intro.js/introjs.css';
14
6
  /**
15
7
  * Nile tour component.
16
8
  *
17
9
  * @tag nile-tour
18
- *
19
10
  */
20
- let NileTour = class NileTour extends NileElement {
11
+ let NileTour = class NileTour extends LitElement {
21
12
  static get styles() {
22
13
  return [styles];
23
14
  }
@@ -26,43 +17,86 @@ let NileTour = class NileTour extends NileElement {
26
17
  }
27
18
  constructor() {
28
19
  super();
29
- // Define the type of tourInstance using ReturnType<typeof introJs>
30
20
  this.tourInstance = null;
31
21
  /**
32
22
  * The steps for the tour.
33
23
  */
34
24
  this.steps = [];
25
+ /**
26
+ * JSON string for steps.
27
+ */
28
+ this.stepsJson = '';
29
+ /**
30
+ * Whether to show the backdrop overlay.
31
+ */
32
+ this.showBackdrop = false;
33
+ /**
34
+ * Whether to disable interaction during the tour.
35
+ */
36
+ this.disableInteraction = false;
37
+ }
38
+ updated(changedProperties) {
39
+ if (changedProperties.has('stepsJson')) {
40
+ this.parseStepsJson();
41
+ }
42
+ super.updated(changedProperties);
43
+ }
44
+ /**
45
+ * Parses the JSON string and updates the steps array.
46
+ */
47
+ parseStepsJson() {
48
+ if (this.stepsJson) {
49
+ try {
50
+ const parsedSteps = JSON.parse(this.stepsJson);
51
+ if (Array.isArray(parsedSteps)) {
52
+ this.steps = parsedSteps;
53
+ }
54
+ else {
55
+ console.error('Invalid JSON: Expected an array');
56
+ }
57
+ }
58
+ catch (error) {
59
+ console.error('Failed to parse stepsJson:', error);
60
+ }
61
+ }
35
62
  }
36
63
  /**
37
64
  * Initializes and starts the Intro.js tour.
38
65
  */
39
66
  startTour() {
40
- const introSteps = this.steps.map((step) => ({
41
- element: document.querySelector(step.element),
67
+ console.log('start of tour');
68
+ const introSteps = this.steps
69
+ .map((step) => ({
70
+ element: document.querySelector(`[data-tour="${step.element}"]`),
42
71
  intro: step.content,
43
72
  title: step.title,
44
73
  position: step.position,
45
74
  beforeChange: step.beforeChange,
46
75
  afterChange: step.afterChange,
47
- })).filter((step) => step.element !== null); // Filter out steps with null elements
76
+ }))
77
+ .filter((step) => step.element !== null);
48
78
  this.tourInstance = introJs().setOptions({
49
79
  steps: introSteps,
50
80
  nextLabel: "<button class='introjs-button introjs-next-button'>Next</button>",
51
81
  prevLabel: "<button class='introjs-button introjs-prev-button'>Prev</button>",
82
+ overlayOpacity: 0,
83
+ disableInteraction: this.disableInteraction,
52
84
  showButtons: true,
53
- showStepNumbers: true,
85
+ showStepNumbers: false,
86
+ exitOnOverlayClick: false,
54
87
  });
55
- // Handle beforeChange
56
88
  this.tourInstance.onbeforechange(async (targetElement) => {
57
89
  const currentStepIndex = this.tourInstance?._currentStep ?? 0;
58
90
  const currentStep = this.steps[currentStepIndex];
59
91
  if (currentStep?.beforeChange) {
60
92
  const result = await currentStep.beforeChange();
61
- return result === true; // Proceed only if `true` is returned
93
+ if (!result) {
94
+ this.shakeTooltip();
95
+ return false;
96
+ }
62
97
  }
63
- return true; // Proceed if no beforeChange function is provided
98
+ return true;
64
99
  });
65
- // Handle afterChange
66
100
  this.tourInstance.onafterchange((targetElement) => {
67
101
  const currentStepIndex = this.tourInstance?._currentStep ?? 0;
68
102
  const currentStep = this.steps[currentStepIndex];
@@ -70,24 +104,56 @@ let NileTour = class NileTour extends NileElement {
70
104
  currentStep.afterChange();
71
105
  }
72
106
  });
107
+ // Update step counter on change
108
+ this.tourInstance.onchange((targetElement) => {
109
+ const currentStep = this.tourInstance?._currentStep ?? 0;
110
+ const totalSteps = this.steps.length;
111
+ const tooltip = document.querySelector('.introjs-tooltip');
112
+ if (tooltip) {
113
+ const navBar = tooltip.querySelector('.introjs-tooltipbuttons');
114
+ if (navBar) {
115
+ let stepCounter = navBar.querySelector('.introjs-step-counter');
116
+ if (!stepCounter) {
117
+ stepCounter = document.createElement('div');
118
+ stepCounter.className = 'introjs-step-counter';
119
+ navBar.insertBefore(stepCounter, navBar.firstChild);
120
+ }
121
+ stepCounter.textContent = `${currentStep + 1} of ${totalSteps}`;
122
+ }
123
+ }
124
+ });
73
125
  this.tourInstance.start();
74
126
  }
75
- /**
76
- * Render method
77
- * @slot This is a slot test
78
- */
127
+ shakeTooltip() {
128
+ const tooltip = document.querySelector('.introjs-tooltip');
129
+ if (tooltip) {
130
+ tooltip.classList.add('introjs-shake');
131
+ setTimeout(() => {
132
+ tooltip.classList.remove('introjs-shake');
133
+ }, 1500);
134
+ }
135
+ }
79
136
  render() {
80
137
  return html `
81
- <style>
82
- ${styles.cssText}
83
- </style>
84
- <slot></slot>
85
- `;
138
+ <style>
139
+ ${styles.cssText}
140
+ </style>
141
+ <slot></slot>
142
+ `;
86
143
  }
87
144
  };
88
145
  __decorate([
89
146
  property({ type: Array })
90
147
  ], NileTour.prototype, "steps", void 0);
148
+ __decorate([
149
+ property({ type: String })
150
+ ], NileTour.prototype, "stepsJson", void 0);
151
+ __decorate([
152
+ property({ type: Boolean })
153
+ ], NileTour.prototype, "showBackdrop", void 0);
154
+ __decorate([
155
+ property({ type: Boolean })
156
+ ], NileTour.prototype, "disableInteraction", void 0);
91
157
  NileTour = __decorate([
92
158
  customElement('nile-tour')
93
159
  ], NileTour);
@@ -1 +1 @@
1
- {"version":3,"file":"nile-tour.js","sourceRoot":"","sources":["../../../src/nile-tour/nile-tour.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAc,IAAI,EAAkC,QAAQ,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,iCAAiC;AAEjC;;;;;GAKG;A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CAAC;YAEjD,IAAI,WAAW,EAAE,YAAY,EAAE;gBAC5B,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,YAAY,EAAE,CAAC;gBAChD,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,qCAAqC;aAC/D;YAED,OAAO,IAAI,CAAC,CAAC,kDAAkD;QAClE,CAAC,CAAC,CAAC;QAEH,qBAAqB;QACrB,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,aAAa,EAAE,EAAE;YAC/C,MAAM,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,YAAY,IAAI,CAAC,CAAC;YAC9D,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YAEjD,IAAI,WAAW,EAAE,WAAW,EAAE;gBAC3B,WAAW,CAAC,WAAW,EAAE,CAAC;aAC5B;QACJ,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACI,MAAM;QACV,OAAO,IAAI,CAAA;;cAEH,MAAM,CAAC,OAAO;;;OAGrB,CAAC;IACL,CAAC;CACH,CAAA;AAjFE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;uCASlB;AAhBE,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAyFpB;SAzFY,QAAQ;AA2FrB,eAAe,QAAQ,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { LitElement, html, CSSResultArray, TemplateResult, property } from 'lit-element';\nimport { customElement } from 'lit/decorators.js';\nimport { styles } from './nile-tour.css';\nimport NileElement from '../internal/nile-element';\nimport introJs from 'intro.js';\n// import 'intro.js/introjs.css';\n\n/**\n * Nile tour component.\n *\n * @tag nile-tour\n *\n */\n@customElement('nile-tour')\nexport class NileTour extends NileElement {\n // Define the type of tourInstance using ReturnType<typeof introJs>\n private tourInstance: ReturnType<typeof introJs> | null = null;\n\n /**\n * The steps for the tour.\n */\n @property({ type: Array })\n steps: Array<{\n stepNo: number;\n element: string;\n title: string;\n content: string;\n position: \"top\" | \"left\" | \"right\" | \"bottom\";\n beforeChange?: () => Promise<boolean> | boolean;\n afterChange?: () => Promise<void> | void;\n }> = [];\n\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n createRenderRoot() {\n return this;\n }\n\n constructor() {\n super();\n }\n\n /**\n * Initializes and starts the Intro.js tour.\n */\n public startTour(): void {\n const introSteps = this.steps.map((step) => ({\n element: document.querySelector(step.element) as HTMLElement | null,\n intro: step.content,\n title: step.title,\n position: step.position,\n beforeChange: step.beforeChange,\n afterChange: step.afterChange,\n })).filter((step) => step.element !== null); // Filter out steps with null elements\n\n this.tourInstance = introJs().setOptions({\n steps: introSteps,\n nextLabel: \"<button class='introjs-button introjs-next-button'>Next</button>\",\n prevLabel: \"<button class='introjs-button introjs-prev-button'>Prev</button>\",\n showButtons: true,\n showStepNumbers: true,\n });\n\n // Handle beforeChange\n this.tourInstance.onbeforechange(async (targetElement) => {\n const currentStepIndex = this.tourInstance?._currentStep ?? 0;\n const currentStep = this.steps[currentStepIndex];\n\n if (currentStep?.beforeChange) {\n const result = await currentStep.beforeChange();\n return result === true; // Proceed only if `true` is returned\n }\n\n return true; // Proceed if no beforeChange function is provided\n });\n\n // Handle afterChange\n this.tourInstance.onafterchange((targetElement) => {\n const currentStepIndex = this.tourInstance?._currentStep ?? 0;\n const currentStep = this.steps[currentStepIndex];\n\n if (currentStep?.afterChange) {\n currentStep.afterChange();\n }\n });\n\n this.tourInstance.start();\n }\n\n /**\n * Render method\n * @slot This is a slot test\n */\n public render(): TemplateResult {\n return html`\n <style>\n ${styles.cssText}\n </style>\n <slot></slot>\n `;\n }\n}\n\nexport default NileTour;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-tour': NileTour;\n }\n}\n"]}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C,WAAW,GAAG,GAAG,WAAW,GAAG,CAAC,OAAO,UAAU,EAAE,CAAC;iBACjE;aACF;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;IAEO,YAAY;QAClB,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;QAC3D,IAAI,OAAO,EAAE;YACX,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;YACvC,UAAU,CAAC,GAAG,EAAE;gBACd,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;YAC5C,CAAC,EAAE,IAAI,CAAC,CAAC;SACV;IACH,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAA;;UAEL,MAAM,CAAC,OAAO;;;KAGnB,CAAC;IACJ,CAAC;CACF,CAAA;AA3JC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;uCASlB;AAMR;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACJ;AAMvB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;8CACE;AAM9B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDACQ;AAjCzB,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAkKpB;SAlKY,QAAQ;AAoKrB,eAAe,QAAQ,CAAC","sourcesContent":["import { LitElement, html, CSSResultArray, TemplateResult, property } from 'lit-element';\nimport { customElement } from 'lit/decorators.js';\nimport { styles } from './nile-tour.css';\nimport introJs from 'intro.js';\n\n/**\n * Nile tour component.\n *\n * @tag nile-tour\n */\n@customElement('nile-tour')\nexport class NileTour extends LitElement {\n private tourInstance: ReturnType<typeof introJs> | null = null;\n\n /**\n * The steps for the tour.\n */\n @property({ type: Array })\n steps: Array<{\n stepNo: number;\n element: string;\n title: string;\n content: string;\n position: \"top\" | \"left\" | \"right\" | \"bottom\";\n beforeChange?: () => Promise<boolean> | boolean;\n afterChange?: () => Promise<void> | void;\n }> = [];\n\n /**\n * JSON string for steps.\n */\n @property({ type: String })\n stepsJson: string = '';\n\n /**\n * Whether to show the backdrop overlay.\n */\n @property({ type: Boolean })\n showBackdrop: boolean = false;\n\n /**\n * Whether to disable interaction during the tour.\n */\n @property({ type: Boolean })\n disableInteraction: boolean = false;\n\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n createRenderRoot() {\n return this;\n }\n\n constructor() {\n super();\n }\n\n updated(changedProperties: Map<string | number | symbol, unknown>): void {\n if (changedProperties.has('stepsJson')) {\n this.parseStepsJson();\n }\n super.updated(changedProperties);\n }\n\n /**\n * Parses the JSON string and updates the steps array.\n */\n private parseStepsJson(): void {\n if (this.stepsJson) {\n try {\n const parsedSteps = JSON.parse(this.stepsJson);\n if (Array.isArray(parsedSteps)) {\n this.steps = parsedSteps;\n } else {\n console.error('Invalid JSON: Expected an array');\n }\n } catch (error) {\n console.error('Failed to parse stepsJson:', error);\n }\n }\n }\n\n /**\n * Initializes and starts the Intro.js tour.\n */\n public startTour(): void {\n console.log('start of tour');\n const introSteps = this.steps\n .map((step) => ({\n element: document.querySelector(`[data-tour=\"${step.element}\"]`) as HTMLElement | null,\n intro: step.content,\n title: step.title,\n position: step.position,\n beforeChange: step.beforeChange,\n afterChange: step.afterChange,\n }))\n .filter((step) => step.element !== null);\n\n this.tourInstance = introJs().setOptions({\n steps: introSteps,\n nextLabel: \"<button class='introjs-button introjs-next-button'>Next</button>\",\n prevLabel: \"<button class='introjs-button introjs-prev-button'>Prev</button>\",\n overlayOpacity: 0,\n disableInteraction: this.disableInteraction,\n showButtons: true,\n showStepNumbers: false,\n exitOnOverlayClick: false,\n });\n\n this.tourInstance.onbeforechange(async (targetElement) => {\n const currentStepIndex = this.tourInstance?._currentStep ?? 0;\n const currentStep = this.steps[currentStepIndex];\n\n if (currentStep?.beforeChange) {\n const result = await currentStep.beforeChange();\n if (!result) {\n this.shakeTooltip();\n return false;\n }\n }\n return true;\n });\n\n this.tourInstance.onafterchange((targetElement) => {\n const currentStepIndex = this.tourInstance?._currentStep ?? 0;\n const currentStep = this.steps[currentStepIndex];\n\n if (currentStep?.afterChange) {\n currentStep.afterChange();\n }\n });\n\n // Update step counter on change\n this.tourInstance.onchange((targetElement) => {\n const currentStep = this.tourInstance?._currentStep ?? 0;\n const totalSteps = this.steps.length;\n const tooltip = document.querySelector('.introjs-tooltip');\n if (tooltip) {\n const navBar = tooltip.querySelector('.introjs-tooltipbuttons');\n if (navBar) {\n let stepCounter = navBar.querySelector('.introjs-step-counter') as HTMLElement;\n if (!stepCounter) {\n stepCounter = document.createElement('div');\n stepCounter.className = 'introjs-step-counter';\n navBar.insertBefore(stepCounter, navBar.firstChild);\n }\n stepCounter.textContent = `${currentStep + 1} of ${totalSteps}`;\n }\n }\n });\n\n this.tourInstance.start();\n }\n\n private shakeTooltip(): void {\n const tooltip = document.querySelector('.introjs-tooltip');\n if (tooltip) {\n tooltip.classList.add('introjs-shake');\n setTimeout(() => {\n tooltip.classList.remove('introjs-shake');\n }, 1500);\n }\n }\n\n public render(): TemplateResult {\n return html`\n <style>\n ${styles.cssText}\n </style>\n <slot></slot>\n `;\n }\n}\n\nexport default NileTour;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-tour': NileTour;\n }\n}\n"]}