@roxyapi/ui 0.51.0 → 0.51.1

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.
Files changed (73) hide show
  1. package/components-catalog.json +153 -153
  2. package/dist/cdn/components/endpoint-form.js +4 -4
  3. package/dist/cdn/components/endpoint-form.js.map +3 -3
  4. package/dist/cdn/roxy-ui.js +74 -74
  5. package/dist/cdn/roxy-ui.js.map +3 -3
  6. package/dist/components/endpoint-form.d.ts +3 -9
  7. package/dist/components/endpoint-form.d.ts.map +1 -1
  8. package/dist/components/endpoint-form.js +1 -1
  9. package/dist/components/endpoint-form.js.map +3 -3
  10. package/dist/forms/labels/de.json +1 -1
  11. package/dist/forms/labels/en.json +1 -1
  12. package/dist/forms/labels/es.json +1 -1
  13. package/dist/forms/labels/fr.json +1 -1
  14. package/dist/forms/labels/hi.json +1 -1
  15. package/dist/forms/labels/pt.json +1 -1
  16. package/dist/forms/labels/ru.json +1 -1
  17. package/dist/forms/labels/tr.json +1 -1
  18. package/dist/forms.json +1 -1
  19. package/dist/index.cjs +57 -57
  20. package/dist/index.cjs.map +3 -3
  21. package/dist/index.js +59 -59
  22. package/dist/index.js.map +3 -3
  23. package/dist/schemas/get--ayurveda-doshas-id.json +1 -1
  24. package/dist/schemas/get--chinese-astrology-zodiac-animals-id.json +1 -1
  25. package/dist/schemas/get--chinese-astrology-zodiac-id-daily.json +1 -1
  26. package/dist/schemas/get--feng-shui-bagua-id.json +1 -1
  27. package/dist/schemas/get--human-design-centers-id.json +1 -1
  28. package/dist/schemas/get--kabbalah-letters-id.json +1 -1
  29. package/dist/schemas/get--kabbalah-sephirot-id.json +1 -1
  30. package/dist/schemas/get--mesoamerican-astrology-aztec-day-signs-id.json +1 -1
  31. package/dist/schemas/get--mesoamerican-astrology-mayan-day-signs-id.json +1 -1
  32. package/dist/schemas/get--mesoamerican-astrology-mayan-haab-months-id.json +1 -1
  33. package/dist/schemas/get--vastu-devatas-id.json +1 -1
  34. package/dist/schemas/get--vastu-directions-id.json +1 -1
  35. package/dist/schemas/get--vedic-astrology-avasthas-id.json +1 -1
  36. package/dist/schemas/get--vedic-astrology-nakshatras-id.json +1 -1
  37. package/dist/schemas/get--vedic-astrology-rashis-id.json +1 -1
  38. package/dist/schemas/get--vedic-astrology-yoga-id.json +1 -1
  39. package/dist/schemas/post--astrology-compatibility-score.json +1 -1
  40. package/dist/schemas/post--astrology-composite-chart.json +1 -1
  41. package/dist/schemas/post--astrology-relocation-chart.json +1 -1
  42. package/dist/schemas/post--astrology-synastry.json +1 -1
  43. package/dist/schemas/post--astrology-transit-aspects.json +1 -1
  44. package/dist/schemas/post--astrology-transits.json +1 -1
  45. package/dist/schemas/post--biorhythm-compatibility.json +1 -1
  46. package/dist/schemas/post--chinese-astrology-bazi-compatibility.json +1 -1
  47. package/dist/schemas/post--forecast-digest.json +1 -1
  48. package/dist/schemas/post--forecast-significant-dates.json +1 -1
  49. package/dist/schemas/post--forecast-timeline.json +1 -1
  50. package/dist/schemas/post--forecast-transits.json +1 -1
  51. package/dist/schemas/post--human-design-connection.json +1 -1
  52. package/dist/schemas/post--human-design-penta.json +1 -1
  53. package/dist/schemas/post--human-design-transit.json +1 -1
  54. package/dist/schemas/post--mesoamerican-astrology-mayan-compatibility.json +1 -1
  55. package/dist/schemas/post--numerology-compatibility.json +1 -1
  56. package/dist/schemas/post--tarot-spreads-custom.json +1 -1
  57. package/dist/schemas/post--vastu-entrance.json +1 -1
  58. package/dist/schemas/post--vastu-mandala.json +1 -1
  59. package/dist/schemas/post--vastu-plot.json +1 -1
  60. package/dist/schemas/post--vastu-rooms.json +1 -1
  61. package/dist/schemas/post--vedic-astrology-compatibility-dashakoot.json +1 -1
  62. package/dist/schemas/post--vedic-astrology-compatibility-papasamyam.json +1 -1
  63. package/dist/schemas/post--vedic-astrology-compatibility.json +1 -1
  64. package/dist/schemas/post--vedic-astrology-kp-daily-finance.json +1 -1
  65. package/dist/styles/themes/practitioner.css +5 -5
  66. package/dist/utils/field-schema.d.ts +18 -0
  67. package/dist/utils/field-schema.d.ts.map +1 -1
  68. package/dist/version.d.ts +1 -1
  69. package/package.json +1 -1
  70. package/src/components/endpoint-form.ts +19 -25
  71. package/src/styles/themes/practitioner.css +5 -5
  72. package/src/utils/field-schema.ts +61 -20
  73. package/src/version.ts +1 -1
@@ -16,6 +16,7 @@ import {
16
16
  } from '../utils/fetch-controller.js';
17
17
  import {
18
18
  buildFormModel,
19
+ deriveGroupLabel,
19
20
  deriveSubmitLabel,
20
21
  type FieldDef,
21
22
  type FieldOption,
@@ -41,7 +42,6 @@ import {
41
42
  readOptions,
42
43
  renderPicker,
43
44
  } from '../utils/option-picker.js';
44
- import { humanize } from '../utils/string.js';
45
45
  import { ROXY_UI_VERSION } from '../version.js';
46
46
 
47
47
  /** Production spec, fetched when no slice is available and no explicit `spec-url` is set. */
@@ -790,8 +790,8 @@ export class RoxyEndpointForm extends RoxyLocalizedElement {
790
790
  if (this.roleOf(f) === 'location' || f.city)
791
791
  return this.locationLabel(this.cityGroup(f));
792
792
  return f.group
793
- ? `${this.groupName(f.group)} ${this.fieldText(f.name)}`
794
- : this.fieldText(f.name);
793
+ ? `${this.groupName(f.group)} ${this.fieldText(f.name, f.label)}`
794
+ : this.fieldText(f.name, f.label);
795
795
  }
796
796
 
797
797
  /** The issues the API reported on a whole card or a city box, printed under it. */
@@ -964,8 +964,11 @@ export class RoxyEndpointForm extends RoxyLocalizedElement {
964
964
  * a separate key space from the chrome catalogue.
965
965
  *
966
966
  * English ships no payload, so the API English label is compiled in and comes before `humanize()`.
967
+ * A contextual model label wins over the generic wire-name map: translating `id` would
968
+ * discard the noun the spec supplied and make every lookup say ID again.
967
969
  */
968
- private fieldText(name: string): string {
970
+ private fieldText(name: string, label?: string): string {
971
+ if (label) return label;
969
972
  return displayField(this.requestLang(), name, EN_FIELD_LABELS[name]);
970
973
  }
971
974
 
@@ -1180,7 +1183,7 @@ export class RoxyEndpointForm extends RoxyLocalizedElement {
1180
1183
  const cur = opts.findIndex((o) => o.value === this.values[f.key]);
1181
1184
  const active = cur === -1 ? opts.findIndex((o) => !o.disabled) : cur;
1182
1185
  return html`<div class="field tiles-field">
1183
- <span class="label" id=${labelId}>${this.fieldText(f.name)}${this.reqMark(f)}</span>
1186
+ <span class="label" id=${labelId}>${this.fieldText(f.name, f.label)}${this.reqMark(f)}</span>
1184
1187
  <div
1185
1188
  class=${narrow ? 'tiles narrow' : 'tiles'}
1186
1189
  role="radiogroup"
@@ -1217,7 +1220,7 @@ export class RoxyEndpointForm extends RoxyLocalizedElement {
1217
1220
  private renderSelect(f: FieldDef) {
1218
1221
  const id = `roxy-form-${f.key}`;
1219
1222
  return html`<div part="field" class="field">
1220
- <label for=${id}>${this.fieldText(f.name)}${this.reqMark(f)}</label>
1223
+ <label for=${id}>${this.fieldText(f.name, f.label)}${this.reqMark(f)}</label>
1221
1224
  <select
1222
1225
  id=${id}
1223
1226
  ?required=${f.required}
@@ -1248,7 +1251,7 @@ export class RoxyEndpointForm extends RoxyLocalizedElement {
1248
1251
  const sole = this.soleChoice?.key === f.key;
1249
1252
  const issue = this.issueFor(f);
1250
1253
  return html`<div part="field" class="field">
1251
- ${sole ? nothing : html`<label for=${id}>${this.fieldText(f.name)}${this.reqMark(f)}</label>`}
1254
+ ${sole ? nothing : html`<label for=${id}>${this.fieldText(f.name, f.label)}${this.reqMark(f)}</label>`}
1252
1255
  ${renderPicker(
1253
1256
  picker,
1254
1257
  id,
@@ -1283,7 +1286,7 @@ export class RoxyEndpointForm extends RoxyLocalizedElement {
1283
1286
  <span class="knob"></span>
1284
1287
  </button>
1285
1288
  <label class="toggle-label" for=${id}
1286
- >${this.fieldText(f.name)}${this.reqMark(f)}</label
1289
+ >${this.fieldText(f.name, f.label)}${this.reqMark(f)}</label
1287
1290
  >
1288
1291
  </div>
1289
1292
  ${this.description(f)}
@@ -1306,7 +1309,7 @@ export class RoxyEndpointForm extends RoxyLocalizedElement {
1306
1309
  ? String(f.example)
1307
1310
  : '';
1308
1311
  return html`<div part="field" class="field">
1309
- <label for=${id}>${this.fieldText(f.name)}${this.reqMark(f)}</label>
1312
+ <label for=${id}>${this.fieldText(f.name, f.label)}${this.reqMark(f)}</label>
1310
1313
  <input
1311
1314
  id=${id}
1312
1315
  type=${f.kind === 'array' ? 'text' : type}
@@ -1350,23 +1353,13 @@ export class RoxyEndpointForm extends RoxyLocalizedElement {
1350
1353
  }
1351
1354
  }
1352
1355
 
1353
- /**
1354
- * The name of one request group, translated, falling back to the humanized English.
1355
- *
1356
- * @remarks
1357
- * A group name is the one derived label that is also ENUMERABLE. A field label is `humanize()` over one of 909 spec field names, but a group is `humanize()` over the names an object-valued property or a coordinate prefix can take, and the whole spec has nine across 176 operations. So each is a catalogue entry, and no English token sits inside translated prose (`Local de Natal Chart`, `Место (Birth Data)`). A tenth group appearing in the spec still renders: `t()` returns its source string on a miss, so it degrades to the humanized English rather than to a blank or a key.
1358
- *
1359
- * **The lookup folds case, and that is what makes `natalChart` work.** `humanize` produces `Natal Chart` while the catalogue carries `Natal chart` for the card heading, and {@link lookupKey} folds both to one key on write and on read, so this reuses the shipped translation. Adding the capitalized twin instead would SILENTLY OVERWRITE that heading in every locale rather than reading as a duplicate, which is why `i18n/chrome-strings.ts` carries no entry for it.
1360
- */
1361
- /** The legend of a group: the catalogued name of an object property, or, for one record of a repeating property, the published label of the array with the record's number. */
1356
+ /** The shared group legend, using this form's chrome and field-label catalogues. */
1362
1357
  private groupName(group: string): string {
1363
- const repeat = parseRepeatGroup(group);
1364
- return repeat
1365
- ? this.t('{{group}} {{n}}', {
1366
- group: this.fieldText(repeat.key),
1367
- n: repeat.index + 1,
1368
- })
1369
- : this.t(humanize(group));
1358
+ return deriveGroupLabel(
1359
+ group,
1360
+ (source, vars) => this.t(source, vars),
1361
+ (name) => this.fieldText(name),
1362
+ );
1370
1363
  }
1371
1364
 
1372
1365
  /** How many records a repeating property currently shows. */
@@ -1392,6 +1385,7 @@ export class RoxyEndpointForm extends RoxyLocalizedElement {
1392
1385
  {
1393
1386
  ...template,
1394
1387
  key: repeatGroup(key, index),
1388
+ label: deriveGroupLabel(repeatGroup(key, index)),
1395
1389
  ...(template.location && {
1396
1390
  location: {
1397
1391
  ...template.location,
@@ -27,7 +27,7 @@
27
27
  font-style: normal;
28
28
  font-weight: 400 600;
29
29
  font-display: swap;
30
- src: url("https://cdn.jsdelivr.net/npm/@roxyapi/ui@0.51.0/dist/styles/fonts/fraunces/fraunces-latin.woff2")
30
+ src: url("https://cdn.jsdelivr.net/npm/@roxyapi/ui@0.51.1/dist/styles/fonts/fraunces/fraunces-latin.woff2")
31
31
  format("woff2");
32
32
  unicode-range:
33
33
  U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
@@ -38,7 +38,7 @@
38
38
  font-style: normal;
39
39
  font-weight: 400 600;
40
40
  font-display: swap;
41
- src: url("https://cdn.jsdelivr.net/npm/@roxyapi/ui@0.51.0/dist/styles/fonts/fraunces/fraunces-latin-ext.woff2")
41
+ src: url("https://cdn.jsdelivr.net/npm/@roxyapi/ui@0.51.1/dist/styles/fonts/fraunces/fraunces-latin-ext.woff2")
42
42
  format("woff2");
43
43
  unicode-range:
44
44
  U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
@@ -49,7 +49,7 @@
49
49
  font-style: normal;
50
50
  font-weight: 400 600;
51
51
  font-display: swap;
52
- src: url("https://cdn.jsdelivr.net/npm/@roxyapi/ui@0.51.0/dist/styles/fonts/jost/jost-latin.woff2")
52
+ src: url("https://cdn.jsdelivr.net/npm/@roxyapi/ui@0.51.1/dist/styles/fonts/jost/jost-latin.woff2")
53
53
  format("woff2");
54
54
  unicode-range:
55
55
  U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
@@ -60,7 +60,7 @@
60
60
  font-style: normal;
61
61
  font-weight: 400 600;
62
62
  font-display: swap;
63
- src: url("https://cdn.jsdelivr.net/npm/@roxyapi/ui@0.51.0/dist/styles/fonts/jost/jost-latin-ext.woff2")
63
+ src: url("https://cdn.jsdelivr.net/npm/@roxyapi/ui@0.51.1/dist/styles/fonts/jost/jost-latin-ext.woff2")
64
64
  format("woff2");
65
65
  unicode-range:
66
66
  U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
@@ -71,7 +71,7 @@
71
71
  font-style: normal;
72
72
  font-weight: 400 600;
73
73
  font-display: swap;
74
- src: url("https://cdn.jsdelivr.net/npm/@roxyapi/ui@0.51.0/dist/styles/fonts/jost/jost-cyrillic.woff2")
74
+ src: url("https://cdn.jsdelivr.net/npm/@roxyapi/ui@0.51.1/dist/styles/fonts/jost/jost-cyrillic.woff2")
75
75
  format("woff2");
76
76
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
77
77
  }
@@ -5,7 +5,9 @@
5
5
  * The registry is by SHAPE, never by name: {@link classifyInput} inspects `enum` / `type` / `format` only, so a new API parameter gets a working widget with no code change, and the taxonomy gate fails loudly (via a `null` return) the day a genuinely new shape appears. Name-driven render intent (hidden values, city searches and the Advanced fold) is resolved here too, so browser and server renderers consume the same decisions.
6
6
  */
7
7
 
8
+ import { EN_FIELD_LABELS } from '../generated/field-labels-en.js';
8
9
  import { DISABLED_WHEN, OPTION_SOURCES } from '../generated/option-sources.js';
10
+ import { interpolate } from '../i18n/registry.js';
9
11
  import { SIGNS_ORDER } from '../tokens/index.js';
10
12
  import { humanize } from './string.js';
11
13
 
@@ -47,6 +49,7 @@ export interface OperationSchema {
47
49
  parameters?: Array<{
48
50
  name: string;
49
51
  in: string;
52
+ description?: string;
50
53
  required?: boolean;
51
54
  schema?: OpenApiSchema;
52
55
  }>;
@@ -84,6 +87,8 @@ export interface FieldDef {
84
87
  key: string;
85
88
  /** Schema property name (the label source), e.g. "date". */
86
89
  name: string;
90
+ /** Contextual English label, overriding the generic name label when it loses the field's meaning. */
91
+ label?: string;
87
92
  /** Parent object key for a nested schema (person1/person2); undefined for a flat field. */
88
93
  group?: string;
89
94
  /** True when the spec declares the field as `in: query`, so it belongs in the query string even on a POST. */
@@ -156,6 +161,8 @@ export interface RepeatDef {
156
161
  /** One field group, in field order. An absent key denotes the flat top level. */
157
162
  export interface FormGroup {
158
163
  key?: string;
164
+ /** English legend for a named group; absent for the unlabelled flat top level. */
165
+ label?: string;
159
166
  fold?: true;
160
167
  /** A coordinate pair's city box, with the exact wire keys it fills (including its claimed timezone). */
161
168
  location?: { fields: string[]; required: boolean };
@@ -187,6 +194,32 @@ export function parseRepeatGroup(
187
194
  return m ? { key: m[1] as string, index: Number(m[2]) } : null;
188
195
  }
189
196
 
197
+ /**
198
+ * A group legend, shared by the browser and published labels. Named objects use the chrome
199
+ * catalogue (whose lookup folds case); repeating records use the array's field label and the
200
+ * catalogued numbered-group template. The defaults produce the same legend in English.
201
+ *
202
+ * Catalogue lookup folds case: `humanize('natalChart')` produces `Natal Chart` and reuses
203
+ * the existing `Natal chart` heading translation. Do not add a capitalized twin, which
204
+ * would overwrite that heading in every locale. A new group with no catalogue entry
205
+ * falls back to its humanized English name, so a missing translation never leaves a key
206
+ * or an empty legend inside translated location labels.
207
+ */
208
+ export function deriveGroupLabel(
209
+ group: string,
210
+ t: typeof interpolate = interpolate,
211
+ fieldText: (name: string) => string = (name) =>
212
+ EN_FIELD_LABELS[name] ?? humanize(name),
213
+ ): string {
214
+ const repeat = parseRepeatGroup(group);
215
+ return repeat
216
+ ? t('{{group}} {{n}}', {
217
+ group: fieldText(repeat.key),
218
+ n: repeat.index + 1,
219
+ })
220
+ : t(humanize(group));
221
+ }
222
+
190
223
  /** The fields of one record of a repeating property, from the fields of its first record. Every record is the same template, so the form grows a repeat by re-keying record zero. */
191
224
  export function repeatFields(
192
225
  fields: readonly FieldDef[],
@@ -419,18 +452,13 @@ export function buildFormModel(
419
452
  // identity: rewriting it to `birth.latitude` would serialise a body the API
420
453
  // rejects.
421
454
  const coord = splitCoordinateName(name);
422
- fields.push(
423
- coord
424
- ? toField(coord.leaf, resolved, {
425
- key: name,
426
- group: coord.group,
427
- required: required.has(name),
428
- })
429
- : toField(name, resolved, {
430
- key: name,
431
- required: required.has(name),
432
- }),
433
- );
455
+ const field = toField(coord?.leaf ?? name, resolved, {
456
+ key: name,
457
+ group: coord?.group,
458
+ required: required.has(name),
459
+ });
460
+ if (coord) field.label = `${humanize(coord.group)} ${coord.leaf}`;
461
+ fields.push(field);
434
462
  }
435
463
  }
436
464
  }
@@ -444,13 +472,26 @@ export function buildFormModel(
444
472
  continue;
445
473
  }
446
474
  const resolved = resolveSchema(param.schema, schemas) ?? {};
447
- fields.push(
448
- toField(param.name, resolved, {
449
- key: param.name,
450
- required: !!param.required,
451
- inQuery: param.in === 'query',
452
- }),
453
- );
475
+ const field = toField(param.name, resolved, {
476
+ key: param.name,
477
+ required: !!param.required,
478
+ inQuery: param.in === 'query',
479
+ });
480
+ // Only an otherwise bare identifier needs a noun from the spec. A meaningful
481
+ // name such as `sign` keeps its existing field-label catalogue entry.
482
+ if (
483
+ param.in === 'path' &&
484
+ field.enum &&
485
+ /^(id|identifier|slug)$/i.test(
486
+ EN_FIELD_LABELS[field.name] ?? humanize(field.name),
487
+ )
488
+ ) {
489
+ const noun = /^([A-Za-z][A-Za-z -]*?)\s+(?:id|identifier|slug)\b/i
490
+ .exec(param.description ?? field.description ?? '')?.[1]
491
+ ?.trim();
492
+ if (noun) field.label = noun;
493
+ }
494
+ fields.push(field);
454
495
  }
455
496
 
456
497
  return withRenderIntent(
@@ -497,7 +538,7 @@ export function withRenderIntent(
497
538
  };
498
539
  });
499
540
  const groups: FormGroup[] = [...new Set(fields.map((f) => f.group))].map(
500
- (key) => (key === undefined ? {} : { key }),
541
+ (key) => (key === undefined ? {} : { key, label: deriveGroupLabel(key) }),
501
542
  );
502
543
  const locations = groups.filter((g) =>
503
544
  LOCATION_PAIR.every((name) =>
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by scripts/sync-version.ts. Do not edit.
2
- export const ROXY_UI_VERSION = '0.51.0';
2
+ export const ROXY_UI_VERSION = '0.51.1';