js-kompo-utils 1.0.7 → 1.0.9

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.
@@ -257,7 +257,7 @@
257
257
  <div v-show="cards.conditions" class="sb-card-body">
258
258
  <div class="sb-row">
259
259
  <label class="sb-lbl">Show If</label>
260
- <input :value="step.showIf || ''" @input="setStepProp('showIf', $event.target.value)" class="sb-input" placeholder="CSS selector">
260
+ <input :value="step.showIf || ''" @input="setStepProp('showIf', $event.target.value)" class="sb-input" placeholder="permission:X, role:X, selector:.css">
261
261
  </div>
262
262
  </div>
263
263
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-kompo-utils",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "",
5
5
  "main": "app.js",
6
6
  "scripts": {
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export class TutorialConfig {
5
5
  static DEFAULTS = {
6
- avatar: '/images/tutorial-avatar.png',
6
+ avatar: '/images/tutorial-avatar.webp',
7
7
  cursorImage: null,
8
8
  cursorSize: 'clamp(32px, 8vw, 48px)',
9
9
  avatarHeight: 'clamp(200px, 50vh, 475px)',
@@ -181,6 +181,10 @@ export class TutorialEngine {
181
181
  }
182
182
 
183
183
  _wireButtons() {
184
+ if (this.bubble.closeBtn) {
185
+ this.bubble.closeBtn.addEventListener('click', () => { this._close(); });
186
+ }
187
+
184
188
  if (this.bubble.actionBtn) {
185
189
  this.bubble.actionBtn.addEventListener('click', () => { this._advance(); });
186
190
  }
@@ -228,11 +232,17 @@ export class TutorialEngine {
228
232
  const devMode = this.config.get('devMode');
229
233
 
230
234
  if (step.showIf) {
231
- const sel = typeof step.showIf === 'string' ? step.showIf : step.showIf.selector;
232
- if (sel && !document.querySelector(sel)) {
233
- const nextIdx = index + this._lastDirection;
234
- if (nextIdx >= 0 && nextIdx < this.steps.length) this._showStep(nextIdx);
235
- return;
235
+ const raw = typeof step.showIf === 'string' ? step.showIf : step.showIf.selector;
236
+ // Client-side: only evaluate "selector:.css-selector" conditions
237
+ // Server-side conditions (permission:, setting:, role:) are already
238
+ // filtered by TutorialProcessor before reaching the client
239
+ if (raw && raw.startsWith('selector:')) {
240
+ const sel = raw.slice('selector:'.length);
241
+ if (sel && !document.querySelector(sel)) {
242
+ const nextIdx = index + this._lastDirection;
243
+ if (nextIdx >= 0 && nextIdx < this.steps.length) this._showStep(nextIdx);
244
+ return;
245
+ }
236
246
  }
237
247
  }
238
248
 
@@ -29,6 +29,12 @@ export class Bubble {
29
29
  this.el.style.fontSize = config.bubbleFontSize;
30
30
  this.el.style.lineHeight = config.bubbleLineHeight;
31
31
 
32
+ this.closeBtn = document.createElement('button');
33
+ this.closeBtn.className = 'tutorial-close-btn';
34
+ this.closeBtn.setAttribute('aria-label', 'Close tutorial');
35
+ this.closeBtn.textContent = '\u00D7';
36
+ this.el.appendChild(this.closeBtn);
37
+
32
38
  this.arrowEl = document.createElement('div');
33
39
  this.arrowEl.className = 'tutorial-arrow';
34
40
  this.el.appendChild(this.arrowEl);
@@ -209,6 +215,7 @@ export class Bubble {
209
215
  this.actionBtn = null;
210
216
  this.backBtn = null;
211
217
  this.pauseBtn = null;
218
+ this.closeBtn = null;
212
219
  }
213
220
 
214
221
  // --- Private: mobile positioning (CSS flexbox, no @floating-ui) ---
@@ -213,6 +213,32 @@
213
213
  }
214
214
  }
215
215
 
216
+ // === Close button (top-right of bubble) ===
217
+ .tutorial-close-btn {
218
+ position: absolute;
219
+ top: 8px;
220
+ right: 8px;
221
+ width: 28px;
222
+ height: 28px;
223
+ border: none;
224
+ border-radius: 50%;
225
+ background: rgba(0, 0, 0, 0.06);
226
+ color: #999;
227
+ font-size: 18px;
228
+ line-height: 1;
229
+ cursor: pointer;
230
+ display: flex;
231
+ align-items: center;
232
+ justify-content: center;
233
+ transition: background 0.15s, color 0.15s;
234
+ z-index: 1;
235
+
236
+ &:hover {
237
+ background: rgba(0, 0, 0, 0.12);
238
+ color: #333;
239
+ }
240
+ }
241
+
216
242
  .tutorial-text {
217
243
  margin: 0;
218
244
  max-height: clamp(150px, 40vh, 300px);