@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.
- package/README.md +6 -0
- package/demo/index.html +87 -16
- package/dist/nile-code-editor/nile-code-editor.cjs.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
- package/dist/nile-code-editor/nile-code-editor.esm.js +1 -1
- package/dist/nile-tour/index.cjs.js +1 -1
- package/dist/nile-tour/index.esm.js +1 -1
- package/dist/nile-tour/nile-tour.cjs.js +2 -2
- package/dist/nile-tour/nile-tour.cjs.js.map +1 -1
- package/dist/nile-tour/nile-tour.css.cjs.js +1 -1
- package/dist/nile-tour/nile-tour.css.cjs.js.map +1 -1
- package/dist/nile-tour/nile-tour.css.esm.js +49 -13
- package/dist/nile-tour/nile-tour.esm.js +7 -7
- package/dist/src/nile-code-editor/nile-code-editor.js +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/dist/src/nile-tour/nile-tour.css.js +49 -13
- package/dist/src/nile-tour/nile-tour.css.js.map +1 -1
- package/dist/src/nile-tour/nile-tour.d.ts +20 -14
- package/dist/src/nile-tour/nile-tour.js +95 -29
- package/dist/src/nile-tour/nile-tour.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/nile-code-editor/nile-code-editor.ts +1 -1
- package/src/nile-tour/nile-tour.css.ts +49 -13
- package/src/nile-tour/nile-tour.ts +165 -102
- package/vscode-html-custom-data.json +15 -1
package/package.json
CHANGED
@@ -17,8 +17,8 @@ export const styles = css`
|
|
17
17
|
.introjs-tooltip {
|
18
18
|
background-color: var(--nile-tour-background-color, #000);
|
19
19
|
color: var(--nile-tour-text-color, #fff);
|
20
|
-
|
21
|
-
|
20
|
+
width: 300px;
|
21
|
+
max-width: 300px;
|
22
22
|
}
|
23
23
|
|
24
24
|
.introjs-arrow.bottom {
|
@@ -42,11 +42,9 @@ export const styles = css`
|
|
42
42
|
}
|
43
43
|
|
44
44
|
.introjs-arrow.right-bottom {
|
45
|
-
border-
|
45
|
+
border-left-color: var(--nile-tour-background-color, #000) !important;
|
46
46
|
}
|
47
47
|
|
48
|
-
|
49
|
-
|
50
48
|
.introjs-button {
|
51
49
|
background: none;
|
52
50
|
border: none;
|
@@ -84,23 +82,61 @@ export const styles = css`
|
|
84
82
|
gap: 10px;
|
85
83
|
}
|
86
84
|
|
87
|
-
.introjs-helperNumberLayer{
|
88
|
-
|
85
|
+
.introjs-helperNumberLayer {
|
86
|
+
display: none;
|
89
87
|
}
|
90
88
|
|
91
|
-
.introjs-bullets{
|
92
|
-
|
93
|
-
|
89
|
+
.introjs-bullets {
|
90
|
+
display: none;
|
94
91
|
}
|
95
92
|
|
96
93
|
.introjs-skipbutton {
|
97
|
-
|
94
|
+
display: none;
|
95
|
+
}
|
96
|
+
|
97
|
+
.introjs-prev-button {
|
98
|
+
color: #c7ced4;
|
99
|
+
}
|
98
100
|
|
101
|
+
.introjs-helperLayer {
|
102
|
+
display: none;
|
103
|
+
pointer-events: none;
|
99
104
|
}
|
100
105
|
|
106
|
+
.introjs-overlay {
|
107
|
+
display: none;
|
108
|
+
pointer-events: none;
|
109
|
+
}
|
101
110
|
|
102
|
-
.introjs-
|
103
|
-
|
111
|
+
.introjs-step-counter {
|
112
|
+
margin-right: auto; /* Push buttons to the opposite side */
|
113
|
+
font-size: 14px;
|
114
|
+
color: #ffffff;
|
115
|
+
padding: 0 10px;
|
116
|
+
display: flex;
|
117
|
+
align-items: center;
|
118
|
+
}
|
119
|
+
|
120
|
+
@keyframes shake {
|
121
|
+
0% {
|
122
|
+
transform: translateX(0);
|
123
|
+
}
|
124
|
+
25% {
|
125
|
+
transform: translateX(-5px);
|
126
|
+
}
|
127
|
+
50% {
|
128
|
+
transform: translateX(5px);
|
129
|
+
}
|
130
|
+
75% {
|
131
|
+
transform: translateX(-5px);
|
132
|
+
}
|
133
|
+
100% {
|
134
|
+
transform: translateX(0);
|
135
|
+
}
|
136
|
+
}
|
137
|
+
|
138
|
+
.introjs-shake {
|
139
|
+
animation: shake 0.5s ease infinite; /* Repeats continuously */
|
104
140
|
}
|
105
141
|
`;
|
106
142
|
|
@@ -1,119 +1,182 @@
|
|
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
|
-
|
8
1
|
import { LitElement, html, CSSResultArray, TemplateResult, property } from 'lit-element';
|
9
2
|
import { customElement } from 'lit/decorators.js';
|
10
3
|
import { styles } from './nile-tour.css';
|
11
|
-
import NileElement from '../internal/nile-element';
|
12
4
|
import introJs from 'intro.js';
|
13
|
-
// import 'intro.js/introjs.css';
|
14
5
|
|
15
6
|
/**
|
16
7
|
* Nile tour component.
|
17
8
|
*
|
18
9
|
* @tag nile-tour
|
19
|
-
*
|
20
10
|
*/
|
21
11
|
@customElement('nile-tour')
|
22
|
-
export class NileTour extends
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
12
|
+
export class NileTour extends LitElement {
|
13
|
+
private tourInstance: ReturnType<typeof introJs> | null = null;
|
14
|
+
|
15
|
+
/**
|
16
|
+
* The steps for the tour.
|
17
|
+
*/
|
18
|
+
@property({ type: Array })
|
19
|
+
steps: Array<{
|
20
|
+
stepNo: number;
|
21
|
+
element: string;
|
22
|
+
title: string;
|
23
|
+
content: string;
|
24
|
+
position: "top" | "left" | "right" | "bottom";
|
25
|
+
beforeChange?: () => Promise<boolean> | boolean;
|
26
|
+
afterChange?: () => Promise<void> | void;
|
27
|
+
}> = [];
|
28
|
+
|
29
|
+
/**
|
30
|
+
* JSON string for steps.
|
31
|
+
*/
|
32
|
+
@property({ type: String })
|
33
|
+
stepsJson: string = '';
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Whether to show the backdrop overlay.
|
37
|
+
*/
|
38
|
+
@property({ type: Boolean })
|
39
|
+
showBackdrop: boolean = false;
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Whether to disable interaction during the tour.
|
43
|
+
*/
|
44
|
+
@property({ type: Boolean })
|
45
|
+
disableInteraction: boolean = false;
|
46
|
+
|
47
|
+
public static get styles(): CSSResultArray {
|
48
|
+
return [styles];
|
49
|
+
}
|
50
|
+
|
51
|
+
createRenderRoot() {
|
52
|
+
return this;
|
53
|
+
}
|
54
|
+
|
55
|
+
constructor() {
|
56
|
+
super();
|
57
|
+
}
|
58
|
+
|
59
|
+
updated(changedProperties: Map<string | number | symbol, unknown>): void {
|
60
|
+
if (changedProperties.has('stepsJson')) {
|
61
|
+
this.parseStepsJson();
|
62
|
+
}
|
63
|
+
super.updated(changedProperties);
|
64
|
+
}
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Parses the JSON string and updates the steps array.
|
68
|
+
*/
|
69
|
+
private parseStepsJson(): void {
|
70
|
+
if (this.stepsJson) {
|
71
|
+
try {
|
72
|
+
const parsedSteps = JSON.parse(this.stepsJson);
|
73
|
+
if (Array.isArray(parsedSteps)) {
|
74
|
+
this.steps = parsedSteps;
|
75
|
+
} else {
|
76
|
+
console.error('Invalid JSON: Expected an array');
|
77
|
+
}
|
78
|
+
} catch (error) {
|
79
|
+
console.error('Failed to parse stepsJson:', error);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Initializes and starts the Intro.js tour.
|
86
|
+
*/
|
87
|
+
public startTour(): void {
|
88
|
+
console.log('start of tour');
|
89
|
+
const introSteps = this.steps
|
90
|
+
.map((step) => ({
|
91
|
+
element: document.querySelector(`[data-tour="${step.element}"]`) as HTMLElement | null,
|
92
|
+
intro: step.content,
|
93
|
+
title: step.title,
|
94
|
+
position: step.position,
|
95
|
+
beforeChange: step.beforeChange,
|
96
|
+
afterChange: step.afterChange,
|
97
|
+
}))
|
98
|
+
.filter((step) => step.element !== null);
|
99
|
+
|
100
|
+
this.tourInstance = introJs().setOptions({
|
101
|
+
steps: introSteps,
|
102
|
+
nextLabel: "<button class='introjs-button introjs-next-button'>Next</button>",
|
103
|
+
prevLabel: "<button class='introjs-button introjs-prev-button'>Prev</button>",
|
104
|
+
overlayOpacity: 0,
|
105
|
+
disableInteraction: this.disableInteraction,
|
106
|
+
showButtons: true,
|
107
|
+
showStepNumbers: false,
|
108
|
+
exitOnOverlayClick: false,
|
109
|
+
});
|
110
|
+
|
111
|
+
this.tourInstance.onbeforechange(async (targetElement) => {
|
112
|
+
const currentStepIndex = this.tourInstance?._currentStep ?? 0;
|
113
|
+
const currentStep = this.steps[currentStepIndex];
|
114
|
+
|
115
|
+
if (currentStep?.beforeChange) {
|
116
|
+
const result = await currentStep.beforeChange();
|
117
|
+
if (!result) {
|
118
|
+
this.shakeTooltip();
|
119
|
+
return false;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
return true;
|
123
|
+
});
|
124
|
+
|
125
|
+
this.tourInstance.onafterchange((targetElement) => {
|
126
|
+
const currentStepIndex = this.tourInstance?._currentStep ?? 0;
|
127
|
+
const currentStep = this.steps[currentStepIndex];
|
128
|
+
|
129
|
+
if (currentStep?.afterChange) {
|
130
|
+
currentStep.afterChange();
|
131
|
+
}
|
132
|
+
});
|
133
|
+
|
134
|
+
// Update step counter on change
|
135
|
+
this.tourInstance.onchange((targetElement) => {
|
136
|
+
const currentStep = this.tourInstance?._currentStep ?? 0;
|
137
|
+
const totalSteps = this.steps.length;
|
138
|
+
const tooltip = document.querySelector('.introjs-tooltip');
|
139
|
+
if (tooltip) {
|
140
|
+
const navBar = tooltip.querySelector('.introjs-tooltipbuttons');
|
141
|
+
if (navBar) {
|
142
|
+
let stepCounter = navBar.querySelector('.introjs-step-counter') as HTMLElement;
|
143
|
+
if (!stepCounter) {
|
144
|
+
stepCounter = document.createElement('div');
|
145
|
+
stepCounter.className = 'introjs-step-counter';
|
146
|
+
navBar.insertBefore(stepCounter, navBar.firstChild);
|
147
|
+
}
|
148
|
+
stepCounter.textContent = `${currentStep + 1} of ${totalSteps}`;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
});
|
152
|
+
|
153
|
+
this.tourInstance.start();
|
154
|
+
}
|
155
|
+
|
156
|
+
private shakeTooltip(): void {
|
157
|
+
const tooltip = document.querySelector('.introjs-tooltip');
|
158
|
+
if (tooltip) {
|
159
|
+
tooltip.classList.add('introjs-shake');
|
160
|
+
setTimeout(() => {
|
161
|
+
tooltip.classList.remove('introjs-shake');
|
162
|
+
}, 1500);
|
163
|
+
}
|
164
|
+
}
|
165
|
+
|
166
|
+
public render(): TemplateResult {
|
167
|
+
return html`
|
168
|
+
<style>
|
169
|
+
${styles.cssText}
|
170
|
+
</style>
|
171
|
+
<slot></slot>
|
172
|
+
`;
|
173
|
+
}
|
111
174
|
}
|
112
175
|
|
113
176
|
export default NileTour;
|
114
177
|
|
115
178
|
declare global {
|
116
|
-
|
117
|
-
|
118
|
-
|
179
|
+
interface HTMLElementTagNameMap {
|
180
|
+
'nile-tour': NileTour;
|
181
|
+
}
|
119
182
|
}
|
@@ -3728,11 +3728,25 @@
|
|
3728
3728
|
},
|
3729
3729
|
{
|
3730
3730
|
"name": "nile-tour",
|
3731
|
-
"description": "Nile tour component.\n\nAttributes:\n\n * `steps` {`{ stepNo: number; element: string; title: string; content: string; position: \"top\" | \"bottom\" | \"right\" | \"left\"; beforeChange?: (() => boolean | Promise<boolean>) | undefined; afterChange?: (() => void | Promise<...>) | undefined; }[]`} - The steps for the tour.\n\nProperties:\n\n * `tourInstance` - \n\n * `steps` {`{ stepNo: number; element: string; title: string; content: string; position: \"top\" | \"bottom\" | \"right\" | \"left\"; beforeChange?: (() => boolean | Promise<boolean>) | undefined; afterChange?: (() => void | Promise<...>) | undefined; }[]`} - The steps for the tour.\n\n * `
|
3731
|
+
"description": "Nile tour component.\n\nAttributes:\n\n * `steps` {`{ stepNo: number; element: string; title: string; content: string; position: \"top\" | \"bottom\" | \"right\" | \"left\"; beforeChange?: (() => boolean | Promise<boolean>) | undefined; afterChange?: (() => void | Promise<...>) | undefined; }[]`} - The steps for the tour.\n\n * `stepsJson` {`string`} - JSON string for steps.\n\n * `showBackdrop` {`boolean`} - Whether to show the backdrop overlay.\n\n * `disableInteraction` {`boolean`} - Whether to disable interaction during the tour.\n\nProperties:\n\n * `tourInstance` - \n\n * `steps` {`{ stepNo: number; element: string; title: string; content: string; position: \"top\" | \"bottom\" | \"right\" | \"left\"; beforeChange?: (() => boolean | Promise<boolean>) | undefined; afterChange?: (() => void | Promise<...>) | undefined; }[]`} - The steps for the tour.\n\n * `stepsJson` {`string`} - JSON string for steps.\n\n * `showBackdrop` {`boolean`} - Whether to show the backdrop overlay.\n\n * `disableInteraction` {`boolean`} - Whether to disable interaction during the tour.",
|
3732
3732
|
"attributes": [
|
3733
3733
|
{
|
3734
3734
|
"name": "steps",
|
3735
3735
|
"description": "`steps` {`{ stepNo: number; element: string; title: string; content: string; position: \"top\" | \"bottom\" | \"right\" | \"left\"; beforeChange?: (() => boolean | Promise<boolean>) | undefined; afterChange?: (() => void | Promise<...>) | undefined; }[]`} - The steps for the tour.\n\nProperty: steps\n\nDefault: "
|
3736
|
+
},
|
3737
|
+
{
|
3738
|
+
"name": "stepsJson",
|
3739
|
+
"description": "`stepsJson` {`string`} - JSON string for steps.\n\nProperty: stepsJson\n\nDefault: "
|
3740
|
+
},
|
3741
|
+
{
|
3742
|
+
"name": "showBackdrop",
|
3743
|
+
"description": "`showBackdrop` {`boolean`} - Whether to show the backdrop overlay.\n\nProperty: showBackdrop\n\nDefault: false",
|
3744
|
+
"valueSet": "v"
|
3745
|
+
},
|
3746
|
+
{
|
3747
|
+
"name": "disableInteraction",
|
3748
|
+
"description": "`disableInteraction` {`boolean`} - Whether to disable interaction during the tour.\n\nProperty: disableInteraction\n\nDefault: false",
|
3749
|
+
"valueSet": "v"
|
3736
3750
|
}
|
3737
3751
|
]
|
3738
3752
|
},
|