@operato/property-panel 10.29.109 → 10.29.110

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.
@@ -14,6 +14,18 @@ export declare class PropertyScene3D extends AbstractProperty {
14
14
  static styles: import("lit").CSSResult[];
15
15
  value?: Properties;
16
16
  scene: Scene | null;
17
+ /** The browser is being asked where it is, for the board's latitude and longitude (ADR-0263). */
18
+ private simulating;
19
+ private simulatedAt;
20
+ private simulationClock?;
21
+ /** The board's model layer, which shows a context without saving it. */
22
+ private get vibeLayer();
23
+ private startSimulation;
24
+ private stopSimulation;
25
+ disconnectedCallback(): void;
26
+ private locating;
27
+ /** Why the location could not be read, to say what to do: none when it was read. */
28
+ private locateFailed?;
17
29
  render(): import("lit-html").TemplateResult<1>;
18
30
  /**
19
31
  * Camera 초기 설정 — Initial View(뷰 프리셋), FOV/Near/Far, 현재 카메라 저장 버튼.
@@ -42,6 +54,16 @@ export declare class PropertyScene3D extends AbstractProperty {
42
54
  * "원클릭 전체 look" — 사용자가 원하면 Light Mood/원자 컨트롤로 위에 얹어 조정.
43
55
  */
44
56
  private _renderSky;
57
+ /**
58
+ * The board's context (ADR-0263): turned on, the sun, sky light and background follow the time, date and weather,
59
+ * and lamps light after sunset. Turned off, the values are kept and the board shows its own look.
60
+ */
61
+ private _renderVibe;
62
+ /**
63
+ * The palette tokens that are leaves, and the kind of tree (ADR-0263 stage 4): their colours follow the season. One
64
+ * kind for the tokens given, as most boards have one kind of tree.
65
+ */
66
+ private _renderFoliage;
45
67
  /**
46
68
  * Environment 선택 핸들러 — sky 필드만 바꾸는 게 아니라 ENVIRONMENT_DEFAULTS에
47
69
  * 정의된 hemi/dir 기본 조명까지 한 번의 property-change로 함께 적용한다.
@@ -6,10 +6,34 @@ import '@operato/input/ox-input-color.js';
6
6
  import '@operato/i18n/ox-i18n.js';
7
7
  import './property-material3d.js';
8
8
  import { css, html } from 'lit';
9
- import { property } from 'lit/decorators.js';
9
+ import { property, state } from 'lit/decorators.js';
10
10
  import { ENVIRONMENT_DEFAULTS, LIGHTING_PRESETS, hasSceneOverride, lookedState, sceneLookDefaults, sceneLookOf, sceneLookSelection } from '@hatiolab/things-scene';
11
+ import { i18next } from '@operato/i18n';
11
12
  import { PropertyGridStyles } from '@operato/styles/property-grid-styles.js';
12
13
  import { AbstractProperty } from '../abstract-property.js';
14
+ /**
15
+ * A context's time as the date-time input shows it, in this computer's time zone: `YYYY-MM-DDTHH:mm`, or empty.
16
+ */
17
+ function localDateTime(time) {
18
+ const t = typeof time === 'number' ? time : typeof time === 'string' && time ? Date.parse(time) : NaN;
19
+ if (!Number.isFinite(t))
20
+ return '';
21
+ const d = new Date(t);
22
+ const two = (n) => String(n).padStart(2, '0');
23
+ return `${d.getFullYear()}-${two(d.getMonth() + 1)}-${two(d.getDate())}T${two(d.getHours())}:${two(d.getMinutes())}`;
24
+ }
25
+ /** The date-time input's value with this computer's UTC offset, so that the moment it names is kept: `...T17:30:00+09:00`. */
26
+ function withOffset(local) {
27
+ if (!local)
28
+ return undefined;
29
+ const d = new Date(local);
30
+ if (Number.isNaN(d.getTime()))
31
+ return undefined;
32
+ const minutes = -d.getTimezoneOffset();
33
+ const sign = minutes >= 0 ? '+' : '-';
34
+ const two = (n) => String(Math.floor(Math.abs(n))).padStart(2, '0');
35
+ return `${local.length === 16 ? `${local}:00` : local}${sign}${two(minutes / 60)}:${two(minutes % 60)}`;
36
+ }
13
37
  /**
14
38
  * Scene-level 3D settings for model-layer.
15
39
  * Includes 3D mode, camera, renderer, lighting, presets, and floor configuration.
@@ -18,6 +42,50 @@ export class PropertyScene3D extends AbstractProperty {
18
42
  constructor() {
19
43
  super(...arguments);
20
44
  this.scene = null;
45
+ /** The browser is being asked where it is, for the board's latitude and longitude (ADR-0263). */
46
+ /* The modeller's simulation (ADR-0263): today played in a minute, shown and not saved. */
47
+ this.simulating = false;
48
+ this.simulatedAt = '';
49
+ this.locating = false;
50
+ }
51
+ /** The board's model layer, which shows a context without saving it. */
52
+ get vibeLayer() {
53
+ var _a, _b, _c, _d, _e;
54
+ const scene = this.scene;
55
+ return [scene === null || scene === void 0 ? void 0 : scene.root, (_a = scene === null || scene === void 0 ? void 0 : scene.root) === null || _a === void 0 ? void 0 : _a.root, (_c = (_b = scene === null || scene === void 0 ? void 0 : scene.rootContainer) === null || _b === void 0 ? void 0 : _b.components) === null || _c === void 0 ? void 0 : _c[0], (_e = (_d = scene === null || scene === void 0 ? void 0 : scene.root) === null || _d === void 0 ? void 0 : _d.components) === null || _e === void 0 ? void 0 : _e[0]].find(c => typeof (c === null || c === void 0 ? void 0 : c.previewVibe) === 'function');
56
+ }
57
+ startSimulation(vibe) {
58
+ const layer = this.vibeLayer;
59
+ if (!(layer === null || layer === void 0 ? void 0 : layer.previewVibe))
60
+ return;
61
+ const d = new Date();
62
+ const two = (n) => String(n).padStart(2, '0');
63
+ /* From 4:30 this morning, so dawn comes soon; a day in a minute, slower near sunrise and sunset. */
64
+ const start = withOffset(`${d.getFullYear()}-${two(d.getMonth() + 1)}-${two(d.getDate())}T04:30`);
65
+ const { enabled, ...rest } = vibe;
66
+ layer.previewVibe({ ...rest, mode: 'cycle', cycleSeconds: 60, time: start });
67
+ this.simulating = true;
68
+ this.simulationClock = setInterval(() => {
69
+ var _a;
70
+ const t = (_a = this.vibeLayer) === null || _a === void 0 ? void 0 : _a.vibeShownTime;
71
+ if (!t)
72
+ return;
73
+ const at = new Date(t);
74
+ this.simulatedAt = `${at.getMonth() + 1}/${at.getDate()} ${two(at.getHours())}:${two(at.getMinutes())}`;
75
+ }, 250);
76
+ }
77
+ stopSimulation() {
78
+ var _a, _b;
79
+ clearInterval(this.simulationClock);
80
+ this.simulationClock = undefined;
81
+ this.simulating = false;
82
+ this.simulatedAt = '';
83
+ (_b = (_a = this.vibeLayer) === null || _a === void 0 ? void 0 : _a.previewVibe) === null || _b === void 0 ? void 0 : _b.call(_a, undefined);
84
+ }
85
+ disconnectedCallback() {
86
+ if (this.simulating)
87
+ this.stopSimulation();
88
+ super.disconnectedCallback();
21
89
  }
22
90
  render() {
23
91
  var _a, _b;
@@ -29,7 +97,7 @@ export class PropertyScene3D extends AbstractProperty {
29
97
  return html `
30
98
  ${this._renderMode(value)} ${this._renderComposition(value)} ${this._renderPlacement(value)}
31
99
  ${this._renderCamera(value)}
32
- ${this._renderRenderer(value)} ${this._renderSky(value)}
100
+ ${this._renderRenderer(value)} ${this._renderSky(value)} ${this._renderVibe()}
33
101
  ${this._renderHemisphereLight(value)} ${this._renderKeyLight(value)} ${this._renderLightingPresets()}
34
102
  ${this._renderFloor(value)} ${this._renderThemeOverrides()}
35
103
  `;
@@ -316,6 +384,209 @@ export class PropertyScene3D extends AbstractProperty {
316
384
  </fieldset>
317
385
  `;
318
386
  }
387
+ /**
388
+ * The board's context (ADR-0263): turned on, the sun, sky light and background follow the time, date and weather,
389
+ * and lamps light after sunset. Turned off, the values are kept and the board shows its own look.
390
+ */
391
+ _renderVibe() {
392
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
393
+ const own = (_a = this.value) === null || _a === void 0 ? void 0 : _a.vibe;
394
+ const vibe = own && typeof own === 'object' ? own : {};
395
+ const on = !!own && typeof own === 'object' && vibe.enabled !== false;
396
+ /* As the scene reads it: a context without a mode stays at its time. */
397
+ const mode = vibe.mode || 'fixed';
398
+ const send = (next) => this.dispatchEvent(new CustomEvent('property-change', { bubbles: true, composed: true, detail: { vibe: next } }));
399
+ const put = (key, v) => {
400
+ const { [key]: _, ...rest } = vibe;
401
+ send(v === undefined || v === '' || (typeof v === 'number' && !Number.isFinite(v)) ? rest : { ...rest, [key]: v });
402
+ };
403
+ const number = (key) => (e) => {
404
+ e.stopPropagation();
405
+ const input = e.target;
406
+ put(key, input.value === '' ? undefined : Number(input.value));
407
+ };
408
+ return html `
409
+ <fieldset>
410
+ <legend><ox-i18n msgid="label.vibe">Time and weather</ox-i18n></legend>
411
+ <div class="property-grid">
412
+ <input
413
+ id="cb-vibe"
414
+ type="checkbox"
415
+ .checked=${on}
416
+ @change=${(e) => {
417
+ e.stopPropagation();
418
+ const checked = e.target.checked;
419
+ const { enabled, ...rest } = vibe;
420
+ /* Turned on for the first time, the board follows the clock. */
421
+ send(checked ? { mode: 'live', ...rest } : { ...rest, enabled: false });
422
+ }}
423
+ />
424
+ <label for="cb-vibe"><ox-i18n msgid="label.vibe on">Light and sky follow the time and weather</ox-i18n></label>
425
+ ${on
426
+ ? html `
427
+ <div class="vibe-note"><ox-i18n msgid="text.vibe lighting">The lighting below is the reference: a clear day with the sun 45° high.</ox-i18n></div>
428
+ <div class="vibe-locate">
429
+ <button @click=${() => (this.simulating ? this.stopSimulation() : this.startSimulation(vibe))}>
430
+ ${this.simulating
431
+ ? html `<ox-i18n msgid="button.vibe stop simulation">Stop</ox-i18n>`
432
+ : html `<ox-i18n msgid="button.vibe simulate day">Simulate a day</ox-i18n>`}
433
+ </button>
434
+ ${this.simulating ? html `<span>${this.simulatedAt}</span>` : ''}
435
+ </div>
436
+ <input
437
+ id="cb-vibe-indoor"
438
+ type="checkbox"
439
+ .checked=${vibe.indoor === true}
440
+ @change=${(e) => {
441
+ e.stopPropagation();
442
+ put('indoor', e.target.checked ? true : undefined);
443
+ }}
444
+ />
445
+ <label for="cb-vibe-indoor"><ox-i18n msgid="label.vibe indoor">Indoors: own lighting, no rain or snow</ox-i18n></label>
446
+ <label><ox-i18n msgid="label.vibe mode">Time</ox-i18n></label>
447
+ <select
448
+ @change=${(e) => {
449
+ e.stopPropagation();
450
+ put('mode', e.target.value);
451
+ }}
452
+ >
453
+ ${['live', 'fixed', 'cycle'].map(m => html `<option value=${m} ?selected=${mode === m}>${i18next.t(`label.vibe mode ${m}`)}</option>`)}
454
+ </select>
455
+ ${mode === 'live'
456
+ ? ''
457
+ : html `
458
+ <label><ox-i18n msgid=${mode === 'cycle' ? 'label.vibe start' : 'label.vibe time'}>Date and time</ox-i18n></label>
459
+ <input
460
+ type="datetime-local"
461
+ .value=${localDateTime(vibe.time)}
462
+ @change=${(e) => {
463
+ e.stopPropagation();
464
+ put('time', withOffset(e.target.value));
465
+ }}
466
+ />
467
+ `}
468
+ ${mode === 'cycle'
469
+ ? html `
470
+ <label><ox-i18n msgid="label.vibe cycle seconds">Seconds a day takes</ox-i18n></label>
471
+ <input type="number" min="10" step="10" placeholder="120" .value=${String((_b = vibe.cycleSeconds) !== null && _b !== void 0 ? _b : '')} @change=${number('cycleSeconds')} />
472
+ `
473
+ : ''}
474
+ <label><ox-i18n msgid="label.vibe latitude">Latitude</ox-i18n></label>
475
+ <input type="number" min="-90" max="90" step="0.01" placeholder="36" .value=${String((_c = vibe.latitude) !== null && _c !== void 0 ? _c : '')} @change=${number('latitude')} />
476
+ <label><ox-i18n msgid="label.vibe longitude">Longitude</ox-i18n></label>
477
+ <input type="number" min="-180" max="180" step="0.01" placeholder="127" .value=${String((_d = vibe.longitude) !== null && _d !== void 0 ? _d : '')} @change=${number('longitude')} />
478
+ <div class="vibe-locate">
479
+ <button
480
+ ?disabled=${this.locating}
481
+ @click=${() => {
482
+ /* A browser gives its location only to a secure page (HTTPS or localhost) that may ask for it. */
483
+ if (!window.isSecureContext)
484
+ return void (this.locateFailed = 'insecure');
485
+ if (!navigator.geolocation)
486
+ return void (this.locateFailed = 'unsupported');
487
+ this.locating = true;
488
+ this.locateFailed = undefined;
489
+ navigator.geolocation.getCurrentPosition(position => {
490
+ this.locating = false;
491
+ /* Two decimals: about 1 km, all the sun's position needs. */
492
+ const round = (v) => Math.round(v * 100) / 100;
493
+ const { latitude, longitude, ...rest } = vibe;
494
+ this.dispatchEvent(new CustomEvent('property-change', {
495
+ bubbles: true,
496
+ composed: true,
497
+ detail: { vibe: { ...rest, latitude: round(position.coords.latitude), longitude: round(position.coords.longitude) } }
498
+ }));
499
+ }, error => {
500
+ this.locating = false;
501
+ /* GeolocationPositionError: 1 the user or a policy refused, 2 none could be found, 3 timed out. */
502
+ this.locateFailed = error.code === 1 ? 'denied' : error.code === 3 ? 'timeout' : 'unavailable';
503
+ }, { timeout: 10000, maximumAge: 600000 });
504
+ }}
505
+ >
506
+ <ox-i18n msgid="button.vibe current location">Current location</ox-i18n>
507
+ </button>
508
+ ${this.locateFailed ? html `<span class="vibe-locate-failed">${i18next.t(`text.vibe location ${this.locateFailed}`)}</span>` : ''}
509
+ </div>
510
+ <label title=${i18next.t('label.vibe north help')}><ox-i18n msgid="label.vibe north">Bearing of the board's top (°)</ox-i18n></label>
511
+ <input type="number" min="0" max="360" step="1" placeholder="0" .value=${String((_e = vibe.north) !== null && _e !== void 0 ? _e : '')} @change=${number('north')} />
512
+ <label><ox-i18n msgid="label.vibe cloud">Cloud cover</ox-i18n></label>
513
+ <div class="range-with-value">
514
+ <input type="range" min="0" max="1" step="0.05" .value=${String((_f = vibe.cloud) !== null && _f !== void 0 ? _f : 0)} @change=${number('cloud')} />
515
+ <span>${Number((_g = vibe.cloud) !== null && _g !== void 0 ? _g : 0).toFixed(2)}</span>
516
+ </div>
517
+ <label><ox-i18n msgid="label.vibe precipitation">Precipitation</ox-i18n></label>
518
+ <select
519
+ @change=${(e) => {
520
+ e.stopPropagation();
521
+ const v = e.target.value;
522
+ put('precipitation', v === 'none' ? undefined : v);
523
+ }}
524
+ >
525
+ ${['none', 'rain', 'snow'].map(k => html `<option value=${k} ?selected=${(vibe.precipitation || 'none') === k}>${i18next.t(`label.vibe precipitation ${k}`)}</option>`)}
526
+ </select>
527
+ ${vibe.precipitation === 'rain' || vibe.precipitation === 'snow'
528
+ ? html `
529
+ <label><ox-i18n msgid="label.vibe intensity">Intensity</ox-i18n></label>
530
+ <div class="range-with-value">
531
+ <input type="range" min="0" max="1" step="0.05" .value=${String((_h = vibe.intensity) !== null && _h !== void 0 ? _h : 0.5)} @change=${number('intensity')} />
532
+ <span>${Number((_j = vibe.intensity) !== null && _j !== void 0 ? _j : 0.5).toFixed(2)}</span>
533
+ </div>
534
+ `
535
+ : ''}
536
+ <label class="as-written"><ox-i18n msgid="label.vibe visibility">Visibility (m)</ox-i18n></label>
537
+ <input type="number" min="10" step="10" placeholder=${i18next.t('text.vibe auto')} .value=${String((_k = vibe.visibility) !== null && _k !== void 0 ? _k : '')} @change=${number('visibility')} />
538
+ <label><ox-i18n msgid="label.vibe snow cover">Snow cover (0-1)</ox-i18n></label>
539
+ <input type="number" min="0" max="1" step="0.1" placeholder=${i18next.t('text.vibe auto')} .value=${String((_l = vibe.snowCover) !== null && _l !== void 0 ? _l : '')} @change=${number('snowCover')} />
540
+ <label><ox-i18n msgid="label.vibe wet">Wet ground (0-1)</ox-i18n></label>
541
+ <input type="number" min="0" max="1" step="0.1" placeholder=${i18next.t('text.vibe auto')} .value=${String((_m = vibe.wet) !== null && _m !== void 0 ? _m : '')} @change=${number('wet')} />
542
+ <label><ox-i18n msgid="label.vibe dust">Yellow dust</ox-i18n></label>
543
+ <div class="range-with-value">
544
+ <input type="range" min="0" max="1" step="0.05" .value=${String((_o = vibe.dust) !== null && _o !== void 0 ? _o : 0)} @change=${number('dust')} />
545
+ <span>${Number((_p = vibe.dust) !== null && _p !== void 0 ? _p : 0).toFixed(2)}</span>
546
+ </div>
547
+ ${this._renderFoliage(vibe, put)}
548
+ `
549
+ : ''}
550
+ </div>
551
+ </fieldset>
552
+ `;
553
+ }
554
+ /**
555
+ * The palette tokens that are leaves, and the kind of tree (ADR-0263 stage 4): their colours follow the season. One
556
+ * kind for the tokens given, as most boards have one kind of tree.
557
+ */
558
+ _renderFoliage(vibe, put) {
559
+ const foliage = vibe.foliage && typeof vibe.foliage === 'object' ? vibe.foliage : {};
560
+ const tokens = Object.keys(foliage);
561
+ const kind = (tokens.length && foliage[tokens[0]]) || 'deciduous';
562
+ const set = (names, k) => put('foliage', names.length ? Object.fromEntries(names.map(n => [n, k])) : undefined);
563
+ return html `
564
+ <label><ox-i18n msgid="label.vibe foliage tokens">Leaf tokens</ox-i18n></label>
565
+ <input
566
+ type="text"
567
+ placeholder="palette.leaf, palette.leaf-dark"
568
+ .value=${tokens.join(', ')}
569
+ @change=${(e) => {
570
+ e.stopPropagation();
571
+ const names = e.target.value.split(/[\s,]+/).map(t => t.trim()).filter(Boolean);
572
+ set(names, kind);
573
+ }}
574
+ />
575
+ ${tokens.length
576
+ ? html `
577
+ <label><ox-i18n msgid="label.vibe foliage kind">Kind of tree</ox-i18n></label>
578
+ <select
579
+ @change=${(e) => {
580
+ e.stopPropagation();
581
+ set(tokens, e.target.value);
582
+ }}
583
+ >
584
+ ${['deciduous', 'evergreen', 'blossom'].map(k => html `<option value=${k} ?selected=${kind === k}>${i18next.t(`label.vibe foliage ${k}`)}</option>`)}
585
+ </select>
586
+ `
587
+ : ''}
588
+ `;
589
+ }
319
590
  /**
320
591
  * Environment 선택 핸들러 — sky 필드만 바꾸는 게 아니라 ENVIRONMENT_DEFAULTS에
321
592
  * 정의된 hemi/dir 기본 조명까지 한 번의 property-change로 함께 적용한다.
@@ -611,6 +882,45 @@ PropertyScene3D.styles = [
611
882
  cursor: pointer;
612
883
  }
613
884
 
885
+ /* A label with a unit: as written (the grid's labels capitalise, m would show as M). */
886
+ .property-grid > label.as-written {
887
+ text-transform: none;
888
+ }
889
+
890
+ /* The board's latitude and longitude from where this computer is: a button under them. */
891
+ .vibe-locate {
892
+ grid-column: 10 / -1;
893
+ display: flex;
894
+ flex-wrap: wrap;
895
+ align-items: center;
896
+ gap: 8px;
897
+ font-size: 0.74rem;
898
+ color: var(--md-sys-color-on-surface-variant);
899
+ }
900
+
901
+ .vibe-locate-failed {
902
+ flex: 1 1 100%;
903
+ line-height: 1.4;
904
+ }
905
+
906
+ .vibe-locate button {
907
+ font-size: 12px;
908
+ padding: 4px 10px;
909
+ border: 1px solid var(--md-sys-color-outline, #c4c7c5);
910
+ border-radius: 4px;
911
+ background: var(--md-sys-color-surface, #fff);
912
+ color: var(--md-sys-color-on-surface, #1c1b1f);
913
+ cursor: pointer;
914
+ }
915
+
916
+ /* What the context does to the lighting below: one line across the panel. */
917
+ .vibe-note {
918
+ grid-column: 1 / -1;
919
+ font-size: 0.72rem;
920
+ line-height: 1.4;
921
+ color: var(--md-sys-color-on-surface-variant);
922
+ }
923
+
614
924
  button.scene-look-value:hover {
615
925
  background: var(--md-sys-color-surface-variant, #e7e0ec);
616
926
  }
@@ -623,4 +933,16 @@ __decorate([
623
933
  __decorate([
624
934
  property({ type: Object })
625
935
  ], PropertyScene3D.prototype, "scene", void 0);
936
+ __decorate([
937
+ state()
938
+ ], PropertyScene3D.prototype, "simulating", void 0);
939
+ __decorate([
940
+ state()
941
+ ], PropertyScene3D.prototype, "simulatedAt", void 0);
942
+ __decorate([
943
+ state()
944
+ ], PropertyScene3D.prototype, "locating", void 0);
945
+ __decorate([
946
+ state()
947
+ ], PropertyScene3D.prototype, "locateFailed", void 0);
626
948
  //# sourceMappingURL=property-scene3d.js.map
@@ -15,5 +15,7 @@ export declare class Property3D extends AbstractProperty {
15
15
  firstUpdated(): void;
16
16
  render(): import("lit-html").TemplateResult<1>;
17
17
  private _renderAutoPanel;
18
+ private _renderLamp;
19
+ private _renderIndoor;
18
20
  onValueChange(e: Event): void;
19
21
  }
@@ -14,7 +14,7 @@ import './property-material3d.js';
14
14
  * 컴포넌트 3D 와 씬 3D 는 같은 탭의 두 얼굴이라 같은 문으로 나가는 것이 맞다.
15
15
  */
16
16
  export { PropertyScene3D } from './property-scene3d.js';
17
- import { html } from 'lit';
17
+ import { css, html } from 'lit';
18
18
  import { property } from 'lit/decorators.js';
19
19
  import { i18next } from '@operato/i18n';
20
20
  import { PropertyGridStyles } from '@operato/styles/property-grid-styles.js';
@@ -111,7 +111,7 @@ export class Property3D extends AbstractProperty {
111
111
  </div>
112
112
  </fieldset>
113
113
 
114
- ${this._renderAutoPanel(value)}
114
+ ${this._renderAutoPanel(value)} ${this._renderLamp(value)} ${this._renderIndoor(value)}
115
115
 
116
116
  <property-material3d .value=${value.material3d}></property-material3d>
117
117
  `;
@@ -162,6 +162,122 @@ export class Property3D extends AbstractProperty {
162
162
  </fieldset>
163
163
  `;
164
164
  }
165
+ /*
166
+ * A lamp (ADR-0263): on a board whose light follows the time, it lights after sunset. Where its light comes out is
167
+ * measured from the middle of the component's footprint: along its width, up from its bottom, along its depth.
168
+ * Turned off, the values are kept.
169
+ */
170
+ _renderLamp(value) {
171
+ var _a, _b;
172
+ /* A component may have several lamps (a light over each door): the panel edits the first and keeps the others. */
173
+ const list = Array.isArray(value.lamp) ? value.lamp : undefined;
174
+ const own = list ? list[0] : value.lamp;
175
+ const lamp = own && typeof own === 'object' ? own : {};
176
+ const on = !!own && lamp.enabled !== false;
177
+ const send = (next) => this.dispatchEvent(new CustomEvent('property-change', { bubbles: true, composed: true, detail: { lamp: list ? [next !== null && next !== void 0 ? next : { enabled: false }, ...list.slice(1)] : next } }));
178
+ const triple = (key, i, fallback) => (e) => {
179
+ e.stopPropagation();
180
+ const n = Number(e.target.value);
181
+ const next = [...(Array.isArray(lamp[key]) ? lamp[key] : fallback)];
182
+ next[i] = Number.isFinite(n) ? n : 0;
183
+ send({ ...lamp, [key]: next });
184
+ };
185
+ const one = (key) => (e) => {
186
+ e.stopPropagation();
187
+ const input = e.target;
188
+ const { [key]: _, ...rest } = lamp;
189
+ send(input.value === '' ? rest : { ...rest, [key]: Number(input.value) });
190
+ };
191
+ const at = Array.isArray(lamp.at) ? lamp.at : [0, 0, 0];
192
+ const size = Array.isArray(lamp.size) ? lamp.size : [400, 200];
193
+ return html `
194
+ <fieldset>
195
+ <legend><ox-i18n msgid="label.lamp">Lamp</ox-i18n></legend>
196
+ <div class="property-grid">
197
+ <input
198
+ id="cb-lamp"
199
+ type="checkbox"
200
+ .checked=${on}
201
+ @change=${(e) => {
202
+ e.stopPropagation();
203
+ const { enabled, ...rest } = lamp;
204
+ send(e.target.checked ? rest : { ...rest, enabled: false });
205
+ }}
206
+ />
207
+ <label for="cb-lamp"><ox-i18n msgid="label.lamp on">Lights up after sunset</ox-i18n></label>
208
+ ${on
209
+ ? html `
210
+ <label class="fullwidth caption"><ox-i18n msgid="label.lamp position">Light position (mm)</ox-i18n></label>
211
+ ${['X', 'Y', 'Z'].map((axis, i) => {
212
+ var _a;
213
+ return html `<div class="field third" title=${axis}>
214
+ <span>${axis}</span>
215
+ <input type="number" step="10" .value=${String((_a = at[i]) !== null && _a !== void 0 ? _a : 0)} @change=${triple('at', i, [0, 0, 0])} />
216
+ </div>`;
217
+ })}
218
+ <label class="fullwidth caption"><ox-i18n msgid="label.lamp size">Lit face (mm)</ox-i18n></label>
219
+ ${['W', 'D'].map((axis, i) => html `<div class="field half" title=${axis}>
220
+ <span>${axis}</span>
221
+ <input
222
+ type="number"
223
+ min="1"
224
+ step="10"
225
+ .value=${String(size[i])}
226
+ @change=${(e) => {
227
+ e.stopPropagation();
228
+ const n = Number(e.target.value);
229
+ const next = [...size];
230
+ next[i] = Number.isFinite(n) && n > 0 ? n : size[i];
231
+ send({ ...lamp, size: next });
232
+ }}
233
+ />
234
+ </div>`)}
235
+ <label><ox-i18n msgid="label.lamp kelvin">Colour temperature (K)</ox-i18n></label>
236
+ <input type="number" min="1800" max="6500" step="100" placeholder="4000" .value=${String((_a = lamp.kelvin) !== null && _a !== void 0 ? _a : '')} @change=${one('kelvin')} />
237
+ <label><ox-i18n msgid="label.lamp level">Strength</ox-i18n></label>
238
+ <input type="number" min="0" max="5" step="0.1" placeholder="1" .value=${String((_b = lamp.level) !== null && _b !== void 0 ? _b : '')} @change=${one('level')} />
239
+ <input
240
+ id="cb-lamp-always"
241
+ type="checkbox"
242
+ .checked=${lamp.switch === 'always'}
243
+ @change=${(e) => {
244
+ e.stopPropagation();
245
+ const { switch: _, ...rest } = lamp;
246
+ send(e.target.checked ? { ...rest, switch: 'always' } : rest);
247
+ }}
248
+ />
249
+ <label for="cb-lamp-always"><ox-i18n msgid="label.lamp always">Always on (a light indoors)</ox-i18n></label>
250
+ ${list && list.length > 1 ? html `<div class="fullwidth caption-note">${i18next.t('text.lamp more', { count: list.length - 1 })}</div>` : ''}
251
+ `
252
+ : ''}
253
+ </div>
254
+ </fieldset>
255
+ `;
256
+ }
257
+ /*
258
+ * An indoor space (ADR-0263 stage 5): on a board whose light follows the time and weather, what is inside this
259
+ * component's box keeps its own lighting at night, stays dry, and no rain or snow falls in it.
260
+ */
261
+ _renderIndoor(value) {
262
+ return html `
263
+ <fieldset>
264
+ <legend><ox-i18n msgid="label.indoor">Indoors</ox-i18n></legend>
265
+ <div class="property-grid">
266
+ <input
267
+ id="cb-indoor"
268
+ type="checkbox"
269
+ .checked=${value.indoor === true}
270
+ @change=${(e) => {
271
+ e.stopPropagation();
272
+ const checked = e.target.checked;
273
+ this.dispatchEvent(new CustomEvent('property-change', { bubbles: true, composed: true, detail: { indoor: checked ? true : undefined } }));
274
+ }}
275
+ />
276
+ <label for="cb-indoor"><ox-i18n msgid="label.indoor space">An indoor space: lit at night, dry</ox-i18n></label>
277
+ </div>
278
+ </fieldset>
279
+ `;
280
+ }
165
281
  onValueChange(e) {
166
282
  var _a, _b;
167
283
  var element = e.target;
@@ -190,7 +306,23 @@ export class Property3D extends AbstractProperty {
190
306
  }
191
307
  }
192
308
  }
193
- Property3D.styles = [PropertyGridStyles, SizeLimitStyles];
309
+ Property3D.styles = [
310
+ PropertyGridStyles,
311
+ SizeLimitStyles,
312
+ css `
313
+ /* A caption over a row of fields: left, and its unit as written (the grid's labels capitalise). */
314
+ .property-grid > .caption-note {
315
+ font-size: 0.72rem;
316
+ color: var(--md-sys-color-on-surface-variant);
317
+ }
318
+
319
+ .property-grid > label.caption {
320
+ justify-content: flex-start;
321
+ text-align: left;
322
+ text-transform: none;
323
+ }
324
+ `
325
+ ];
194
326
  __decorate([
195
327
  property({ type: Object })
196
328
  ], Property3D.prototype, "value", void 0);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@operato/property-panel",
3
3
  "description": "Webcomponent property-panel following open-wc recommendations",
4
4
  "author": "heartyoh",
5
- "version": "10.29.109",
5
+ "version": "10.29.110",
6
6
  "type": "module",
7
7
  "main": "dist/src/index.js",
8
8
  "module": "dist/src/index.js",
@@ -87,10 +87,10 @@
87
87
  },
88
88
  "dependencies": {
89
89
  "@material/web": "^2.0.0",
90
- "@operato/app": "^10.29.103",
91
- "@operato/attachment": "^10.29.103",
90
+ "@operato/app": "^10.29.110",
91
+ "@operato/attachment": "^10.29.110",
92
92
  "@operato/i18n": "^10.29.85",
93
- "@operato/input": "^10.29.96",
93
+ "@operato/input": "^10.29.110",
94
94
  "@operato/styles": "^10.29.83",
95
95
  "@operato/utils": "^10.29.85",
96
96
  "lit": "^3.1.2"
@@ -128,5 +128,5 @@
128
128
  "prettier --write"
129
129
  ]
130
130
  },
131
- "gitHead": "874663836d54a024c61f9c81dfaf65ba146aba60"
131
+ "gitHead": "1f632dc24479906d67512d7c8564e119ca021bae"
132
132
  }
@@ -814,5 +814,54 @@
814
814
  "label.auto panel by type": "As the board sets for its type",
815
815
  "label.auto panel on": "Show",
816
816
  "label.auto panel off": "Do not show",
817
- "label.auto panel priority": "Priority"
817
+ "label.auto panel priority": "Priority",
818
+ "label.vibe": "Time and weather",
819
+ "label.vibe on": "Light and sky follow the time and weather",
820
+ "label.vibe mode": "Time",
821
+ "label.vibe mode live": "The current time",
822
+ "label.vibe mode fixed": "A set date and time",
823
+ "label.vibe mode cycle": "A day played back",
824
+ "label.vibe time": "Date and time",
825
+ "label.vibe start": "Playback starts at",
826
+ "label.vibe cycle seconds": "Seconds a day takes",
827
+ "label.vibe latitude": "Latitude",
828
+ "label.vibe longitude": "Longitude",
829
+ "label.vibe north": "Bearing of the board's top (°)",
830
+ "label.vibe north help": "The direction the board's top faces: north 0°, east 90°, south 180°, west 270°.",
831
+ "label.vibe cloud": "Cloud cover",
832
+ "label.lamp": "Lamp",
833
+ "label.lamp on": "Lights up after sunset",
834
+ "label.lamp position": "Light position (mm)",
835
+ "label.lamp size": "Lit face (mm)",
836
+ "label.lamp kelvin": "Colour temperature (K)",
837
+ "label.lamp level": "Strength",
838
+ "text.vibe lighting": "The lighting below is the reference, a clear day with the sun 45° high; the scene is lit from the time and weather.",
839
+ "label.vibe precipitation": "Precipitation",
840
+ "label.vibe precipitation none": "None",
841
+ "label.vibe precipitation rain": "Rain",
842
+ "label.vibe precipitation snow": "Snow",
843
+ "label.vibe intensity": "Intensity",
844
+ "label.vibe visibility": "Visibility (m)",
845
+ "label.vibe snow cover": "Snow cover (0-1)",
846
+ "label.vibe wet": "Wet ground (0-1)",
847
+ "text.vibe auto": "auto",
848
+ "label.vibe dust": "Yellow dust",
849
+ "label.vibe foliage tokens": "Leaf tokens",
850
+ "label.vibe foliage kind": "Kind of tree",
851
+ "label.vibe foliage deciduous": "Deciduous",
852
+ "label.vibe foliage evergreen": "Evergreen",
853
+ "label.vibe foliage blossom": "Flowering (cherry)",
854
+ "button.vibe current location": "Current location",
855
+ "text.vibe location unavailable": "The location could not be read. Check that the system's location services are on.",
856
+ "label.vibe indoor": "Indoors: own lighting, no rain or snow",
857
+ "label.lamp always": "Always on (a light indoors)",
858
+ "text.lamp more": "This component has {{count}} more lamps; change them in the board's source.",
859
+ "label.indoor": "Indoors",
860
+ "label.indoor space": "An indoor space: lit at night, dry",
861
+ "button.vibe simulate day": "Simulate a day",
862
+ "button.vibe stop simulation": "Stop",
863
+ "text.vibe location insecure": "The location is given only to a secure (HTTPS) address. Enter the latitude and longitude.",
864
+ "text.vibe location unsupported": "This browser does not give its location. Enter the latitude and longitude.",
865
+ "text.vibe location denied": "Permission to use the location was refused. Allow the location in the site settings by the address bar, and check that the system's location services are on.",
866
+ "text.vibe location timeout": "Reading the location took too long. Try again."
818
867
  }
@@ -838,5 +838,54 @@
838
838
  "label.auto panel by type": "보드의 유형별 설정 따름",
839
839
  "label.auto panel on": "표시",
840
840
  "label.auto panel off": "표시 안 함",
841
- "label.auto panel priority": "우선순위"
841
+ "label.auto panel priority": "우선순위",
842
+ "label.vibe": "시각·날씨",
843
+ "label.vibe on": "시각과 날씨에 따라 빛과 하늘 변경",
844
+ "label.vibe mode": "기준 시각",
845
+ "label.vibe mode live": "현재 시각",
846
+ "label.vibe mode fixed": "지정 일시",
847
+ "label.vibe mode cycle": "하루 재생",
848
+ "label.vibe time": "일시",
849
+ "label.vibe start": "재생 시작 일시",
850
+ "label.vibe cycle seconds": "하루 재생 시간(초)",
851
+ "label.vibe latitude": "위도",
852
+ "label.vibe longitude": "경도",
853
+ "label.vibe north": "보드 위쪽 방위(°)",
854
+ "label.vibe north help": "보드 위쪽이 향하는 방위입니다. 북쪽 0°, 동쪽 90°, 남쪽 180°, 서쪽 270°입니다.",
855
+ "label.vibe cloud": "운량",
856
+ "label.lamp": "조명 기구",
857
+ "label.lamp on": "해가 지면 점등",
858
+ "label.lamp position": "발광 위치(mm)",
859
+ "label.lamp size": "발광면 크기(mm)",
860
+ "label.lamp kelvin": "색온도(K)",
861
+ "label.lamp level": "밝기 배율",
862
+ "text.vibe lighting": "아래 조명 값은 해 높이 45°, 맑은 날의 기준값입니다. 화면의 조명은 시각과 날씨에 따라 계산됩니다.",
863
+ "label.vibe precipitation": "강수",
864
+ "label.vibe precipitation none": "없음",
865
+ "label.vibe precipitation rain": "비",
866
+ "label.vibe precipitation snow": "눈",
867
+ "label.vibe intensity": "강수 강도",
868
+ "label.vibe visibility": "시정(m)",
869
+ "label.vibe snow cover": "적설(0~1)",
870
+ "label.vibe wet": "노면 젖음(0~1)",
871
+ "text.vibe auto": "자동",
872
+ "label.vibe dust": "황사",
873
+ "label.vibe foliage tokens": "나뭇잎 토큰",
874
+ "label.vibe foliage kind": "나무 종류",
875
+ "label.vibe foliage deciduous": "낙엽수",
876
+ "label.vibe foliage evergreen": "상록수",
877
+ "label.vibe foliage blossom": "꽃나무(벚나무)",
878
+ "button.vibe current location": "현재 위치",
879
+ "text.vibe location unavailable": "위치를 확인할 수 없습니다. 운영체제의 위치 서비스가 켜져 있는지 확인하세요.",
880
+ "label.vibe indoor": "실내 보드(조명 유지·강수 없음)",
881
+ "label.lamp always": "항상 점등(실내 조명)",
882
+ "text.lamp more": "이 컴포넌트에는 조명 기구가 {{count}}개 더 있습니다. 보드 원본에서 수정하세요.",
883
+ "label.indoor": "실내",
884
+ "label.indoor space": "실내 공간(밤에도 조명 유지·젖지 않음)",
885
+ "button.vibe simulate day": "하루 시뮬레이션",
886
+ "button.vibe stop simulation": "중지",
887
+ "text.vibe location insecure": "보안 연결(HTTPS) 주소에서만 위치를 확인할 수 있습니다. 위도·경도를 직접 입력하세요.",
888
+ "text.vibe location unsupported": "이 브라우저는 위치 정보를 지원하지 않습니다. 위도·경도를 직접 입력하세요.",
889
+ "text.vibe location denied": "위치 권한이 거부되었습니다. 주소창의 사이트 설정에서 위치를 허용하고, 운영체제의 위치 서비스가 켜져 있는지 확인하세요.",
890
+ "text.vibe location timeout": "위치 확인 시간이 초과되었습니다. 다시 시도하세요."
842
891
  }