@mistriwork/kit 1.0.0-rc.49 → 1.0.0-rc.51

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.
@@ -6,9 +6,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
6
6
  import { DateField as Field } from '@mistriwork/ui/DateField.js';
7
7
  import { Icon } from './Icon.js';
8
8
  import { say } from '../copy/forms/components/DateField.js';
9
+ import { appWord } from '../messages.js';
9
10
  /* Read when a field draws, so a catalog worn later is the one said. */
10
11
  const words = () => ({
11
- dateTimePattern: say('yyyyMmDdHh'),
12
+ dateTimePattern: appWord('mistri.form.dateTimeHint', say('yyyyMmDdHh')),
12
13
  enterDateAndTime: say('enterADateAndTime'),
13
14
  enterDate: (format) => say('enterADateInYyyy', { format }),
14
15
  dateAndTimeFormat: say('dateAndTimeFormat'),
@@ -12,6 +12,7 @@ import { Button } from '@mistriwork/ui/Button.js';
12
12
  import { ActionBar, ProgressBar, StepHeader } from '@mistriwork/ui/FormParts.js';
13
13
  /* The progress bar, the step header and the action bar wear @mistriwork/ui's form rules, which arrive with this chunk. */
14
14
  import { say } from '../copy/forms/components/MultiStepForm.js';
15
+ import { appWord } from '../messages.js';
15
16
  const MAX_RENDERED_STEPS = 16;
16
17
  /* The intake style's sheets (intakeStyle.ts), fetched the first time a form wears it. Until they are here the form
17
18
  draws nothing rather than an undressed frame that would move as they land. */
@@ -40,7 +41,7 @@ function safeIndex(index, length) {
40
41
  * surrounding New/command/business form supplies those through children and
41
42
  * validateStep, so moving between steps cannot create a second write path.
42
43
  */
43
- export function MultiStepForm({ steps, children, step, initialStep = 0, onStepChange, validateStep, onComplete, nextLabel, previousLabel = say('common.back'), completeLabel = say('common.save'), className = '', leading, said: hostSaid, style = 'stepper', note, isStepEmpty, presentation = 'page', headingLevel = 1, summarize, }) {
44
+ export function MultiStepForm({ steps, children, step, initialStep = 0, onStepChange, validateStep, onComplete, nextLabel, previousLabel = appWord('mistri.form.back', say('common.back')), completeLabel = say('common.save'), className = '', leading, said: hostSaid, style = 'stepper', note, isStepEmpty, presentation = 'page', headingLevel = 1, summarize, }) {
44
45
  const id = useId();
45
46
  const boundedSteps = steps.slice(0, MAX_RENDERED_STEPS);
46
47
  const controlled = step !== undefined;
@@ -193,7 +194,14 @@ export function MultiStepForm({ steps, children, step, initialStep = 0, onStepCh
193
194
  /* The bar and its count beside it. The count is the bar's own name said again for the eye, so it is hidden from
194
195
  assistive technology, which hears the bar's. A form of one step has no way through to show: "Step 1 of 1" over a
195
196
  full bar said nothing, so neither is drawn. */
196
- const progressRow = boundedSteps.length > 1 && (_jsxs("div", { className: "multi-step-progress", children: [_jsx(ProgressBar, { min: 1, value: current + 1, max: boundedSteps.length, label: say('progress', { step: current + 1, count: boundedSteps.length, label: active.label }) }), _jsx("span", { className: "multi-step-count", "aria-hidden": "true", children: say('stepOf', { step: current + 1, count: boundedSteps.length }) })] }));
197
+ const progressRow = boundedSteps.length > 1 && (_jsxs("div", { className: "multi-step-progress", children: [_jsx(ProgressBar, { min: 1, value: current + 1, max: boundedSteps.length, label: appWord('mistri.form.stepNamed', say('progress', { step: current + 1, count: boundedSteps.length, label: active.label }), {
198
+ step: current + 1,
199
+ count: boundedSteps.length,
200
+ label: active.label,
201
+ }) }), _jsx("span", { className: "multi-step-count", "aria-hidden": "true", children: appWord('mistri.form.step', say('stepOf', { step: current + 1, count: boundedSteps.length }), {
202
+ step: current + 1,
203
+ count: boundedSteps.length,
204
+ }) })] }));
197
205
  const panelNode = (_jsx("div", { id: panelId, ref: panel, className: "multi-step-panel", role: "group", "aria-labelledby": titleId, onKeyDown: enter, children: children(active, current) }));
198
206
  const problemNode = (_jsx("p", { ref: said, tabIndex: -1, className: "multi-step-problem", role: "alert", "aria-live": "polite", hidden: !problem, children: problem }));
199
207
  /* A page's steps beside the form (drawn, and shown only where the page is wide enough, by structure.css, so the
@@ -1,3 +1,4 @@
1
+ import type { FrameworkWordKey } from '@mistriwork/engine/shared/frameworkWords.js';
1
2
  type MessageLanguage = 'en' | 'es';
2
3
  type MessageValue = string | {
3
4
  one: string;
@@ -193,6 +194,8 @@ export interface ServedLanguage {
193
194
  locale?: string | undefined;
194
195
  /** The App has words in several languages (`ui.languages`): the server's answer is the language, chrome included. */
195
196
  offered?: readonly string[] | undefined;
197
+ /** The platform's form words the App's catalog says in the reader's language (`mistri.*`): what `appWord` says. */
198
+ words?: Readonly<Record<string, string>> | undefined;
196
199
  }
197
200
  /**
198
201
  * Select the current App (undefined is the Workbench) and what the server
@@ -203,6 +206,16 @@ export interface ServedLanguage {
203
206
  * again with nothing new does not create a render.
204
207
  */
205
208
  export declare function setMessageScope(appId?: string, language?: ServedLanguage): Promise<void>;
209
+ /**
210
+ * Hold the App's words for the platform's (`words`, served beside a public form, which has no App shell to scope it).
211
+ * The next form drawn says them.
212
+ */
213
+ export declare function holdAppWords(words: Readonly<Record<string, string>> | undefined): void;
214
+ /**
215
+ * One of the platform's form words (`mistri.form.back`, engine shared/frameworkWords.ts) as the App's catalog says it
216
+ * in the reader's language, filled with its values; else `fallback`, the platform's own in the chrome's language.
217
+ */
218
+ export declare function appWord(key: FrameworkWordKey, fallback: string, params?: MessageParams): string;
206
219
  /** The active framework language, always one the framework catalog supports. */
207
220
  export declare function messageLanguage(): MessageLanguage;
208
221
  /** The App's languages a reader may pick among, where the server says its words in several; empty elsewhere. */
@@ -188,6 +188,8 @@ const sharedIn = (lang) => translations[lang] ?? {};
188
188
  const STORAGE_PREFIX = 'mistri.messages.language.';
189
189
  let scope;
190
190
  let served = {};
191
+ /** The App's words for the platform's own (`holdAppWords`): a public form holds its own, an App's shell its payload's. */
192
+ let appWords = {};
191
193
  /** The language on screen; `wanted` is the one asked for, which `language` becomes once its words are here. */
192
194
  let language = 'en';
193
195
  let wanted = 'en';
@@ -276,6 +278,7 @@ function want(next, changed) {
276
278
  export function setMessageScope(appId, language) {
277
279
  const nextScope = appId || undefined;
278
280
  served = language ?? {};
281
+ appWords = served.words ?? {};
279
282
  const next = served.offered?.length ? chromeLanguage(served.locale) : (savedLanguage(nextScope) ?? chromeLanguage(served.locale));
280
283
  const moved = scope !== nextScope;
281
284
  scope = nextScope;
@@ -283,6 +286,21 @@ export function setMessageScope(appId, language) {
283
286
  return arriving.get(next) ?? Promise.resolve();
284
287
  return want(next, moved);
285
288
  }
289
+ /**
290
+ * Hold the App's words for the platform's (`words`, served beside a public form, which has no App shell to scope it).
291
+ * The next form drawn says them.
292
+ */
293
+ export function holdAppWords(words) {
294
+ appWords = words ?? {};
295
+ }
296
+ /**
297
+ * One of the platform's form words (`mistri.form.back`, engine shared/frameworkWords.ts) as the App's catalog says it
298
+ * in the reader's language, filled with its values; else `fallback`, the platform's own in the chrome's language.
299
+ */
300
+ export function appWord(key, fallback, params) {
301
+ const word = Object.hasOwn(appWords, key) ? appWords[key] : undefined;
302
+ return word === undefined ? fallback : interpolate(word, params);
303
+ }
286
304
  /** The active framework language, always one the framework catalog supports. */
287
305
  export function messageLanguage() {
288
306
  return language;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistriwork/kit",
3
- "version": "1.0.0-rc.49",
3
+ "version": "1.0.0-rc.51",
4
4
  "description": "The shared React client both shells are drawn with: the walk and the address, Grid, Value, the record page, lists, filters and charts.",
5
5
  "homepage": "https://mistriwork.dev",
6
6
  "bugs": {
@@ -83,8 +83,8 @@
83
83
  "./package.json": "./package.json"
84
84
  },
85
85
  "dependencies": {
86
- "@mistriwork/engine": "1.0.0-rc.49",
87
- "@mistriwork/ui": "1.0.0-rc.49",
86
+ "@mistriwork/engine": "1.0.0-rc.51",
87
+ "@mistriwork/ui": "1.0.0-rc.51",
88
88
  "intl-messageformat": "12.1.2",
89
89
  "qrcode-generator": "^2.0.4"
90
90
  },