@sillsdev/config-r 1.0.0-alpha.29 → 1.0.0-alpha.30

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 CHANGED
@@ -65,3 +65,22 @@ To provide languages other than English for the small set of built-in strings, p
65
65
  ```
66
66
 
67
67
  `searchLabel` is used for both the visible search placeholder and the input accessibility label.
68
+
69
+ ## Knowing and choosing the page
70
+
71
+ `onTopLevelPageChange` is called with the `pageKey` of the top-level page showing, when the pane mounts and whenever the page changes. To show a page from outside the pane, put a ref on it and call `selectTopLevelPage`, which shows that page and keeps the values being edited:
72
+
73
+ ```tsx
74
+ const paneRef = React.useRef<ConfigrPaneHandle>(null);
75
+
76
+ <ConfigrPane
77
+ ref={paneRef}
78
+ label="Settings"
79
+ initialValues={initialValues}
80
+ onTopLevelPageChange={(pageKey) => setShownPage(pageKey)}
81
+ >
82
+ {/* pages */}
83
+ </ConfigrPane>;
84
+
85
+ paneRef.current?.selectTopLevelPage('subscription');
86
+ ```
@@ -2,7 +2,15 @@ import { ThemeOptions } from '@mui/material';
2
2
  import { ConfigrLocalizationOverrides } from './ConfigrLocalizations';
3
3
  import { ConfigrArea, ConfigrPage, ConfigrValues } from './ContentPane';
4
4
  import * as React from 'react';
5
- export declare const ConfigrPane: React.FunctionComponent<React.PropsWithChildren<{
5
+ /** What a ref on a ConfigrPane can do. */
6
+ export interface ConfigrPaneHandle {
7
+ /**
8
+ * Shows the top-level page with this key, keeping the values being edited. A key that
9
+ * names no page, or a disabled one, is ignored.
10
+ */
11
+ selectTopLevelPage: (pageKey: string) => void;
12
+ }
13
+ export declare const ConfigrPane: React.ForwardRefExoticComponent<{
6
14
  label: string;
7
15
  initialValues: ConfigrValues;
8
16
  children: React.ReactElement<React.ComponentProps<typeof ConfigrPage>> | React.ReactElement<React.ComponentProps<typeof ConfigrArea>> | Array<React.ReactElement<React.ComponentProps<typeof ConfigrPage>> | React.ReactElement<React.ComponentProps<typeof ConfigrArea>>>;
@@ -16,4 +24,12 @@ export declare const ConfigrPane: React.FunctionComponent<React.PropsWithChildre
16
24
  localizations?: ConfigrLocalizationOverrides;
17
25
  className?: string;
18
26
  initiallySelectedTopLevelPageKey?: string;
19
- }>>;
27
+ /**
28
+ * Called with the pageKey of the top-level page now showing: once when the pane mounts,
29
+ * and again each time the page changes, by the user or by selectTopLevelPage. It gets
30
+ * undefined while no top-level page is showing (an area's own content, or a search).
31
+ */
32
+ onTopLevelPageChange?: (pageKey: string | undefined) => void;
33
+ } & {
34
+ children?: React.ReactNode | undefined;
35
+ } & React.RefAttributes<ConfigrPaneHandle>>;