@operato/property-editor 10.29.80 → 10.29.81

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/CHANGELOG.md CHANGED
@@ -3,6 +3,15 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ### [10.29.81](https://github.com/hatiolab/operato/compare/v10.29.80...v10.29.81) (2026-11-11)
7
+
8
+
9
+ ### :rocket: New Features
10
+
11
+ * **property-editor:** a number-map entry marked mixed shows it is mixed, not its default ([31c278d](https://github.com/hatiolab/operato/commit/31c278d6c3f17f311a6888a0f38fd3ea97e28ecf))
12
+
13
+
14
+
6
15
  ### [10.29.80](https://github.com/hatiolab/operato/compare/v10.29.79...v10.29.80) (2026-11-11)
7
16
 
8
17
  **Note:** Version bump only for package @operato/property-editor
@@ -15,6 +15,12 @@ export interface NumberMapEntry {
15
15
  /** For an enum: the values it may take. */
16
16
  values?: string[];
17
17
  default?: number | boolean | string;
18
+ /**
19
+ * The things edited together hold different values here (several selected). While the map holds no value for the
20
+ * entry it is shown as mixed -- an empty field saying so, no thumb on the slider, no choice made, an indeterminate
21
+ * checkbox -- not as its default, which none of them may hold. A value given to it is shown as any other.
22
+ */
23
+ mixed?: boolean;
18
24
  }
19
25
  /**
20
26
  * Several numbers kept as one map ({ key: number }) -- a figure's design values and state values a board sets
@@ -28,11 +34,17 @@ export interface NumberMapEntry {
28
34
  *
29
35
  * `property.nested`: a key `a.b` is the value `b` inside the map's `a` -- a figure's motion settings, one map per group
30
36
  * (`{ locomotion: { clip, speed, paused } }`, ADR-0051 §3.2). The key splits at its first dot only.
37
+ *
38
+ * An entry marked `mixed` (several things edited together that hold different values there) is shown as mixed until
39
+ * the map holds a value for it.
31
40
  */
32
41
  export declare class OxPropertyEditorNumberMap extends OxPropertyEditor {
33
42
  static styles: import("lit").CSSResult[];
34
43
  editorTemplate(value: any, spec: PropertySpec): TemplateResult;
35
- /** A checkbox for a boolean, a choice for an enum: what is shown is what the map holds, or the entry's default. */
44
+ /**
45
+ * A checkbox for a boolean, a choice for an enum: what is shown is what the map holds, or the entry's default. A mixed
46
+ * entry is an indeterminate checkbox, or a choice that says it is mixed and is not one of the values.
47
+ */
36
48
  private choiceRow;
37
49
  /** The value a key holds in the map: `a.b` inside `a` when the map is nested. */
38
50
  private read;
@@ -2,7 +2,12 @@ import { __decorate } from "tslib";
2
2
  import { css, html, nothing } from 'lit';
3
3
  import { customElement } from 'lit/decorators.js';
4
4
  import { ifDefined } from 'lit/directives/if-defined.js';
5
+ import { i18next } from '@operato/i18n';
5
6
  import { OxPropertyEditor } from './ox-property-editor.js';
7
+ /** The word a mixed entry shows: its own translation when the app has one. */
8
+ function mixedText() {
9
+ return i18next.t('text.mixed-values', { defaultValue: 'Mixed' });
10
+ }
6
11
  /**
7
12
  * Several numbers kept as one map ({ key: number }) -- a figure's design values and state values a board sets
8
13
  * (ADR-0096), a shelf's spacings. Each entry is one compact row: its name, a slider when it has a range, the number
@@ -15,6 +20,9 @@ import { OxPropertyEditor } from './ox-property-editor.js';
15
20
  *
16
21
  * `property.nested`: a key `a.b` is the value `b` inside the map's `a` -- a figure's motion settings, one map per group
17
22
  * (`{ locomotion: { clip, speed, paused } }`, ADR-0051 §3.2). The key splits at its first dot only.
23
+ *
24
+ * An entry marked `mixed` (several things edited together that hold different values there) is shown as mixed until
25
+ * the map holds a value for it.
18
26
  */
19
27
  let OxPropertyEditorNumberMap = class OxPropertyEditorNumberMap extends OxPropertyEditor {
20
28
  editorTemplate(value, spec) {
@@ -26,9 +34,10 @@ let OxPropertyEditorNumberMap = class OxPropertyEditorNumberMap extends OxProper
26
34
  ${entries.map(entry => {
27
35
  var _a;
28
36
  const held = this.read(value, entry.key, nested);
37
+ const mixed = !!entry.mixed && held === undefined;
29
38
  if (entry.kind === 'boolean' || entry.kind === 'enum')
30
- return this.choiceRow(entry, held !== null && held !== void 0 ? held : entry.default);
31
- const shown = (held !== null && held !== void 0 ? held : entry.default);
39
+ return this.choiceRow(entry, mixed ? undefined : held !== null && held !== void 0 ? held : entry.default, mixed);
40
+ const shown = mixed ? undefined : (held !== null && held !== void 0 ? held : entry.default);
32
41
  const ranged = this.rangeOf(entry);
33
42
  return html `
34
43
  <span name title=${entry.label}>${entry.label}</span>
@@ -40,8 +49,9 @@ let OxPropertyEditorNumberMap = class OxPropertyEditorNumberMap extends OxProper
40
49
  min=${ranged.min}
41
50
  max=${ranged.max}
42
51
  step=${ranged.step}
52
+ ?mixed=${mixed}
43
53
  .value=${String(shown !== null && shown !== void 0 ? shown : ranged.min)}
44
- style=${`--fill: ${this.fillOf(shown !== null && shown !== void 0 ? shown : ranged.min, ranged)}%`}
54
+ style=${`--fill: ${mixed ? 0 : this.fillOf(shown !== null && shown !== void 0 ? shown : ranged.min, ranged)}%`}
45
55
  ?disabled=${this.disabled}
46
56
  @input=${this.onSlide}
47
57
  />`
@@ -51,8 +61,10 @@ let OxPropertyEditorNumberMap = class OxPropertyEditorNumberMap extends OxProper
51
61
  data-key=${entry.key}
52
62
  aria-label=${entry.label}
53
63
  ?wide=${!ranged}
64
+ ?mixed=${mixed}
54
65
  .value=${String(shown !== null && shown !== void 0 ? shown : '')}
55
- placeholder=${ifDefined(this.hintOf(entry))}
66
+ title=${ifDefined(mixed ? this.hintOf(entry) : undefined)}
67
+ placeholder=${ifDefined(mixed ? mixedText() : this.hintOf(entry))}
56
68
  min=${ifDefined(entry.min)}
57
69
  max=${ifDefined(entry.max)}
58
70
  step="any"
@@ -64,15 +76,26 @@ let OxPropertyEditorNumberMap = class OxPropertyEditorNumberMap extends OxProper
64
76
  </div>
65
77
  `;
66
78
  }
67
- /** A checkbox for a boolean, a choice for an enum: what is shown is what the map holds, or the entry's default. */
68
- choiceRow(entry, shown) {
79
+ /**
80
+ * A checkbox for a boolean, a choice for an enum: what is shown is what the map holds, or the entry's default. A mixed
81
+ * entry is an indeterminate checkbox, or a choice that says it is mixed and is not one of the values.
82
+ */
83
+ choiceRow(entry, shown, mixed = false) {
69
84
  var _a, _b;
70
85
  return html `
71
86
  <span name title=${entry.label}>${entry.label}</span>
72
87
  ${entry.kind === 'boolean'
73
- ? html `<input type="checkbox" data-key=${entry.key} aria-label=${entry.label} .checked=${shown === true} ?disabled=${this.disabled} />`
88
+ ? html `<input
89
+ type="checkbox"
90
+ data-key=${entry.key}
91
+ aria-label=${entry.label}
92
+ .checked=${shown === true}
93
+ .indeterminate=${mixed}
94
+ ?disabled=${this.disabled}
95
+ />`
74
96
  : html `<select data-key=${entry.key} aria-label=${entry.label} ?disabled=${this.disabled}>
75
- ${((_a = entry.values) !== null && _a !== void 0 ? _a : []).map(v => html `<option value=${v} ?selected=${v === shown}>${v}</option>`)}
97
+ ${mixed ? html `<option value="" disabled selected hidden>${mixedText()}</option>` : nothing}
98
+ ${((_a = entry.values) !== null && _a !== void 0 ? _a : []).map(v => html `<option value=${v} ?selected=${!mixed && v === shown}>${v}</option>`)}
76
99
  </select>`}
77
100
  <span unit>${(_b = entry.unit) !== null && _b !== void 0 ? _b : ''}</span>
78
101
  `;
@@ -121,7 +144,7 @@ let OxPropertyEditorNumberMap = class OxPropertyEditorNumberMap extends OxProper
121
144
  this._valueChanged(e);
122
145
  }
123
146
  _valueChanged(e) {
124
- var _a, _b, _c, _d, _e;
147
+ var _a, _b, _c, _d;
125
148
  e.stopPropagation();
126
149
  const input = e.target;
127
150
  const key = input.getAttribute('data-key');
@@ -139,8 +162,9 @@ let OxPropertyEditorNumberMap = class OxPropertyEditorNumberMap extends OxProper
139
162
  const number = input.valueAsNumber;
140
163
  const outside = !Number.isFinite(number) || ((entry === null || entry === void 0 ? void 0 : entry.min) !== undefined && number < entry.min) || ((entry === null || entry === void 0 ? void 0 : entry.max) !== undefined && number > entry.max);
141
164
  if (outside) {
142
- /* Not taken: the field shows what the map holds. */
143
- input.value = String((_e = (_d = this.read(this.value, key, nested)) !== null && _d !== void 0 ? _d : entry === null || entry === void 0 ? void 0 : entry.default) !== null && _e !== void 0 ? _e : '');
165
+ /* Not taken: the field shows what the map holds -- for a mixed entry with none, nothing, as before. */
166
+ const held = this.read(this.value, key, nested);
167
+ input.value = String((_d = held !== null && held !== void 0 ? held : ((entry === null || entry === void 0 ? void 0 : entry.mixed) ? '' : entry === null || entry === void 0 ? void 0 : entry.default)) !== null && _d !== void 0 ? _d : '');
144
168
  return;
145
169
  }
146
170
  const taken = input.type === 'range' ? Math.round(number * 100) / 100 : number;
@@ -239,6 +263,19 @@ OxPropertyEditorNumberMap.styles = [
239
263
  background: var(--md-sys-color-primary);
240
264
  }
241
265
 
266
+ /* Mixed: no value to stand at, so no thumb until one is given (a click or a drag gives one to all). */
267
+ :host > div[rows] > input[type='range'][mixed]::-webkit-slider-thumb {
268
+ opacity: 0;
269
+ }
270
+
271
+ :host > div[rows] > input[type='range'][mixed]::-moz-range-thumb {
272
+ opacity: 0;
273
+ }
274
+
275
+ :host > div[rows] > input[type='number'][mixed]::placeholder {
276
+ font-style: italic;
277
+ }
278
+
242
279
  :host > div[rows] > input[type='range']:disabled {
243
280
  cursor: default;
244
281
  opacity: 0.5;
@@ -1 +1 @@
1
- {"version":3,"file":"ox-property-editor-number-map.js","sourceRoot":"","sources":["../../src/ox-property-editor-number-map.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAExD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAmB1D;;;;;;;;;;;;GAYG;AAEI,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,gBAAgB;IAsJ7D,cAAc,CAAC,KAAU,EAAE,IAAkB;;QAC3C,MAAM,OAAO,GAAqB,MAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,OAAO,m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G,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;QACrI,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QAChF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC1B,CAAC;;AAzRM,gCAAM,GAAG;IACd,GAAG,gBAAgB,CAAC,MAAM;IAC1B,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgJF;CACF,AAnJY,CAmJZ;AApJU,yBAAyB;IADrC,aAAa,CAAC,+BAA+B,CAAC;GAClC,yBAAyB,CA2RrC","sourcesContent":["import { css, html, nothing, TemplateResult } from 'lit'\nimport { customElement } from 'lit/decorators.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\n\nimport { OxPropertyEditor } from './ox-property-editor.js'\nimport { PropertySpec } from './types.js'\n\n/**\n * One value of the map: its key, the name shown, and what it is held to. A number unless `kind` says otherwise: a\n * boolean is a checkbox, an enum a choice among `values` (a figure's data properties, ADR-0051).\n */\nexport interface NumberMapEntry {\n key: string\n label: string\n kind?: 'number' | 'boolean' | 'enum'\n unit?: string\n min?: number\n max?: number\n /** For an enum: the values it may take. */\n values?: string[]\n default?: number | boolean | string\n}\n\n/**\n * Several numbers kept as one map ({ key: number }) -- a figure's design values and state values a board sets\n * (ADR-0096), a shelf's spacings. Each entry is one compact row: its name, a slider when it has a range, the number\n * field, and its unit. A value outside its range is not taken: the field goes back to what it was. A change sends the\n * whole map, so the map is the one value the component holds.\n *\n * The slider is taken at every step of a drag, so what it drives moves with the handle.\n *\n * Built by the Figure lane after the existing editors (chief architect, 2026-09-26); open for the UX lane's review.\n *\n * `property.nested`: a key `a.b` is the value `b` inside the map's `a` -- a figure's motion settings, one map per group\n * (`{ locomotion: { clip, speed, paused } }`, ADR-0051 §3.2). The key splits at its first dot only.\n */\n@customElement('ox-property-editor-number-map')\nexport class OxPropertyEditorNumberMap extends OxPropertyEditor {\n static styles = [\n ...OxPropertyEditor.styles,\n css`\n /*\n * The rows take the editor's own 24 columns (subgrid), so a name sits in the label column, right-aligned like\n * every other label, and the fields start where every other field starts.\n */\n :host > div[rows] {\n display: grid;\n grid-template-columns: subgrid;\n grid-auto-rows: 16px;\n row-gap: 3px;\n align-items: center;\n }\n\n :host > div[rows] > [name] {\n grid-column: 1 / var(--property-editor-label-end, 9);\n text-align: right;\n font: var(--property-editor-label-font, var(--label-font));\n color: var(--property-editor-label-color, inherit);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n /* A thin track filled up to the value (--fill), and a small round thumb: quieter than the fields around it. */\n :host > div[rows] > input[type='range'] {\n grid-column: var(--property-editor-label-end, 9) / 18;\n -webkit-appearance: none;\n appearance: none;\n width: 100%;\n min-width: 0;\n height: 12px;\n margin: 0;\n padding: 0;\n border: none;\n background: transparent;\n cursor: pointer;\n }\n\n :host > div[rows] > input[type='range']::-webkit-slider-runnable-track {\n height: 2px;\n border-radius: 1px;\n background: linear-gradient(\n to right,\n var(--md-sys-color-primary) var(--fill, 0%),\n var(--md-sys-color-outline-variant) var(--fill, 0%)\n );\n }\n\n :host > div[rows] > input[type='range']::-webkit-slider-thumb {\n -webkit-appearance: none;\n width: 8px;\n height: 8px;\n margin-top: -3px;\n border-radius: 50%;\n background: var(--md-sys-color-primary);\n transition: transform 0.12s;\n }\n\n :host > div[rows] > input[type='range']:hover::-webkit-slider-thumb,\n :host > div[rows] > input[type='range']:focus-visible::-webkit-slider-thumb {\n transform: scale(1.4);\n }\n\n :host > div[rows] > input[type='range']::-moz-range-track {\n height: 2px;\n border-radius: 1px;\n background: var(--md-sys-color-outline-variant);\n }\n\n :host > div[rows] > input[type='range']::-moz-range-progress {\n height: 2px;\n border-radius: 1px;\n background: var(--md-sys-color-primary);\n }\n\n :host > div[rows] > input[type='range']::-moz-range-thumb {\n width: 8px;\n height: 8px;\n border: none;\n border-radius: 50%;\n background: var(--md-sys-color-primary);\n }\n\n :host > div[rows] > input[type='range']:disabled {\n cursor: default;\n opacity: 0.5;\n }\n\n :host > div[rows] > input[type='number'] {\n grid-column: 18 / 22;\n box-sizing: border-box;\n width: 100%;\n min-width: 0;\n height: 16px;\n min-height: 0;\n padding: 0 2px;\n font: 0.7rem/1 var(--theme-font, Roboto, sans-serif);\n /* The value reads as text; the field shows itself only when pointed at or typed in. */\n background: transparent;\n border-color: transparent;\n border-radius: 3px;\n }\n\n :host > div[rows] > input[type='number']:hover {\n border-color: var(--md-sys-color-outline-variant);\n }\n\n :host > div[rows] > input[type='number']:focus {\n border-color: var(--md-sys-color-primary);\n background: var(--property-editor-background, field);\n }\n\n :host > div[rows] > input[type='number']::-webkit-inner-spin-button {\n display: none;\n min-width: 0;\n }\n\n /* No range, no slider: the field takes the slider's room. */\n :host > div[rows] > input[type='number'][wide] {\n grid-column: var(--property-editor-label-end, 9) / 22;\n }\n\n :host > div[rows] > select,\n :host > div[rows] > input[type='checkbox'] {\n grid-column: var(--property-editor-label-end, 9) / 22;\n box-sizing: border-box;\n min-width: 0;\n height: 16px;\n margin: 0;\n font: 0.7rem/1 var(--theme-font, Roboto, sans-serif);\n }\n\n :host > div[rows] > input[type='checkbox'] {\n justify-self: start;\n width: 14px;\n }\n\n :host > div[rows] > [unit] {\n grid-column: 22 / -1;\n overflow: hidden;\n font: 0.66rem/1 var(--theme-font, Roboto, sans-serif);\n color: var(--md-sys-color-outline);\n white-space: nowrap;\n }\n `\n ]\n\n editorTemplate(value: any, spec: PropertySpec): TemplateResult {\n const entries: NumberMapEntry[] = spec.property?.entries ?? []\n const nested = !!spec.property?.nested\n return html`\n <div fullwidth rows>\n ${entries.map(entry => {\n const held = this.read(value, entry.key, nested)\n if (entry.kind === 'boolean' || entry.kind === 'enum') return this.choiceRow(entry, held ?? entry.default)\n const shown = (held ?? entry.default) as number | undefined\n const ranged = this.rangeOf(entry)\n return html`\n <span name title=${entry.label}>${entry.label}</span>\n ${ranged\n ? html`<input\n type=\"range\"\n data-key=${entry.key}\n aria-label=${entry.label}\n min=${ranged.min}\n max=${ranged.max}\n step=${ranged.step}\n .value=${String(shown ?? ranged.min)}\n style=${`--fill: ${this.fillOf(shown ?? ranged.min, ranged)}%`}\n ?disabled=${this.disabled}\n @input=${this.onSlide}\n />`\n : nothing}\n <input\n type=\"number\"\n data-key=${entry.key}\n aria-label=${entry.label}\n ?wide=${!ranged}\n .value=${String(shown ?? '')}\n placeholder=${ifDefined(this.hintOf(entry))}\n min=${ifDefined(entry.min)}\n max=${ifDefined(entry.max)}\n step=\"any\"\n ?disabled=${this.disabled}\n />\n <span unit>${entry.unit ?? ''}</span>\n `\n })}\n </div>\n `\n }\n\n /** A checkbox for a boolean, a choice for an enum: what is shown is what the map holds, or the entry's default. */\n private choiceRow(entry: NumberMapEntry, shown: unknown): TemplateResult {\n return html`\n <span name title=${entry.label}>${entry.label}</span>\n ${entry.kind === 'boolean'\n ? html`<input type=\"checkbox\" data-key=${entry.key} aria-label=${entry.label} .checked=${shown === true} ?disabled=${this.disabled} />`\n : html`<select data-key=${entry.key} aria-label=${entry.label} ?disabled=${this.disabled}>\n ${(entry.values ?? []).map(v => html`<option value=${v} ?selected=${v === shown}>${v}</option>`)}\n </select>`}\n <span unit>${entry.unit ?? ''}</span>\n `\n }\n\n /** The value a key holds in the map: `a.b` inside `a` when the map is nested. */\n private read(map: unknown, key: string, nested: boolean): unknown {\n if (!map || typeof map !== 'object') return undefined\n const at = nested ? key.indexOf('.') : -1\n if (at < 0) return (map as Record<string, unknown>)[key]\n const inner = (map as Record<string, unknown>)[key.slice(0, at)]\n return inner && typeof inner === 'object' ? (inner as Record<string, unknown>)[key.slice(at + 1)] : undefined\n }\n\n /** The map with a key written: `a.b` into a copy of `a` when the map is nested. */\n private write(map: unknown, key: string, nested: boolean, value: unknown): Record<string, unknown> {\n const out: Record<string, unknown> = map && typeof map === 'object' ? { ...(map as Record<string, unknown>) } : {}\n const at = nested ? key.indexOf('.') : -1\n if (at < 0) out[key] = value\n else {\n const head = key.slice(0, at)\n const inner = out[head]\n out[head] = { ...(inner && typeof inner === 'object' ? (inner as Record<string, unknown>) : {}), [key.slice(at + 1)]: value }\n }\n return out\n }\n\n /** The slider's range, when the entry has one to slide over. */\n private rangeOf(entry: NumberMapEntry): { min: number; max: number; step: number } | undefined {\n const { min, max } = entry\n if (!Number.isFinite(min) || !Number.isFinite(max) || max! <= min!) return undefined\n return { min: min!, max: max!, step: (max! - min!) / 100 }\n }\n\n /** How far along its range a value is, in percent, for the filled part of the track. */\n private fillOf(value: number, range: { min: number; max: number }): number {\n return Math.min(Math.max(((value - range.min) / (range.max - range.min)) * 100, 0), 100)\n }\n\n private hintOf(entry: NumberMapEntry): string | undefined {\n const range = entry.min !== undefined && entry.max !== undefined ? `${entry.min}–${entry.max}` : undefined\n const standard = entry.default !== undefined ? `(${entry.default})` : undefined\n return [range, standard].filter(Boolean).join(' ') || undefined\n }\n\n /** While dragging the value is taken at every step, so the figure moves with the handle. */\n private onSlide(e: Event) {\n this._valueChanged(e)\n }\n\n override _valueChanged(e: Event) {\n e.stopPropagation()\n const input = e.target as HTMLInputElement\n const key = input.getAttribute('data-key')\n if (!key) return\n const entry = ((this.property?.entries ?? []) as NumberMapEntry[]).find(one => one.key === key)\n const nested = !!this.property?.nested\n if (entry?.kind === 'boolean' || entry?.kind === 'enum') {\n const choice = entry.kind === 'boolean' ? input.checked : (input as unknown as HTMLSelectElement).value\n this.value = this.write(this.value, key, nested, choice)\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n this.observe(this.value)\n return\n }\n const number = input.valueAsNumber\n const outside = !Number.isFinite(number) || (entry?.min !== undefined && number < entry.min) || (entry?.max !== undefined && number > entry.max)\n if (outside) {\n /* Not taken: the field shows what the map holds. */\n input.value = String(this.read(this.value, key, nested) ?? entry?.default ?? '')\n return\n }\n const taken = input.type === 'range' ? Math.round(number * 100) / 100 : number\n this.value = this.write(this.value, key, nested, taken)\n this.renderRoot.querySelectorAll<HTMLInputElement>(`input[data-key=\"${key}\"]`).forEach(one => {\n one.value = String(taken)\n if (one.type === 'range') one.style.setProperty('--fill', `${this.fillOf(taken, { min: Number(one.min), max: Number(one.max) })}%`)\n })\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n this.observe(this.value)\n }\n}\n"]}
1
+ {"version":3,"file":"ox-property-editor-number-map.js","sourceRoot":"","sources":["../../src/ox-property-editor-number-map.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAyB1D,8EAA8E;AAC9E,SAAS,SAAS;IAChB,OAAO,OAAO,CAAC,CAAC,CAAC,mBAAmB,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,CAAW,CAAA;AAC5E,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AAEI,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,gBAAgB;IAmK7D,cAAc,CAAC,KAAU,EAAE,IAAkB;;QAC3C,MAAM,OAAO,GAAqB,MAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,OAAO,mCAAI,EAAE,CAAA;QAC9D,MAAM,MAAM,GAAG,CAAC,CAAC,CAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,MAAM,CAAA,CAAA;QACtC,OAAO,IAAI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sourcesContent":["import { css, html, nothing, TemplateResult } from 'lit'\nimport { customElement } from 'lit/decorators.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\n\nimport { i18next } from '@operato/i18n'\n\nimport { OxPropertyEditor } from './ox-property-editor.js'\nimport { PropertySpec } from './types.js'\n\n/**\n * One value of the map: its key, the name shown, and what it is held to. A number unless `kind` says otherwise: a\n * boolean is a checkbox, an enum a choice among `values` (a figure's data properties, ADR-0051).\n */\nexport interface NumberMapEntry {\n key: string\n label: string\n kind?: 'number' | 'boolean' | 'enum'\n unit?: string\n min?: number\n max?: number\n /** For an enum: the values it may take. */\n values?: string[]\n default?: number | boolean | string\n /**\n * The things edited together hold different values here (several selected). While the map holds no value for the\n * entry it is shown as mixed -- an empty field saying so, no thumb on the slider, no choice made, an indeterminate\n * checkbox -- not as its default, which none of them may hold. A value given to it is shown as any other.\n */\n mixed?: boolean\n}\n\n/** The word a mixed entry shows: its own translation when the app has one. */\nfunction mixedText(): string {\n return i18next.t('text.mixed-values', { defaultValue: 'Mixed' }) as string\n}\n\n/**\n * Several numbers kept as one map ({ key: number }) -- a figure's design values and state values a board sets\n * (ADR-0096), a shelf's spacings. Each entry is one compact row: its name, a slider when it has a range, the number\n * field, and its unit. A value outside its range is not taken: the field goes back to what it was. A change sends the\n * whole map, so the map is the one value the component holds.\n *\n * The slider is taken at every step of a drag, so what it drives moves with the handle.\n *\n * Built by the Figure lane after the existing editors (chief architect, 2026-09-26); open for the UX lane's review.\n *\n * `property.nested`: a key `a.b` is the value `b` inside the map's `a` -- a figure's motion settings, one map per group\n * (`{ locomotion: { clip, speed, paused } }`, ADR-0051 §3.2). The key splits at its first dot only.\n *\n * An entry marked `mixed` (several things edited together that hold different values there) is shown as mixed until\n * the map holds a value for it.\n */\n@customElement('ox-property-editor-number-map')\nexport class OxPropertyEditorNumberMap extends OxPropertyEditor {\n static styles = [\n ...OxPropertyEditor.styles,\n css`\n /*\n * The rows take the editor's own 24 columns (subgrid), so a name sits in the label column, right-aligned like\n * every other label, and the fields start where every other field starts.\n */\n :host > div[rows] {\n display: grid;\n grid-template-columns: subgrid;\n grid-auto-rows: 16px;\n row-gap: 3px;\n align-items: center;\n }\n\n :host > div[rows] > [name] {\n grid-column: 1 / var(--property-editor-label-end, 9);\n text-align: right;\n font: var(--property-editor-label-font, var(--label-font));\n color: var(--property-editor-label-color, inherit);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n /* A thin track filled up to the value (--fill), and a small round thumb: quieter than the fields around it. */\n :host > div[rows] > input[type='range'] {\n grid-column: var(--property-editor-label-end, 9) / 18;\n -webkit-appearance: none;\n appearance: none;\n width: 100%;\n min-width: 0;\n height: 12px;\n margin: 0;\n padding: 0;\n border: none;\n background: transparent;\n cursor: pointer;\n }\n\n :host > div[rows] > input[type='range']::-webkit-slider-runnable-track {\n height: 2px;\n border-radius: 1px;\n background: linear-gradient(\n to right,\n var(--md-sys-color-primary) var(--fill, 0%),\n var(--md-sys-color-outline-variant) var(--fill, 0%)\n );\n }\n\n :host > div[rows] > input[type='range']::-webkit-slider-thumb {\n -webkit-appearance: none;\n width: 8px;\n height: 8px;\n margin-top: -3px;\n border-radius: 50%;\n background: var(--md-sys-color-primary);\n transition: transform 0.12s;\n }\n\n :host > div[rows] > input[type='range']:hover::-webkit-slider-thumb,\n :host > div[rows] > input[type='range']:focus-visible::-webkit-slider-thumb {\n transform: scale(1.4);\n }\n\n :host > div[rows] > input[type='range']::-moz-range-track {\n height: 2px;\n border-radius: 1px;\n background: var(--md-sys-color-outline-variant);\n }\n\n :host > div[rows] > input[type='range']::-moz-range-progress {\n height: 2px;\n border-radius: 1px;\n background: var(--md-sys-color-primary);\n }\n\n :host > div[rows] > input[type='range']::-moz-range-thumb {\n width: 8px;\n height: 8px;\n border: none;\n border-radius: 50%;\n background: var(--md-sys-color-primary);\n }\n\n /* Mixed: no value to stand at, so no thumb until one is given (a click or a drag gives one to all). */\n :host > div[rows] > input[type='range'][mixed]::-webkit-slider-thumb {\n opacity: 0;\n }\n\n :host > div[rows] > input[type='range'][mixed]::-moz-range-thumb {\n opacity: 0;\n }\n\n :host > div[rows] > input[type='number'][mixed]::placeholder {\n font-style: italic;\n }\n\n :host > div[rows] > input[type='range']:disabled {\n cursor: default;\n opacity: 0.5;\n }\n\n :host > div[rows] > input[type='number'] {\n grid-column: 18 / 22;\n box-sizing: border-box;\n width: 100%;\n min-width: 0;\n height: 16px;\n min-height: 0;\n padding: 0 2px;\n font: 0.7rem/1 var(--theme-font, Roboto, sans-serif);\n /* The value reads as text; the field shows itself only when pointed at or typed in. */\n background: transparent;\n border-color: transparent;\n border-radius: 3px;\n }\n\n :host > div[rows] > input[type='number']:hover {\n border-color: var(--md-sys-color-outline-variant);\n }\n\n :host > div[rows] > input[type='number']:focus {\n border-color: var(--md-sys-color-primary);\n background: var(--property-editor-background, field);\n }\n\n :host > div[rows] > input[type='number']::-webkit-inner-spin-button {\n display: none;\n min-width: 0;\n }\n\n /* No range, no slider: the field takes the slider's room. */\n :host > div[rows] > input[type='number'][wide] {\n grid-column: var(--property-editor-label-end, 9) / 22;\n }\n\n :host > div[rows] > select,\n :host > div[rows] > input[type='checkbox'] {\n grid-column: var(--property-editor-label-end, 9) / 22;\n box-sizing: border-box;\n min-width: 0;\n height: 16px;\n margin: 0;\n font: 0.7rem/1 var(--theme-font, Roboto, sans-serif);\n }\n\n :host > div[rows] > input[type='checkbox'] {\n justify-self: start;\n width: 14px;\n }\n\n :host > div[rows] > [unit] {\n grid-column: 22 / -1;\n overflow: hidden;\n font: 0.66rem/1 var(--theme-font, Roboto, sans-serif);\n color: var(--md-sys-color-outline);\n white-space: nowrap;\n }\n `\n ]\n\n editorTemplate(value: any, spec: PropertySpec): TemplateResult {\n const entries: NumberMapEntry[] = spec.property?.entries ?? []\n const nested = !!spec.property?.nested\n return html`\n <div fullwidth rows>\n ${entries.map(entry => {\n const held = this.read(value, entry.key, nested)\n const mixed = !!entry.mixed && held === undefined\n if (entry.kind === 'boolean' || entry.kind === 'enum') return this.choiceRow(entry, mixed ? undefined : held ?? entry.default, mixed)\n const shown = mixed ? undefined : ((held ?? entry.default) as number | undefined)\n const ranged = this.rangeOf(entry)\n return html`\n <span name title=${entry.label}>${entry.label}</span>\n ${ranged\n ? html`<input\n type=\"range\"\n data-key=${entry.key}\n aria-label=${entry.label}\n min=${ranged.min}\n max=${ranged.max}\n step=${ranged.step}\n ?mixed=${mixed}\n .value=${String(shown ?? ranged.min)}\n style=${`--fill: ${mixed ? 0 : this.fillOf(shown ?? ranged.min, ranged)}%`}\n ?disabled=${this.disabled}\n @input=${this.onSlide}\n />`\n : nothing}\n <input\n type=\"number\"\n data-key=${entry.key}\n aria-label=${entry.label}\n ?wide=${!ranged}\n ?mixed=${mixed}\n .value=${String(shown ?? '')}\n title=${ifDefined(mixed ? this.hintOf(entry) : undefined)}\n placeholder=${ifDefined(mixed ? mixedText() : this.hintOf(entry))}\n min=${ifDefined(entry.min)}\n max=${ifDefined(entry.max)}\n step=\"any\"\n ?disabled=${this.disabled}\n />\n <span unit>${entry.unit ?? ''}</span>\n `\n })}\n </div>\n `\n }\n\n /**\n * A checkbox for a boolean, a choice for an enum: what is shown is what the map holds, or the entry's default. A mixed\n * entry is an indeterminate checkbox, or a choice that says it is mixed and is not one of the values.\n */\n private choiceRow(entry: NumberMapEntry, shown: unknown, mixed = false): TemplateResult {\n return html`\n <span name title=${entry.label}>${entry.label}</span>\n ${entry.kind === 'boolean'\n ? html`<input\n type=\"checkbox\"\n data-key=${entry.key}\n aria-label=${entry.label}\n .checked=${shown === true}\n .indeterminate=${mixed}\n ?disabled=${this.disabled}\n />`\n : html`<select data-key=${entry.key} aria-label=${entry.label} ?disabled=${this.disabled}>\n ${mixed ? html`<option value=\"\" disabled selected hidden>${mixedText()}</option>` : nothing}\n ${(entry.values ?? []).map(v => html`<option value=${v} ?selected=${!mixed && v === shown}>${v}</option>`)}\n </select>`}\n <span unit>${entry.unit ?? ''}</span>\n `\n }\n\n /** The value a key holds in the map: `a.b` inside `a` when the map is nested. */\n private read(map: unknown, key: string, nested: boolean): unknown {\n if (!map || typeof map !== 'object') return undefined\n const at = nested ? key.indexOf('.') : -1\n if (at < 0) return (map as Record<string, unknown>)[key]\n const inner = (map as Record<string, unknown>)[key.slice(0, at)]\n return inner && typeof inner === 'object' ? (inner as Record<string, unknown>)[key.slice(at + 1)] : undefined\n }\n\n /** The map with a key written: `a.b` into a copy of `a` when the map is nested. */\n private write(map: unknown, key: string, nested: boolean, value: unknown): Record<string, unknown> {\n const out: Record<string, unknown> = map && typeof map === 'object' ? { ...(map as Record<string, unknown>) } : {}\n const at = nested ? key.indexOf('.') : -1\n if (at < 0) out[key] = value\n else {\n const head = key.slice(0, at)\n const inner = out[head]\n out[head] = { ...(inner && typeof inner === 'object' ? (inner as Record<string, unknown>) : {}), [key.slice(at + 1)]: value }\n }\n return out\n }\n\n /** The slider's range, when the entry has one to slide over. */\n private rangeOf(entry: NumberMapEntry): { min: number; max: number; step: number } | undefined {\n const { min, max } = entry\n if (!Number.isFinite(min) || !Number.isFinite(max) || max! <= min!) return undefined\n return { min: min!, max: max!, step: (max! - min!) / 100 }\n }\n\n /** How far along its range a value is, in percent, for the filled part of the track. */\n private fillOf(value: number, range: { min: number; max: number }): number {\n return Math.min(Math.max(((value - range.min) / (range.max - range.min)) * 100, 0), 100)\n }\n\n private hintOf(entry: NumberMapEntry): string | undefined {\n const range = entry.min !== undefined && entry.max !== undefined ? `${entry.min}–${entry.max}` : undefined\n const standard = entry.default !== undefined ? `(${entry.default})` : undefined\n return [range, standard].filter(Boolean).join(' ') || undefined\n }\n\n /** While dragging the value is taken at every step, so the figure moves with the handle. */\n private onSlide(e: Event) {\n this._valueChanged(e)\n }\n\n override _valueChanged(e: Event) {\n e.stopPropagation()\n const input = e.target as HTMLInputElement\n const key = input.getAttribute('data-key')\n if (!key) return\n const entry = ((this.property?.entries ?? []) as NumberMapEntry[]).find(one => one.key === key)\n const nested = !!this.property?.nested\n if (entry?.kind === 'boolean' || entry?.kind === 'enum') {\n const choice = entry.kind === 'boolean' ? input.checked : (input as unknown as HTMLSelectElement).value\n this.value = this.write(this.value, key, nested, choice)\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n this.observe(this.value)\n return\n }\n const number = input.valueAsNumber\n const outside = !Number.isFinite(number) || (entry?.min !== undefined && number < entry.min) || (entry?.max !== undefined && number > entry.max)\n if (outside) {\n /* Not taken: the field shows what the map holds -- for a mixed entry with none, nothing, as before. */\n const held = this.read(this.value, key, nested)\n input.value = String(held ?? (entry?.mixed ? '' : entry?.default) ?? '')\n return\n }\n const taken = input.type === 'range' ? Math.round(number * 100) / 100 : number\n this.value = this.write(this.value, key, nested, taken)\n this.renderRoot.querySelectorAll<HTMLInputElement>(`input[data-key=\"${key}\"]`).forEach(one => {\n one.value = String(taken)\n if (one.type === 'range') one.style.setProperty('--fill', `${this.fillOf(taken, { min: Number(one.min), max: Number(one.max) })}%`)\n })\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n this.observe(this.value)\n }\n}\n"]}
@@ -114,4 +114,80 @@ describe('number-map — other kinds and nested keys', () => {
114
114
  expect(el.value).to.deep.equal({ locomotion: { clip: 'walk', speed: 2 } });
115
115
  });
116
116
  });
117
+ /**
118
+ * Several things edited together that hold different values (a board's figures selected together): an entry marked
119
+ * `mixed` shows it is mixed, not its default, until a value is given -- and a value given is shown as any other.
120
+ */
121
+ describe('number-map — mixed entries', () => {
122
+ const entries = [
123
+ { key: 'pitch', label: '롤러 간격', unit: 'mm', min: 100, max: 400, default: 200, mixed: true },
124
+ { key: 'gap', label: '틈', unit: 'mm', min: 0, max: 50, default: 10 },
125
+ { key: 'mode', label: '동작', kind: 'enum', values: ['idle', 'walk', 'run'], default: 'idle', mixed: true },
126
+ { key: 'batteryLow', label: '배터리 부족', kind: 'boolean', default: false, mixed: true }
127
+ ];
128
+ const make = (value = { gap: 20 }) => fixture(html `<ox-property-editor-number-map name="figureValues" .property=${{ entries }} .value=${value}></ox-property-editor-number-map>`);
129
+ const at = (el, selector) => el.renderRoot.querySelector(selector);
130
+ it('a mixed number: an empty field saying so, the range kept as its title, no thumb on the slider', async () => {
131
+ const el = await make();
132
+ const field = at(el, 'input[type=number][data-key="pitch"]');
133
+ expect(field.value).to.equal('');
134
+ expect(field.placeholder).to.equal('Mixed');
135
+ expect(field.title).to.equal('100–400 (200)');
136
+ expect(field.hasAttribute('mixed')).to.equal(true);
137
+ expect(at(el, 'input[type=range][data-key="pitch"]').hasAttribute('mixed')).to.equal(true);
138
+ });
139
+ it('an entry not marked mixed shows its value as before', async () => {
140
+ const el = await make();
141
+ expect(at(el, 'input[type=number][data-key="gap"]').value).to.equal('20');
142
+ expect(at(el, 'input[type=number][data-key="gap"]').hasAttribute('mixed')).to.equal(false);
143
+ });
144
+ it('a mixed choice is none of its values; a mixed checkbox is indeterminate', async () => {
145
+ const el = await make();
146
+ const choice = at(el, 'select[data-key="mode"]');
147
+ expect(choice.value).to.equal('');
148
+ expect(choice.selectedOptions[0].textContent).to.equal('Mixed');
149
+ expect(at(el, 'input[type=checkbox][data-key="batteryLow"]').indeterminate).to.equal(true);
150
+ });
151
+ it('a value given to a mixed number is told and then shown as any other', async () => {
152
+ const el = await make();
153
+ const field = at(el, 'input[type=number][data-key="pitch"]');
154
+ field.value = '300';
155
+ const told = oneEvent(el, 'change');
156
+ field.dispatchEvent(new Event('change', { bubbles: true }));
157
+ await told;
158
+ await el.updateComplete;
159
+ expect(el.value).to.deep.equal({ gap: 20, pitch: 300 });
160
+ expect(at(el, 'input[type=number][data-key="pitch"]').value).to.equal('300');
161
+ expect(at(el, 'input[type=number][data-key="pitch"]').hasAttribute('mixed')).to.equal(false);
162
+ expect(at(el, 'input[type=range][data-key="pitch"]').hasAttribute('mixed')).to.equal(false);
163
+ });
164
+ it('a choice made on a mixed entry is told; it is then that choice', async () => {
165
+ const el = await make();
166
+ const choice = at(el, 'select[data-key="mode"]');
167
+ choice.value = 'run';
168
+ const told = oneEvent(el, 'change');
169
+ choice.dispatchEvent(new Event('change', { bubbles: true }));
170
+ await told;
171
+ await el.updateComplete;
172
+ expect(el.value).to.deep.equal({ gap: 20, mode: 'run' });
173
+ expect(at(el, 'select[data-key="mode"]').value).to.equal('run');
174
+ expect(at(el, 'select[data-key="mode"]').querySelector('option[hidden]')).to.equal(null);
175
+ });
176
+ it('a value outside the range on a mixed entry is not taken: the field is empty again, not the default', async () => {
177
+ const el = await make();
178
+ let told = false;
179
+ el.addEventListener('change', () => (told = true));
180
+ const field = at(el, 'input[type=number][data-key="pitch"]');
181
+ field.value = '1000';
182
+ field.dispatchEvent(new Event('change', { bubbles: true }));
183
+ await el.updateComplete;
184
+ expect(told).to.equal(false);
185
+ expect(field.value).to.equal('');
186
+ });
187
+ it('a mixed entry the map holds a value for shows that value', async () => {
188
+ const el = await make({ pitch: 250 });
189
+ expect(at(el, 'input[type=number][data-key="pitch"]').value).to.equal('250');
190
+ expect(at(el, 'input[type=number][data-key="pitch"]').hasAttribute('mixed')).to.equal(false);
191
+ });
192
+ });
117
193
  //# sourceMappingURL=number-map.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"number-map.test.js","sourceRoot":"","sources":["../../test/number-map.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAE1B,OAAO,yCAAyC,CAAA;AAGhD;;;GAGG;AACH,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,MAAM,OAAO,GAAG;QACd,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE;QAC9E,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,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AK,EAAE;SAC3E,CAAA;QACD,MAAM,EAAE,GAAG,MAAM,OAAO,CACtB,IAAI,CAAA,0DAA0D,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,mCAAmC,CAChL,CAAA;QACD,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,iBAAiB,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAC3D,MAAM,KAAK,GAAG,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,iDAAiD,CAAqB,CAAA;QAChH,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACjC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAA;QACjB,MAAM,IAAI,GAAG,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;QACnC,KAAK,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QAC3D,MAAM,IAAI,CAAA;QACV,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAA;IAC5E,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { expect, fixture, oneEvent } from '@open-wc/testing'\nimport { html } from 'lit'\n\nimport '../src/ox-property-editor-number-map.js'\nimport type { OxPropertyEditorNumberMap } from '../src/ox-property-editor-number-map.js'\n\n/**\n * Several numbers as one map (ADR-0096): a board's design values for a figure. A value within range becomes part of the\n * map and the whole map is told; one outside its range is not taken and the field shows what the map holds.\n */\ndescribe('number-map', () => {\n const entries = [\n { key: 'pitch', label: '롤러 간격', unit: 'mm', min: 100, max: 400, default: 200 },\n { key: 'gap', label: '틈', unit: 'mm', min: 0, max: 50, default: 10 }\n ]\n const make = () =>\n fixture<OxPropertyEditorNumberMap>(html`<ox-property-editor-number-map name=\"designInputs\" .property=${{ entries }} .value=${{ pitch: 150 }}></ox-property-editor-number-map>`)\n const field = (el: OxPropertyEditorNumberMap, key: string) => el.renderRoot.querySelector(`input[type=number][data-key=\"${key}\"]`) as HTMLInputElement\n\n it('shows each value, or its default, with its range', async () => {\n const el = await make()\n expect(field(el, 'pitch').value).to.equal('150')\n expect(field(el, 'gap').value).to.equal('10')\n expect(field(el, 'pitch').placeholder).to.equal('100–400 (200)')\n })\n\n it('a value within range: the whole map is told', async () => {\n const el = await make()\n const input = field(el, 'gap')\n input.value = '20'\n const told = oneEvent(el, 'change')\n input.dispatchEvent(new Event('change', { bubbles: true }))\n await told\n expect(el.value).to.deep.equal({ pitch: 150, gap: 20 })\n })\n\n it('a value outside its range is not taken: nothing is told, the field shows the map again', async () => {\n const el = await make()\n let told = false\n el.addEventListener('change', () => (told = true))\n const input = field(el, 'pitch')\n input.value = '1000'\n input.dispatchEvent(new Event('change', { bubbles: true }))\n await el.updateComplete\n expect(told).to.equal(false)\n expect(el.value).to.deep.equal({ pitch: 150 })\n expect(input.value).to.equal('150')\n })\n\n it('an emptied field is not a number: not taken, the field shows the map again', async () => {\n const el = await make()\n let told = false\n el.addEventListener('change', () => (told = true))\n const input = field(el, 'gap')\n input.value = ''\n input.dispatchEvent(new Event('change', { bubbles: true }))\n await el.updateComplete\n expect(told).to.equal(false)\n expect(el.value).to.deep.equal({ pitch: 150 })\n expect(input.value).to.equal('10')\n })\n\n it('★ a ranged entry has a slider: every step of a drag is told, and the number follows', async () => {\n const el = await make()\n const slider = el.renderRoot.querySelector('input[type=range][data-key=\"gap\"]') as HTMLInputElement\n let told = 0\n el.addEventListener('change', () => told++)\n slider.value = '30'\n slider.dispatchEvent(new Event('input', { bubbles: true }))\n expect(field(el, 'gap').value).to.equal('30')\n expect(told).to.equal(1)\n expect(el.value).to.deep.equal({ pitch: 150, gap: 30 })\n slider.value = '40'\n slider.dispatchEvent(new Event('input', { bubbles: true }))\n expect(told).to.equal(2)\n expect(el.value).to.deep.equal({ pitch: 150, gap: 40 })\n })\n\n it('an entry without a range has no slider; its field takes the room', async () => {\n const el = await fixture<OxPropertyEditorNumberMap>(\n html`<ox-property-editor-number-map name=\"clips\" .property=${{ entries: [{ key: 'run', label: 'run', min: 0 }] }}></ox-property-editor-number-map>`\n )\n expect(el.renderRoot.querySelector('input[type=range]')).to.equal(null)\n expect(field(el, 'run').hasAttribute('wide')).to.equal(true)\n })\n})\n\n/** A figure's data values and motion settings (ADR-0051): a boolean, an enum, and a map of maps for the groups. */\ndescribe('number-map — other kinds and nested keys', () => {\n const field = (el: OxPropertyEditorNumberMap, key: string) => el.renderRoot.querySelector(`[data-key=\"${key}\"]`) as HTMLInputElement & HTMLSelectElement\n\n it('a boolean is a checkbox and an enum a choice; each change tells the whole map, false included', async () => {\n const entries = [\n { key: 'batteryLow', label: '배터리 부족', kind: 'boolean', default: false },\n { key: 'mode', label: '동작', kind: 'enum', values: ['idle', 'walk', 'run'], default: 'idle' },\n { key: 'cadence', label: '동작 속도', unit: 'ratio', min: 0, max: 3, default: 1 }\n ]\n const el = await fixture<OxPropertyEditorNumberMap>(html`<ox-property-editor-number-map name=\"figureValues\" .property=${{ entries }} .value=${{ batteryLow: true }}></ox-property-editor-number-map>`)\n expect(field(el, 'batteryLow').checked).to.equal(true)\n expect(field(el, 'mode').value).to.equal('idle')\n const box = field(el, 'batteryLow')\n box.checked = false\n let told = oneEvent(el, 'change')\n box.dispatchEvent(new Event('change', { bubbles: true }))\n await told\n expect(el.value).to.deep.equal({ batteryLow: false })\n const choice = field(el, 'mode')\n choice.value = 'run'\n told = oneEvent(el, 'change')\n choice.dispatchEvent(new Event('change', { bubbles: true }))\n await told\n expect(el.value).to.deep.equal({ batteryLow: false, mode: 'run' })\n })\n\n it('nested: a key a.b is the value b inside a, and writing one keeps the others of a', async () => {\n const entries = [\n { key: 'locomotion.clip', label: '보행', kind: 'enum', values: ['idle', 'walk', 'run'], default: 'idle' },\n { key: 'locomotion.speed', label: '보행', unit: '×', min: 0, max: 3, default: 0 },\n { key: 'locomotion.paused', label: '보행', kind: 'boolean', default: false }\n ]\n const el = await fixture<OxPropertyEditorNumberMap>(\n html`<ox-property-editor-number-map name=\"motion\" .property=${{ entries, nested: true }} .value=${{ locomotion: { clip: 'walk', speed: 1 } }}></ox-property-editor-number-map>`\n )\n expect(field(el, 'locomotion.clip').value).to.equal('walk')\n const speed = el.renderRoot.querySelector('input[type=number][data-key=\"locomotion.speed\"]') as HTMLInputElement\n expect(speed.value).to.equal('1')\n speed.value = '2'\n const told = oneEvent(el, 'change')\n speed.dispatchEvent(new Event('change', { bubbles: true }))\n await told\n expect(el.value).to.deep.equal({ locomotion: { clip: 'walk', speed: 2 } })\n })\n})\n"]}
1
+ {"version":3,"file":"number-map.test.js","sourceRoot":"","sources":["../../test/number-map.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAE1B,OAAO,yCAAyC,CAAA;AAGhD;;;GAGG;AACH,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,MAAM,OAAO,GAAG;QACd,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE;QAC9E,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,O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E,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAClC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,0DAA0D,EAAE,KAAK,IAAI,EAAE;QACxE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;QACrC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,sCAAsC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAC5E,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,sCAAsC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IAC9F,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { expect, fixture, oneEvent } from '@open-wc/testing'\nimport { html } from 'lit'\n\nimport '../src/ox-property-editor-number-map.js'\nimport type { OxPropertyEditorNumberMap } from '../src/ox-property-editor-number-map.js'\n\n/**\n * Several numbers as one map (ADR-0096): a board's design values for a figure. A value within range becomes part of the\n * map and the whole map is told; one outside its range is not taken and the field shows what the map holds.\n */\ndescribe('number-map', () => {\n const entries = [\n { key: 'pitch', label: '롤러 간격', unit: 'mm', min: 100, max: 400, default: 200 },\n { key: 'gap', label: '틈', unit: 'mm', min: 0, max: 50, default: 10 }\n ]\n const make = () =>\n fixture<OxPropertyEditorNumberMap>(html`<ox-property-editor-number-map name=\"designInputs\" .property=${{ entries }} .value=${{ pitch: 150 }}></ox-property-editor-number-map>`)\n const field = (el: OxPropertyEditorNumberMap, key: string) => el.renderRoot.querySelector(`input[type=number][data-key=\"${key}\"]`) as HTMLInputElement\n\n it('shows each value, or its default, with its range', async () => {\n const el = await make()\n expect(field(el, 'pitch').value).to.equal('150')\n expect(field(el, 'gap').value).to.equal('10')\n expect(field(el, 'pitch').placeholder).to.equal('100–400 (200)')\n })\n\n it('a value within range: the whole map is told', async () => {\n const el = await make()\n const input = field(el, 'gap')\n input.value = '20'\n const told = oneEvent(el, 'change')\n input.dispatchEvent(new Event('change', { bubbles: true }))\n await told\n expect(el.value).to.deep.equal({ pitch: 150, gap: 20 })\n })\n\n it('a value outside its range is not taken: nothing is told, the field shows the map again', async () => {\n const el = await make()\n let told = false\n el.addEventListener('change', () => (told = true))\n const input = field(el, 'pitch')\n input.value = '1000'\n input.dispatchEvent(new Event('change', { bubbles: true }))\n await el.updateComplete\n expect(told).to.equal(false)\n expect(el.value).to.deep.equal({ pitch: 150 })\n expect(input.value).to.equal('150')\n })\n\n it('an emptied field is not a number: not taken, the field shows the map again', async () => {\n const el = await make()\n let told = false\n el.addEventListener('change', () => (told = true))\n const input = field(el, 'gap')\n input.value = ''\n input.dispatchEvent(new Event('change', { bubbles: true }))\n await el.updateComplete\n expect(told).to.equal(false)\n expect(el.value).to.deep.equal({ pitch: 150 })\n expect(input.value).to.equal('10')\n })\n\n it('★ a ranged entry has a slider: every step of a drag is told, and the number follows', async () => {\n const el = await make()\n const slider = el.renderRoot.querySelector('input[type=range][data-key=\"gap\"]') as HTMLInputElement\n let told = 0\n el.addEventListener('change', () => told++)\n slider.value = '30'\n slider.dispatchEvent(new Event('input', { bubbles: true }))\n expect(field(el, 'gap').value).to.equal('30')\n expect(told).to.equal(1)\n expect(el.value).to.deep.equal({ pitch: 150, gap: 30 })\n slider.value = '40'\n slider.dispatchEvent(new Event('input', { bubbles: true }))\n expect(told).to.equal(2)\n expect(el.value).to.deep.equal({ pitch: 150, gap: 40 })\n })\n\n it('an entry without a range has no slider; its field takes the room', async () => {\n const el = await fixture<OxPropertyEditorNumberMap>(\n html`<ox-property-editor-number-map name=\"clips\" .property=${{ entries: [{ key: 'run', label: 'run', min: 0 }] }}></ox-property-editor-number-map>`\n )\n expect(el.renderRoot.querySelector('input[type=range]')).to.equal(null)\n expect(field(el, 'run').hasAttribute('wide')).to.equal(true)\n })\n})\n\n/** A figure's data values and motion settings (ADR-0051): a boolean, an enum, and a map of maps for the groups. */\ndescribe('number-map — other kinds and nested keys', () => {\n const field = (el: OxPropertyEditorNumberMap, key: string) => el.renderRoot.querySelector(`[data-key=\"${key}\"]`) as HTMLInputElement & HTMLSelectElement\n\n it('a boolean is a checkbox and an enum a choice; each change tells the whole map, false included', async () => {\n const entries = [\n { key: 'batteryLow', label: '배터리 부족', kind: 'boolean', default: false },\n { key: 'mode', label: '동작', kind: 'enum', values: ['idle', 'walk', 'run'], default: 'idle' },\n { key: 'cadence', label: '동작 속도', unit: 'ratio', min: 0, max: 3, default: 1 }\n ]\n const el = await fixture<OxPropertyEditorNumberMap>(html`<ox-property-editor-number-map name=\"figureValues\" .property=${{ entries }} .value=${{ batteryLow: true }}></ox-property-editor-number-map>`)\n expect(field(el, 'batteryLow').checked).to.equal(true)\n expect(field(el, 'mode').value).to.equal('idle')\n const box = field(el, 'batteryLow')\n box.checked = false\n let told = oneEvent(el, 'change')\n box.dispatchEvent(new Event('change', { bubbles: true }))\n await told\n expect(el.value).to.deep.equal({ batteryLow: false })\n const choice = field(el, 'mode')\n choice.value = 'run'\n told = oneEvent(el, 'change')\n choice.dispatchEvent(new Event('change', { bubbles: true }))\n await told\n expect(el.value).to.deep.equal({ batteryLow: false, mode: 'run' })\n })\n\n it('nested: a key a.b is the value b inside a, and writing one keeps the others of a', async () => {\n const entries = [\n { key: 'locomotion.clip', label: '보행', kind: 'enum', values: ['idle', 'walk', 'run'], default: 'idle' },\n { key: 'locomotion.speed', label: '보행', unit: '×', min: 0, max: 3, default: 0 },\n { key: 'locomotion.paused', label: '보행', kind: 'boolean', default: false }\n ]\n const el = await fixture<OxPropertyEditorNumberMap>(\n html`<ox-property-editor-number-map name=\"motion\" .property=${{ entries, nested: true }} .value=${{ locomotion: { clip: 'walk', speed: 1 } }}></ox-property-editor-number-map>`\n )\n expect(field(el, 'locomotion.clip').value).to.equal('walk')\n const speed = el.renderRoot.querySelector('input[type=number][data-key=\"locomotion.speed\"]') as HTMLInputElement\n expect(speed.value).to.equal('1')\n speed.value = '2'\n const told = oneEvent(el, 'change')\n speed.dispatchEvent(new Event('change', { bubbles: true }))\n await told\n expect(el.value).to.deep.equal({ locomotion: { clip: 'walk', speed: 2 } })\n })\n})\n\n/**\n * Several things edited together that hold different values (a board's figures selected together): an entry marked\n * `mixed` shows it is mixed, not its default, until a value is given -- and a value given is shown as any other.\n */\ndescribe('number-map — mixed entries', () => {\n const entries = [\n { key: 'pitch', label: '롤러 간격', unit: 'mm', min: 100, max: 400, default: 200, mixed: true },\n { key: 'gap', label: '틈', unit: 'mm', min: 0, max: 50, default: 10 },\n { key: 'mode', label: '동작', kind: 'enum', values: ['idle', 'walk', 'run'], default: 'idle', mixed: true },\n { key: 'batteryLow', label: '배터리 부족', kind: 'boolean', default: false, mixed: true }\n ]\n const make = (value: Record<string, unknown> = { gap: 20 }) =>\n fixture<OxPropertyEditorNumberMap>(html`<ox-property-editor-number-map name=\"figureValues\" .property=${{ entries }} .value=${value}></ox-property-editor-number-map>`)\n const at = (el: OxPropertyEditorNumberMap, selector: string) => el.renderRoot.querySelector(selector) as HTMLInputElement & HTMLSelectElement\n\n it('a mixed number: an empty field saying so, the range kept as its title, no thumb on the slider', async () => {\n const el = await make()\n const field = at(el, 'input[type=number][data-key=\"pitch\"]')\n expect(field.value).to.equal('')\n expect(field.placeholder).to.equal('Mixed')\n expect(field.title).to.equal('100–400 (200)')\n expect(field.hasAttribute('mixed')).to.equal(true)\n expect(at(el, 'input[type=range][data-key=\"pitch\"]').hasAttribute('mixed')).to.equal(true)\n })\n\n it('an entry not marked mixed shows its value as before', async () => {\n const el = await make()\n expect(at(el, 'input[type=number][data-key=\"gap\"]').value).to.equal('20')\n expect(at(el, 'input[type=number][data-key=\"gap\"]').hasAttribute('mixed')).to.equal(false)\n })\n\n it('a mixed choice is none of its values; a mixed checkbox is indeterminate', async () => {\n const el = await make()\n const choice = at(el, 'select[data-key=\"mode\"]')\n expect(choice.value).to.equal('')\n expect(choice.selectedOptions[0].textContent).to.equal('Mixed')\n expect(at(el, 'input[type=checkbox][data-key=\"batteryLow\"]').indeterminate).to.equal(true)\n })\n\n it('a value given to a mixed number is told and then shown as any other', async () => {\n const el = await make()\n const field = at(el, 'input[type=number][data-key=\"pitch\"]')\n field.value = '300'\n const told = oneEvent(el, 'change')\n field.dispatchEvent(new Event('change', { bubbles: true }))\n await told\n await el.updateComplete\n expect(el.value).to.deep.equal({ gap: 20, pitch: 300 })\n expect(at(el, 'input[type=number][data-key=\"pitch\"]').value).to.equal('300')\n expect(at(el, 'input[type=number][data-key=\"pitch\"]').hasAttribute('mixed')).to.equal(false)\n expect(at(el, 'input[type=range][data-key=\"pitch\"]').hasAttribute('mixed')).to.equal(false)\n })\n\n it('a choice made on a mixed entry is told; it is then that choice', async () => {\n const el = await make()\n const choice = at(el, 'select[data-key=\"mode\"]')\n choice.value = 'run'\n const told = oneEvent(el, 'change')\n choice.dispatchEvent(new Event('change', { bubbles: true }))\n await told\n await el.updateComplete\n expect(el.value).to.deep.equal({ gap: 20, mode: 'run' })\n expect(at(el, 'select[data-key=\"mode\"]').value).to.equal('run')\n expect(at(el, 'select[data-key=\"mode\"]').querySelector('option[hidden]')).to.equal(null)\n })\n\n it('a value outside the range on a mixed entry is not taken: the field is empty again, not the default', async () => {\n const el = await make()\n let told = false\n el.addEventListener('change', () => (told = true))\n const field = at(el, 'input[type=number][data-key=\"pitch\"]')\n field.value = '1000'\n field.dispatchEvent(new Event('change', { bubbles: true }))\n await el.updateComplete\n expect(told).to.equal(false)\n expect(field.value).to.equal('')\n })\n\n it('a mixed entry the map holds a value for shows that value', async () => {\n const el = await make({ pitch: 250 })\n expect(at(el, 'input[type=number][data-key=\"pitch\"]').value).to.equal('250')\n expect(at(el, 'input[type=number][data-key=\"pitch\"]').hasAttribute('mixed')).to.equal(false)\n })\n})\n"]}