@aquera/nile-elements 0.1.18 → 0.1.20
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 +7 -0
- package/demo/index.html +111 -16
- package/demo/variables.css +12 -0
- package/demo/variables_v2.css +12 -0
- 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/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 +33 -19
- package/dist/nile-tour/nile-tour.esm.js +11 -2
- 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 +31 -17
- package/dist/src/nile-tour/nile-tour.css.js.map +1 -1
- package/dist/src/nile-tour/nile-tour.d.ts +6 -29
- package/dist/src/nile-tour/nile-tour.js +70 -76
- 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 +31 -17
- package/src/nile-tour/nile-tour.ts +86 -95
- package/vscode-html-custom-data.json +1 -5
package/package.json
CHANGED
@@ -15,13 +15,14 @@ export const styles = css`
|
|
15
15
|
}
|
16
16
|
|
17
17
|
.introjs-tooltip {
|
18
|
-
background-color: var(--nile-tour-background-color, #
|
19
|
-
color: var(--nile-tour-text-color,
|
18
|
+
background-color: var(--nile-tour-background-color, #1978b8);
|
19
|
+
color: var(--nile-tour-text-color, #fff);
|
20
20
|
width: 300px;
|
21
21
|
max-width: 300px;
|
22
|
-
border-radius:
|
23
|
-
border: 1px solid var(--Neutral-30, #
|
24
|
-
background: var(--White-Normal, #
|
22
|
+
border-radius: 12px;
|
23
|
+
border: 1px solid var(--Neutral-30, #1978b8);
|
24
|
+
background: var(--White-Normal, #1978b8);
|
25
|
+
/* border: 1px solid var(--Neutral-30, #C7CED4); */
|
25
26
|
|
26
27
|
/* Elevation/Lifted */
|
27
28
|
box-shadow: 0px 4px 8px 0px rgba(119, 125, 130, 0.15);
|
@@ -42,8 +43,12 @@ export const styles = css`
|
|
42
43
|
padding-top: 18px;
|
43
44
|
}
|
44
45
|
|
46
|
+
.introjs-progress {
|
47
|
+
display: none;
|
48
|
+
}
|
49
|
+
|
45
50
|
.introjs-tooltiptext {
|
46
|
-
color:
|
51
|
+
color: #c7ced4;
|
47
52
|
font-size: 14px;
|
48
53
|
font-style: normal;
|
49
54
|
font-weight: 400;
|
@@ -118,7 +123,7 @@ export const styles = css`
|
|
118
123
|
padding: 0;
|
119
124
|
cursor: pointer;
|
120
125
|
text-shadow: none;
|
121
|
-
background: var(--Primary-Normal, #
|
126
|
+
background: var(--Primary-Normal, #1978b8);
|
122
127
|
border-color: transparent;
|
123
128
|
display: flex;
|
124
129
|
padding: 12px;
|
@@ -136,7 +141,7 @@ export const styles = css`
|
|
136
141
|
padding: 0;
|
137
142
|
cursor: pointer;
|
138
143
|
text-shadow: none;
|
139
|
-
background: var(--Primary-Normal, #
|
144
|
+
background: var(--Primary-Normal, #1978b8);
|
140
145
|
border-color: transparent;
|
141
146
|
display: flex;
|
142
147
|
padding: 12px;
|
@@ -153,7 +158,7 @@ export const styles = css`
|
|
153
158
|
cursor: pointer;
|
154
159
|
text-shadow: none;
|
155
160
|
box-shadow: none;
|
156
|
-
background: var(--Primary-Normal, #
|
161
|
+
background: var(--Primary-Normal, #1978b8);
|
157
162
|
border-color: transparent;
|
158
163
|
display: flex;
|
159
164
|
padding: 12px;
|
@@ -185,13 +190,8 @@ export const styles = css`
|
|
185
190
|
}
|
186
191
|
|
187
192
|
.introjs-helperLayer {
|
188
|
-
|
189
|
-
|
190
|
-
}
|
191
|
-
|
192
|
-
.introjs-overlay {
|
193
|
-
display: none;
|
194
|
-
pointer-events: none;
|
193
|
+
box-shadow: rgb(33 33 33 / 0%) 0px 0px 1px 2px,
|
194
|
+
rgba(33, 33, 33, 0.5) 0px 0px 0px 5000px !important;
|
195
195
|
}
|
196
196
|
|
197
197
|
.introjs-step-counter {
|
@@ -200,7 +200,7 @@ export const styles = css`
|
|
200
200
|
padding: 0 10px;
|
201
201
|
display: flex;
|
202
202
|
align-items: center;
|
203
|
-
color: var(--Color-Text-Inverted-Secondary, rgba(255, 255, 255, 0.
|
203
|
+
color: var(--Color-Text-Inverted-Secondary, rgba(255, 255, 255, 0.5));
|
204
204
|
font-style: normal;
|
205
205
|
font-weight: 500;
|
206
206
|
line-height: 14px;
|
@@ -228,6 +228,20 @@ export const styles = css`
|
|
228
228
|
.introjs-shake {
|
229
229
|
animation: shake 0.5s ease infinite;
|
230
230
|
}
|
231
|
+
|
232
|
+
.introjs-close-btn {
|
233
|
+
position: absolute;
|
234
|
+
top: 15px;
|
235
|
+
right: 10px;
|
236
|
+
background: none;
|
237
|
+
border: none;
|
238
|
+
font-size: 16px;
|
239
|
+
cursor: pointer;
|
240
|
+
}
|
241
|
+
|
242
|
+
a[disabled='true'] {
|
243
|
+
display: none;
|
244
|
+
}
|
231
245
|
`;
|
232
246
|
|
233
247
|
export default [styles];
|
@@ -5,33 +5,14 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
|
8
|
-
import { LitElement, html, CSSResultArray, TemplateResult
|
9
|
-
import { customElement,property } from 'lit/decorators.js';
|
10
|
-
import { styles } from './nile-tour.css';
|
8
|
+
import { LitElement, html, css, CSSResultArray, TemplateResult } from 'lit';
|
9
|
+
import { customElement, property } from 'lit/decorators.js';
|
11
10
|
import introJs from 'intro.js';
|
11
|
+
import { styles } from './nile-tour.css';
|
12
12
|
|
13
|
-
/**
|
14
|
-
* Nile tour component.
|
15
|
-
*
|
16
|
-
* @tag nile-tour
|
17
|
-
*/
|
18
13
|
@customElement('nile-tour')
|
19
14
|
export class NileTour extends LitElement {
|
20
|
-
|
21
|
-
|
22
|
-
/**
|
23
|
-
* The steps for the tour.
|
24
|
-
*/
|
25
|
-
@property({ type: Array })
|
26
|
-
steps: Array<{
|
27
|
-
stepNo: number;
|
28
|
-
element: string;
|
29
|
-
title: string;
|
30
|
-
content: string;
|
31
|
-
position: any;
|
32
|
-
beforeChange?: () => Promise<boolean> | boolean;
|
33
|
-
afterChange?: () => Promise<void> | void;
|
34
|
-
}> = [];
|
15
|
+
tourInstance: ReturnType<typeof introJs> | null = null;
|
35
16
|
|
36
17
|
/**
|
37
18
|
* JSON string for steps.
|
@@ -50,7 +31,7 @@ export class NileTour extends LitElement {
|
|
50
31
|
*/
|
51
32
|
@property({ type: Boolean })
|
52
33
|
disableInteraction: boolean = false;
|
53
|
-
|
34
|
+
|
54
35
|
public static get styles(): CSSResultArray {
|
55
36
|
return [styles];
|
56
37
|
}
|
@@ -63,85 +44,90 @@ export class NileTour extends LitElement {
|
|
63
44
|
super();
|
64
45
|
}
|
65
46
|
|
66
|
-
|
67
|
-
if (
|
68
|
-
this.
|
47
|
+
private parseSteps(): any[] {
|
48
|
+
if (Array.isArray(this.stepsJson)) {
|
49
|
+
return this.stepsJson;
|
69
50
|
}
|
70
|
-
|
51
|
+
|
52
|
+
console.error('Invalid stepsJson format');
|
53
|
+
return [];
|
71
54
|
}
|
72
55
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
}
|
85
|
-
} catch (error) {
|
86
|
-
console.error('Failed to parse stepsJson:', error);
|
87
|
-
}
|
88
|
-
}
|
56
|
+
private async getElementWhenNeeded(step: any): Promise<any> {
|
57
|
+
return {
|
58
|
+
element: () => document.querySelector(`[data-tour="${step.element}"]`) as HTMLElement | null,
|
59
|
+
intro: step.content,
|
60
|
+
title: step.title,
|
61
|
+
position: step.position,
|
62
|
+
beforeChange: step.beforeChange,
|
63
|
+
afterChange: step.afterChange,
|
64
|
+
disableNext: step.disableNext || false,
|
65
|
+
disablePrev: step.disablePrev || false
|
66
|
+
};
|
89
67
|
}
|
90
68
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
const
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
beforeChange: step.beforeChange,
|
103
|
-
afterChange: step.afterChange,
|
104
|
-
}));
|
105
|
-
// .filter((step) => step.element !== null);
|
69
|
+
public nextStep() {
|
70
|
+
this.tourInstance?.nextStep();
|
71
|
+
}
|
72
|
+
|
73
|
+
public async startTour(): Promise<void> {
|
74
|
+
const steps = await Promise.all(this.parseSteps().map(step => this.getElementWhenNeeded(step)));
|
75
|
+
|
76
|
+
if (steps.length === 0) {
|
77
|
+
console.error('No valid steps found for the tour.');
|
78
|
+
return;
|
79
|
+
}
|
106
80
|
|
107
81
|
this.tourInstance = introJs().setOptions({
|
108
|
-
steps:
|
109
|
-
nextLabel: "Next",
|
110
|
-
prevLabel: "Prev",
|
111
|
-
overlayOpacity: 0,
|
82
|
+
steps: steps as any,
|
112
83
|
disableInteraction: this.disableInteraction,
|
113
|
-
|
114
|
-
|
84
|
+
nextLabel: 'Next',
|
85
|
+
prevLabel: 'Prev',
|
86
|
+
overlayOpacity: this.showBackdrop ? 0.5 : 0,
|
115
87
|
exitOnOverlayClick: false,
|
88
|
+
showProgress: false,
|
89
|
+
showButtons: true
|
116
90
|
});
|
117
91
|
|
118
92
|
this.tourInstance.onbeforechange(async (targetElement) => {
|
119
93
|
const currentStepIndex = this.tourInstance?._currentStep ?? 0;
|
120
|
-
const
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
94
|
+
const step = steps[currentStepIndex];
|
95
|
+
if (step && typeof step.element === 'function') {
|
96
|
+
const el = step.element();
|
97
|
+
if (el) {
|
98
|
+
if (this.tourInstance && this.tourInstance._introItems) {
|
99
|
+
this.tourInstance._introItems[currentStepIndex].element = el;
|
100
|
+
}
|
127
101
|
}
|
128
102
|
}
|
103
|
+
if (step.beforeChange) {
|
104
|
+
return await step.beforeChange();
|
105
|
+
}
|
129
106
|
return true;
|
130
107
|
});
|
131
108
|
|
132
109
|
this.tourInstance.onafterchange((targetElement) => {
|
133
110
|
const currentStepIndex = this.tourInstance?._currentStep ?? 0;
|
134
|
-
const
|
111
|
+
const step = steps[currentStepIndex];
|
112
|
+
if (step?.afterChange) {
|
113
|
+
step.afterChange();
|
114
|
+
}
|
135
115
|
|
136
|
-
|
137
|
-
|
116
|
+
|
117
|
+
const nextBtn = document.querySelector('.introjs-nextbutton');
|
118
|
+
const prevBtn = document.querySelector('.introjs-prevbutton');
|
119
|
+
|
120
|
+
if (nextBtn) {
|
121
|
+
nextBtn.setAttribute('disabled', step.disableNext ? 'true' : 'false');
|
122
|
+
}
|
123
|
+
if (prevBtn) {
|
124
|
+
prevBtn.setAttribute('disabled', step.disablePrev ? 'true' : 'false');
|
138
125
|
}
|
139
126
|
});
|
140
127
|
|
141
|
-
|
142
|
-
this.tourInstance.onchange((targetElement) => {
|
128
|
+
this.tourInstance.onchange(() => {
|
143
129
|
const currentStep = this.tourInstance?._currentStep ?? 0;
|
144
|
-
const totalSteps =
|
130
|
+
const totalSteps = steps.length;
|
145
131
|
const tooltip = document.querySelector('.introjs-tooltip');
|
146
132
|
if (tooltip) {
|
147
133
|
const navBar = tooltip.querySelector('.introjs-tooltipbuttons');
|
@@ -157,11 +143,9 @@ export class NileTour extends LitElement {
|
|
157
143
|
}
|
158
144
|
});
|
159
145
|
|
160
|
-
|
161
|
-
|
162
146
|
this.tourInstance.start().then(() => {
|
163
147
|
const currentStep = this.tourInstance?._currentStep ?? 0;
|
164
|
-
const totalSteps =
|
148
|
+
const totalSteps = steps.length;
|
165
149
|
const tooltip = document.querySelector('.introjs-tooltip');
|
166
150
|
if (tooltip) {
|
167
151
|
const navBar = tooltip.querySelector('.introjs-tooltipbuttons');
|
@@ -174,33 +158,40 @@ export class NileTour extends LitElement {
|
|
174
158
|
}
|
175
159
|
stepCounter.textContent = `${currentStep + 1} of ${totalSteps}`;
|
176
160
|
}
|
177
|
-
} }).catch(err => {
|
178
|
-
console.error('Error starting the tour:', err);
|
179
|
-
});
|
180
|
-
}
|
181
161
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
162
|
+
const closeButton = document.createElement('button');
|
163
|
+
closeButton.className = 'introjs-close-btn';
|
164
|
+
closeButton.innerHTML = `
|
165
|
+
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
166
|
+
<path d="M5.33228 5.99996L0 11.3322L0.667759 12L6.00004 6.66772L11.3323 12L12.0001 11.3322L6.66779 5.99996L12 0.667759L11.3322 0L6.00004 5.3322L0.667842 5.96046e-08L8.40425e-05 0.667759L5.33228 5.99996Z" fill="white" fill-opacity="0.5"/>
|
167
|
+
</svg>`;
|
168
|
+
closeButton.onclick = () => this.tourInstance?.exit(true);
|
169
|
+
tooltip.appendChild(closeButton);
|
170
|
+
}
|
171
|
+
}).catch(err => {
|
172
|
+
console.error('Error starting the tour:', err);
|
173
|
+
});
|
190
174
|
}
|
191
175
|
|
192
176
|
public render(): TemplateResult {
|
193
177
|
return html`
|
194
178
|
<style>
|
195
179
|
${styles.cssText}
|
180
|
+
.introjs-close-btn {
|
181
|
+
position: absolute;
|
182
|
+
top: 5px;
|
183
|
+
right: 10px;
|
184
|
+
background: none;
|
185
|
+
border: none;
|
186
|
+
cursor: pointer;
|
187
|
+
padding: 0;
|
188
|
+
}
|
196
189
|
</style>
|
197
190
|
<slot></slot>
|
198
191
|
`;
|
199
192
|
}
|
200
193
|
}
|
201
194
|
|
202
|
-
export default NileTour;
|
203
|
-
|
204
195
|
declare global {
|
205
196
|
interface HTMLElementTagNameMap {
|
206
197
|
'nile-tour': NileTour;
|
@@ -3821,12 +3821,8 @@
|
|
3821
3821
|
},
|
3822
3822
|
{
|
3823
3823
|
"name": "nile-tour",
|
3824
|
-
"description": "
|
3824
|
+
"description": "Attributes:\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 * `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.",
|
3825
3825
|
"attributes": [
|
3826
|
-
{
|
3827
|
-
"name": "steps",
|
3828
|
-
"description": "`steps` {`{ stepNo: number; element: string; title: string; content: string; position: any; beforeChange?: (() => boolean | Promise<boolean>) | undefined; afterChange?: (() => void | Promise<void>) | undefined; }[]`} - The steps for the tour.\n\nProperty: steps\n\nDefault: "
|
3829
|
-
},
|
3830
3826
|
{
|
3831
3827
|
"name": "stepsJson",
|
3832
3828
|
"description": "`stepsJson` {`string`} - JSON string for steps.\n\nProperty: stepsJson\n\nDefault: "
|