@sillsdev/config-r 1.0.0-alpha.23 → 1.0.0-alpha.25
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/README.md +26 -2
- package/dist/ConfigrLocalizations.d.ts +10 -0
- package/dist/ConfigrPane.d.ts +3 -0
- package/dist/ContentPane.d.ts +18 -9
- package/dist/configr.cjs.js +137 -121
- package/dist/configr.cjs.js.map +1 -1
- package/dist/configr.es.js +4950 -4794
- package/dist/configr.es.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/validation.d.ts +21 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,5 +39,29 @@ Use [src/stories/bloom.stories.tsx](src/stories/bloom.stories.tsx) as the canoni
|
|
|
39
39
|
- `ConfigrForEach` now uses a render signature of `(pathPrefix, index) => ReactNode`; build full Formik paths from the prefix (see the languages loop in the story).
|
|
40
40
|
- `ConfigrSelect` options accept numbers or `{ label, value, description }` objects; descriptions become tooltips.
|
|
41
41
|
- Override/locking behavior is standardized: most controls accept `overrideValue` + `overrideDescription`; `ConfigrBoolean` adds `locked` and `immediateEffect`.
|
|
42
|
-
- `
|
|
43
|
-
- `
|
|
42
|
+
- Leaf controls support `required` and `validation`. `validation` receives the current field value and may return `true`, `false`, or a string. `false` renders a generic `Invalid value` message, while a string is shown inline in red.
|
|
43
|
+
- Required fields show a `*` beside the control. The fallback `Required` message for empty required fields is controlled at the pane level with `showRequiredMessage` and defaults to `true`.
|
|
44
|
+
- `ConfigrInput` covers standard text, number, and email fields. It also supports `charactersWide`, `allowNewLines`, `minLinesToShow`, and `maxLinesToShowBeforeScrolling` for compact multiline text entry.
|
|
45
|
+
- `ConfigrPane` adds UI props like `showAppBar`, `showSearch`, `showJson`, `themeOverrides`, `initiallySelectedTopLevelPageKey`, and `localizations`.
|
|
46
|
+
|
|
47
|
+
## Localization
|
|
48
|
+
|
|
49
|
+
To provide languages other than English for the small set of built-in strings, pass `localizations` to `ConfigrPane`:
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
<ConfigrPane
|
|
53
|
+
label="Configuracion"
|
|
54
|
+
initialValues={initialValues}
|
|
55
|
+
showSearch={true}
|
|
56
|
+
localizations={{
|
|
57
|
+
fieldRequiredMessage: 'Requiere un valor',
|
|
58
|
+
invalidValueMessage: 'Valor no valido',
|
|
59
|
+
searchLabel: 'Buscar',
|
|
60
|
+
matchesLabel: (count) => `${count} coincidencias`,
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
{/* pages */}
|
|
64
|
+
</ConfigrPane>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`searchLabel` is used for both the visible search placeholder and the input accessibility label.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type ConfigrLocalizations = {
|
|
3
|
+
fieldRequiredMessage: string;
|
|
4
|
+
invalidValueMessage: string;
|
|
5
|
+
searchLabel: string;
|
|
6
|
+
matchesLabel: (count: number) => string;
|
|
7
|
+
};
|
|
8
|
+
export type ConfigrLocalizationOverrides = Partial<ConfigrLocalizations>;
|
|
9
|
+
export declare const defaultConfigrLocalizations: ConfigrLocalizations;
|
|
10
|
+
export declare const ConfigrLocalizationContext: React.Context<ConfigrLocalizations>;
|
package/dist/ConfigrPane.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ThemeOptions } from '@mui/material';
|
|
2
|
+
import { ConfigrLocalizationOverrides } from './ConfigrLocalizations';
|
|
2
3
|
import { ConfigrArea, ConfigrPage, ConfigrValues } from './ContentPane';
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
export declare const ConfigrPane: React.FunctionComponent<React.PropsWithChildren<{
|
|
@@ -11,6 +12,8 @@ export declare const ConfigrPane: React.FunctionComponent<React.PropsWithChildre
|
|
|
11
12
|
showSearch?: boolean;
|
|
12
13
|
themeOverrides?: ThemeOptions;
|
|
13
14
|
showJson?: boolean;
|
|
15
|
+
showRequiredMessage?: boolean;
|
|
16
|
+
localizations?: ConfigrLocalizationOverrides;
|
|
14
17
|
className?: string;
|
|
15
18
|
initiallySelectedTopLevelPageKey?: string;
|
|
16
19
|
}>>;
|
package/dist/ContentPane.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SerializedStyles } from '@emotion/react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
+
import { ConfigrErrorMessageGetter, ConfigrValidation } from './validation';
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
export type ConfigrValues = Record<string, unknown>;
|
|
5
6
|
type valueGetter = () => ConfigrValues;
|
|
@@ -12,6 +13,7 @@ export declare const ConfigrArea: React.FunctionComponent<React.PropsWithChildre
|
|
|
12
13
|
export declare const ContentPane: React.FunctionComponent<React.PropsWithChildren<{
|
|
13
14
|
initialValues: ConfigrValues;
|
|
14
15
|
currentTopLevelPageIndex?: number;
|
|
16
|
+
showRequiredMessage?: boolean;
|
|
15
17
|
children: React.ReactElement<React.ComponentProps<typeof ConfigrPage>> | React.ReactElement<React.ComponentProps<typeof ConfigrPage>>[];
|
|
16
18
|
setValueGetter?: (vg: valueGetter) => void;
|
|
17
19
|
/** Called with the latest values as a plain object (not a JSON string). */
|
|
@@ -27,6 +29,9 @@ interface IConfigrProps<T> {
|
|
|
27
29
|
label: string;
|
|
28
30
|
description?: string;
|
|
29
31
|
disabled?: boolean;
|
|
32
|
+
required?: boolean;
|
|
33
|
+
validation?: ConfigrValidation<T>;
|
|
34
|
+
getErrorMessage?: ConfigrErrorMessageGetter;
|
|
30
35
|
overrideValue?: T;
|
|
31
36
|
overrideDescription?: string;
|
|
32
37
|
pageKey?: string;
|
|
@@ -35,7 +40,11 @@ export declare const ConfigrInput: React.FunctionComponent<React.PropsWithChildr
|
|
|
35
40
|
className?: string;
|
|
36
41
|
type?: 'text' | 'number' | 'email';
|
|
37
42
|
units?: string;
|
|
38
|
-
|
|
43
|
+
charactersWide?: number;
|
|
44
|
+
allowNewLines?: boolean;
|
|
45
|
+
minLinesToShow?: number;
|
|
46
|
+
maxLinesToShowBeforeScrolling?: number;
|
|
47
|
+
getErrorMessage?: ConfigrErrorMessageGetter;
|
|
39
48
|
}>>;
|
|
40
49
|
interface ICustomStringInputProps extends IConfigrProps<string> {
|
|
41
50
|
control: React.FunctionComponent<{
|
|
@@ -43,12 +52,12 @@ interface ICustomStringInputProps extends IConfigrProps<string> {
|
|
|
43
52
|
disabled?: boolean;
|
|
44
53
|
onChange: (value: string) => void;
|
|
45
54
|
}>;
|
|
46
|
-
getErrorMessage?:
|
|
55
|
+
getErrorMessage?: ConfigrErrorMessageGetter;
|
|
47
56
|
}
|
|
48
57
|
export declare const ConfigrCustomStringInput: React.FunctionComponent<React.PropsWithChildren<ICustomStringInputProps>>;
|
|
49
58
|
interface ICustomBooleanInputProps extends IConfigrProps<boolean> {
|
|
50
59
|
control: BooleanEditorComponent;
|
|
51
|
-
getErrorMessage?:
|
|
60
|
+
getErrorMessage?: ConfigrErrorMessageGetter;
|
|
52
61
|
}
|
|
53
62
|
export declare const ConfigrCustomBooleanInput: React.FunctionComponent<React.PropsWithChildren<ICustomBooleanInputProps>>;
|
|
54
63
|
interface ICustomNumberInputProps extends IConfigrProps<number> {
|
|
@@ -57,7 +66,7 @@ interface ICustomNumberInputProps extends IConfigrProps<number> {
|
|
|
57
66
|
disabled?: boolean;
|
|
58
67
|
onChange: (value: number) => void;
|
|
59
68
|
}>>;
|
|
60
|
-
getErrorMessage?:
|
|
69
|
+
getErrorMessage?: ConfigrErrorMessageGetter;
|
|
61
70
|
}
|
|
62
71
|
export declare const ConfigrCustomNumberInput: React.FunctionComponent<React.PropsWithChildren<ICustomNumberInputProps>>;
|
|
63
72
|
interface ICustomObjectInputProps<T> extends IConfigrProps<unknown> {
|
|
@@ -66,7 +75,7 @@ interface ICustomObjectInputProps<T> extends IConfigrProps<unknown> {
|
|
|
66
75
|
disabled?: boolean;
|
|
67
76
|
onChange: (value: T) => void;
|
|
68
77
|
}>>;
|
|
69
|
-
getErrorMessage?:
|
|
78
|
+
getErrorMessage?: ConfigrErrorMessageGetter;
|
|
70
79
|
}
|
|
71
80
|
export declare function ConfigrCustomObjectInput<T>(props: React.PropsWithChildren<ICustomObjectInputProps<T>>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
72
81
|
interface ISelectProps extends IConfigrProps<string> {
|
|
@@ -77,7 +86,7 @@ interface ISelectProps extends IConfigrProps<string> {
|
|
|
77
86
|
description?: string;
|
|
78
87
|
} | number>;
|
|
79
88
|
enableWhen?: string | ((currentValues: object) => boolean);
|
|
80
|
-
getErrorMessage?:
|
|
89
|
+
getErrorMessage?: ConfigrErrorMessageGetter;
|
|
81
90
|
}
|
|
82
91
|
export declare const ConfigrSelect: React.FunctionComponent<React.PropsWithChildren<ISelectProps>>;
|
|
83
92
|
export declare const ConfigrStatic: React.FunctionComponent<React.PropsWithChildren<{}>>;
|
|
@@ -85,7 +94,7 @@ export declare const ConfigrGroup: React.FunctionComponent<React.PropsWithChildr
|
|
|
85
94
|
label?: string;
|
|
86
95
|
searchTerms?: string;
|
|
87
96
|
description?: string | React.ReactNode;
|
|
88
|
-
getErrorMessage?:
|
|
97
|
+
getErrorMessage?: ConfigrErrorMessageGetter;
|
|
89
98
|
inFocussedPage?: boolean;
|
|
90
99
|
}>>;
|
|
91
100
|
export type PageChild = React.ReactElement<typeof ConfigrGroup> | false | undefined | null;
|
|
@@ -95,7 +104,7 @@ export declare const ConfigrPage: React.FunctionComponent<React.PropsWithChildre
|
|
|
95
104
|
pageKey: string;
|
|
96
105
|
searchTerms?: string;
|
|
97
106
|
topLevel?: boolean;
|
|
98
|
-
getErrorMessage?:
|
|
107
|
+
getErrorMessage?: ConfigrErrorMessageGetter;
|
|
99
108
|
inFocussedPage?: boolean;
|
|
100
109
|
disabled?: boolean;
|
|
101
110
|
children: PageChild | PageChild[];
|
|
@@ -105,7 +114,7 @@ export declare const ConfigrForEach: React.FunctionComponent<React.PropsWithChil
|
|
|
105
114
|
searchTerms: string;
|
|
106
115
|
inFocussedPage?: boolean;
|
|
107
116
|
render: (pathPrefix: string, index: number) => React.ReactNode;
|
|
108
|
-
getErrorMessage?:
|
|
117
|
+
getErrorMessage?: ConfigrErrorMessageGetter;
|
|
109
118
|
}>>;
|
|
110
119
|
export declare const ConfigrBoolean: React.FunctionComponent<React.PropsWithChildren<IConfigrProps<boolean> & {
|
|
111
120
|
immediateEffect?: boolean;
|