@jupyterlab/settingeditor 4.0.0-alpha.2 → 4.0.0-alpha.5

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.
@@ -0,0 +1,83 @@
1
+ import { Settings } from '@jupyterlab/settingregistry';
2
+ import { ITranslator } from '@jupyterlab/translation';
3
+ import { Field } from '@rjsf/core';
4
+ import React from 'react';
5
+ import { PluginList } from './pluginlist';
6
+ /**
7
+ * Namespace for a React component that prepares the settings for a
8
+ * given plugin to be rendered in the FormEditor.
9
+ */
10
+ export declare namespace SettingsFormEditor {
11
+ /**
12
+ * Props passed to the SettingsFormEditor component
13
+ */
14
+ interface IProps {
15
+ /**
16
+ * Settings object with schema and user defined values.
17
+ */
18
+ settings: Settings;
19
+ /**
20
+ * Dictionary used for custom field renderers in the form.
21
+ */
22
+ renderers: {
23
+ [id: string]: Field;
24
+ };
25
+ /**
26
+ * Whether the form is collapsed or not.
27
+ */
28
+ isCollapsed: boolean;
29
+ /**
30
+ * Callback with the collapse state value.
31
+ */
32
+ onCollapseChange: (v: boolean) => void;
33
+ /**
34
+ * Translator object
35
+ */
36
+ translator: ITranslator;
37
+ /**
38
+ * Callback to update the plugin list when a validation error occurs.
39
+ */
40
+ hasError: (error: boolean) => void;
41
+ /**
42
+ * Handler for when selection change is triggered by scrolling
43
+ * in the SettingsPanel.
44
+ */
45
+ onSelect: (id: string) => void;
46
+ /**
47
+ * Sends whether this editor has unsaved changes to the parent class.
48
+ */
49
+ updateDirtyState: (dirty: boolean) => void;
50
+ }
51
+ interface IState {
52
+ /**
53
+ * The current form values being displayed in the editor.
54
+ */
55
+ formData: any;
56
+ /**
57
+ * Indicates whether the settings have been modified. Used for hiding
58
+ * the "Restore to Default" button when there are no changes.
59
+ */
60
+ isModified: boolean;
61
+ }
62
+ }
63
+ /**
64
+ * A React component that prepares the settings for a
65
+ * given plugin to be rendered in the FormEditor.
66
+ */
67
+ export declare class SettingsFormEditor extends React.Component<SettingsFormEditor.IProps, SettingsFormEditor.IState> {
68
+ constructor(props: SettingsFormEditor.IProps);
69
+ /**
70
+ * Handler for edits made in the form editor.
71
+ * @param data - Form data sent from the form editor
72
+ */
73
+ handleChange(): void;
74
+ /**
75
+ * Handler for the "Restore to defaults" button - clears all
76
+ * modified settings then calls `setFormData` to restore the
77
+ * values.
78
+ */
79
+ reset: () => Promise<void>;
80
+ render(): JSX.Element;
81
+ protected onSelect: (list: PluginList, id: string) => void;
82
+ private _debouncer;
83
+ }
@@ -0,0 +1,206 @@
1
+ /* -----------------------------------------------------------------------------
2
+ | Copyright (c) Jupyter Development Team.
3
+ | Distributed under the terms of the Modified BSD License.
4
+ |----------------------------------------------------------------------------*/
5
+ import { showErrorMessage } from '@jupyterlab/apputils';
6
+ import { caretDownIcon, caretRightIcon } from '@jupyterlab/ui-components';
7
+ import { reduce } from '@lumino/algorithm';
8
+ import { JSONExt } from '@lumino/coreutils';
9
+ import { Debouncer } from '@lumino/polling';
10
+ import Form, { utils } from '@rjsf/core';
11
+ import React from 'react';
12
+ /**
13
+ * Indentation to use when saving the settings as JSON document.
14
+ */
15
+ const JSON_INDENTATION = 4;
16
+ /**
17
+ * Template to allow for custom buttons to re-order/remove entries in an array.
18
+ * Necessary to create accessible buttons.
19
+ */
20
+ const CustomArrayTemplateFactory = (translator) => {
21
+ const trans = translator.load('jupyterlab');
22
+ const factory = (props) => {
23
+ var _a;
24
+ return (React.createElement("div", { className: props.className },
25
+ React.createElement(props.TitleField, { title: props.title, required: props.required, id: `${props.idSchema.$id}-title` }),
26
+ React.createElement(props.DescriptionField, { id: `${props.idSchema.$id}-description`, description: (_a = props.schema.description) !== null && _a !== void 0 ? _a : '' }),
27
+ props.items.map(item => {
28
+ return (React.createElement("div", { key: item.key, className: item.className },
29
+ item.children,
30
+ React.createElement("div", { className: "jp-ArrayOperations" },
31
+ React.createElement("button", { className: "jp-mod-styled jp-mod-reject", onClick: item.onReorderClick(item.index, item.index - 1), disabled: !item.hasMoveUp }, trans.__('Move Up')),
32
+ React.createElement("button", { className: "jp-mod-styled jp-mod-reject", onClick: item.onReorderClick(item.index, item.index + 1), disabled: !item.hasMoveDown }, trans.__('Move Down')),
33
+ React.createElement("button", { className: "jp-mod-styled jp-mod-warn", onClick: item.onDropIndexClick(item.index), disabled: !item.hasRemove }, trans.__('Remove')))));
34
+ }),
35
+ props.canAdd && (React.createElement("button", { className: "jp-mod-styled jp-mod-reject", onClick: props.onAddClick }, trans.__('Add')))));
36
+ };
37
+ factory.displayName = 'CustomArrayTemplate';
38
+ return factory;
39
+ };
40
+ /**
41
+ * Template with custom add button, necessary for accessiblity and internationalization.
42
+ */
43
+ const CustomObjectTemplateFactory = (translator) => {
44
+ const trans = translator.load('jupyterlab');
45
+ const factory = (props) => {
46
+ const { TitleField, DescriptionField } = props;
47
+ return (React.createElement("fieldset", { id: props.idSchema.$id },
48
+ (props.uiSchema['ui:title'] || props.title) && (React.createElement(TitleField, { id: `${props.idSchema.$id}__title`, title: props.title || props.uiSchema['ui:title'], required: props.required })),
49
+ props.description && (React.createElement(DescriptionField, { id: `${props.idSchema.$id}__description`, description: props.description })),
50
+ props.properties.map(property => property.content),
51
+ utils.canExpand(props.schema, props.uiSchema, props.formData) && (React.createElement("button", { className: "jp-mod-styled jp-mod-reject", onClick: props.onAddClick(props.schema), disabled: props.disabled || props.readonly }, trans.__('Add')))));
52
+ };
53
+ factory.displayName = 'CustomObjectTemplate';
54
+ return factory;
55
+ };
56
+ /**
57
+ * Renders the modified indicator and errors
58
+ */
59
+ const CustomTemplate = (props) => {
60
+ const { formData, schema, label, displayLabel, id, formContext, errors, rawErrors, children, onKeyChange, onDropPropertyClick } = props;
61
+ /**
62
+ * Determine if the field has been modified
63
+ * Schema Id is formatted as 'root_<field name>.<nexted field name>'
64
+ * This logic parses out the field name to find the default value
65
+ * before determining if the field has been modified.
66
+ */
67
+ const schemaIds = id.split('_');
68
+ schemaIds.shift();
69
+ const schemaId = schemaIds.join('.');
70
+ let defaultValue;
71
+ if (schemaIds.length === 1) {
72
+ defaultValue = formContext.settings.default(schemaId);
73
+ }
74
+ else if (schemaIds.length > 1) {
75
+ const allDefaultsForObject = {};
76
+ allDefaultsForObject[schemaIds[0]] = formContext.settings.default(schemaIds[0]);
77
+ defaultValue = reduce(schemaIds, (acc, val, i) => {
78
+ return acc === null || acc === void 0 ? void 0 : acc[val];
79
+ }, allDefaultsForObject);
80
+ }
81
+ const isModified = schemaId !== '' &&
82
+ formData !== undefined &&
83
+ defaultValue !== undefined &&
84
+ !schema.properties &&
85
+ schema.type !== 'array' &&
86
+ !JSONExt.deepEqual(formData, defaultValue);
87
+ const isRoot = schemaId === '';
88
+ const needsDescription = !isRoot &&
89
+ schema.type != 'object' &&
90
+ id !=
91
+ 'jp-SettingsEditor-@jupyterlab/shortcuts-extension:shortcuts_shortcuts';
92
+ // While we can implement "remove" button for array items in array template,
93
+ // object templates do not provide a way to do this; instead we need to add
94
+ // buttons here (and first check if the field can be removed = is additional).
95
+ const isAdditional = schema.hasOwnProperty(utils.ADDITIONAL_PROPERTY_FLAG);
96
+ return (React.createElement("div", { className: `form-group ${displayLabel || schema.type === 'boolean' ? 'small-field' : ''}` },
97
+ // Only show the modified indicator if there are no errors
98
+ isModified && !rawErrors && React.createElement("div", { className: "jp-modifiedIndicator" }),
99
+ // Shows a red indicator for fields that have validation errors
100
+ rawErrors && React.createElement("div", { className: "jp-modifiedIndicator jp-errorIndicator" }),
101
+ React.createElement("div", { className: "jp-FormGroup-content" },
102
+ displayLabel && !isRoot && label && !isAdditional && (React.createElement("h3", { className: "jp-FormGroup-fieldLabel jp-FormGroup-contentItem" }, label)),
103
+ isAdditional && (React.createElement("input", { className: "jp-FormGroup-contentItem jp-mod-styled", type: "text", onBlur: event => onKeyChange(event.target.value), defaultValue: label })),
104
+ React.createElement("div", { className: `${isRoot
105
+ ? 'jp-root'
106
+ : schema.type === 'object'
107
+ ? 'jp-objectFieldWrapper'
108
+ : 'jp-inputFieldWrapper jp-FormGroup-contentItem'}` }, children),
109
+ isAdditional && (React.createElement("button", { className: "jp-FormGroup-contentItem jp-mod-styled jp-mod-warn jp-FormGroup-removeButton", onClick: onDropPropertyClick(label) }, 'Remove')),
110
+ schema.description && needsDescription && (React.createElement("div", { className: "jp-FormGroup-description" }, schema.description)),
111
+ React.createElement("div", { className: "validationErrors" }, errors))));
112
+ };
113
+ /**
114
+ * A React component that prepares the settings for a
115
+ * given plugin to be rendered in the FormEditor.
116
+ */
117
+ export class SettingsFormEditor extends React.Component {
118
+ constructor(props) {
119
+ super(props);
120
+ /**
121
+ * Handler for the "Restore to defaults" button - clears all
122
+ * modified settings then calls `setFormData` to restore the
123
+ * values.
124
+ */
125
+ this.reset = async () => {
126
+ for (const field in this.props.settings.user) {
127
+ await this.props.settings.remove(field);
128
+ }
129
+ this.setState({
130
+ formData: this.props.settings.composite,
131
+ isModified: false
132
+ });
133
+ };
134
+ this.onSelect = (list, id) => {
135
+ if (id === this.props.settings.id) {
136
+ this.props.onCollapseChange(false);
137
+ }
138
+ };
139
+ const { settings } = props;
140
+ this.state = {
141
+ formData: settings.composite,
142
+ isModified: settings.isModified
143
+ };
144
+ this.handleChange = this.handleChange.bind(this);
145
+ this._debouncer = new Debouncer(this.handleChange);
146
+ }
147
+ /**
148
+ * Handler for edits made in the form editor.
149
+ * @param data - Form data sent from the form editor
150
+ */
151
+ handleChange() {
152
+ // Prevent unnecessary save when opening settings that haven't been modified.
153
+ if (!this.props.settings.isModified &&
154
+ this.props.settings.isDefault(this.state.formData)) {
155
+ this.props.updateDirtyState(false);
156
+ return;
157
+ }
158
+ this.props.settings
159
+ .save(JSON.stringify(this.state.formData, undefined, JSON_INDENTATION))
160
+ .then(() => {
161
+ this.props.updateDirtyState(false);
162
+ this.setState({ isModified: this.props.settings.isModified });
163
+ })
164
+ .catch((reason) => {
165
+ this.props.updateDirtyState(false);
166
+ const trans = this.props.translator.load('jupyterlab');
167
+ showErrorMessage(trans.__('Error saving settings.'), reason);
168
+ });
169
+ }
170
+ render() {
171
+ var _a;
172
+ const trans = this.props.translator.load('jupyterlab');
173
+ /**
174
+ * Construct uiSchema to pass any custom renderers to the form editor.
175
+ */
176
+ const uiSchema = {};
177
+ for (const id in this.props.renderers) {
178
+ if (Object.keys((_a = this.props.settings.schema.properties) !== null && _a !== void 0 ? _a : {}).includes(id)) {
179
+ uiSchema[id] = {
180
+ 'ui:field': id
181
+ };
182
+ }
183
+ }
184
+ const icon = this.props.isCollapsed ? caretRightIcon : caretDownIcon;
185
+ return (React.createElement("div", null,
186
+ React.createElement("div", { className: "jp-SettingsHeader", onClick: () => {
187
+ this.props.onCollapseChange(!this.props.isCollapsed);
188
+ this.props.onSelect(this.props.settings.id);
189
+ } },
190
+ React.createElement("header", { className: "jp-SettingsTitle" },
191
+ React.createElement(icon.react, { tag: "span", elementPosition: "center", className: "jp-SettingsTitle-caret" }),
192
+ React.createElement("h2", null, this.props.settings.schema.title),
193
+ React.createElement("div", { className: "jp-SettingsHeader-description" }, this.props.settings.schema.description)),
194
+ this.state.isModified && (React.createElement("button", { className: "jp-RestoreButton", onClick: this.reset }, trans.__('Restore to Defaults')))),
195
+ !this.props.isCollapsed && (React.createElement(Form, { schema: this.props.settings.schema, formData: this.state.formData, FieldTemplate: CustomTemplate, ArrayFieldTemplate: CustomArrayTemplateFactory(this.props.translator), ObjectFieldTemplate: CustomObjectTemplateFactory(this.props.translator), uiSchema: uiSchema, fields: this.props.renderers, formContext: { settings: this.props.settings }, liveValidate: true, idPrefix: `jp-SettingsEditor-${this.props.settings.id}`, onChange: (e) => {
196
+ this.props.hasError(e.errors.length !== 0);
197
+ this.setState({ formData: e.formData });
198
+ if (e.errors.length === 0) {
199
+ this.props.updateDirtyState(true);
200
+ void this._debouncer.invoke();
201
+ }
202
+ this.props.onSelect(this.props.settings.id);
203
+ } }))));
204
+ }
205
+ }
206
+ //# sourceMappingURL=SettingsFormEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SettingsFormEditor.js","sourceR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AC9C,IAAI,CAAC,KAAK,CAAC,UAAU,CACtB,EACD,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC5B,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,EAC9C,YAAY,QACZ,QAAQ,EAAE,qBAAqB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,EAAE,EACvD,QAAQ,EAAE,CAAC,CAA0C,EAAE,EAAE;oBACvD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;oBAC3C,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;oBACxC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;wBACzB,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;wBAClC,KAAK,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;qBAC/B;oBACD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;gBAC9C,CAAC,GACD,CACH,CACG,CACP,CAAC;IACJ,CAAC;CASF"}
package/lib/index.d.ts CHANGED
@@ -2,5 +2,6 @@
2
2
  * @packageDocumentation
3
3
  * @module settingeditor
4
4
  */
5
- export * from './settingeditor';
5
+ export * from './settingseditor';
6
+ export * from './jsonsettingeditor';
6
7
  export * from './tokens';
package/lib/index.js CHANGED
@@ -4,6 +4,7 @@
4
4
  * @packageDocumentation
5
5
  * @module settingeditor
6
6
  */
7
- export * from './settingeditor';
7
+ export * from './settingseditor';
8
+ export * from './jsonsettingeditor';
8
9
  export * from './tokens';
9
10
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAC3D;;;GAGG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAC3D;;;GAGG;AAEH,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC"}
package/lib/inspector.js CHANGED
@@ -42,9 +42,8 @@ class InspectorConnector extends DataConnector {
42
42
  constructor(editor, translator) {
43
43
  super();
44
44
  this._current = 0;
45
- this.translator = translator || nullTranslator;
46
45
  this._editor = editor;
47
- this._trans = this.translator.load('jupyterlab');
46
+ this._trans = (translator !== null && translator !== void 0 ? translator : nullTranslator).load('jupyterlab');
48
47
  }
49
48
  /**
50
49
  * Fetch inspection requests.
@@ -63,50 +62,45 @@ class InspectorConnector extends DataConnector {
63
62
  metadata: {}
64
63
  });
65
64
  }
66
- resolve({ data: Private.render(errors), metadata: {} });
65
+ resolve({ data: this.render(errors), metadata: {} });
67
66
  }, 100));
68
67
  });
69
68
  }
70
- _validate(raw) {
71
- const editor = this._editor;
72
- if (!editor.settings) {
73
- return null;
74
- }
75
- const { id, schema, version } = editor.settings;
76
- const data = { composite: {}, user: {} };
77
- const validator = editor.registry.validator;
78
- return validator.validateData({ data, id, raw, schema, version }, false);
79
- }
80
- }
81
- /**
82
- * A namespace for private module data.
83
- */
84
- var Private;
85
- (function (Private) {
86
69
  /**
87
70
  * Render validation errors as an HTML string.
88
71
  */
89
- function render(errors) {
90
- return { 'text/markdown': errors.map(renderError).join('') };
72
+ render(errors) {
73
+ return {
74
+ 'text/markdown': errors.map(this.renderError.bind(this)).join('')
75
+ };
91
76
  }
92
- Private.render = render;
93
77
  /**
94
78
  * Render an individual validation error as a markdown string.
95
79
  */
96
- function renderError(error) {
80
+ renderError(error) {
97
81
  var _a;
98
82
  switch (error.keyword) {
99
83
  case 'additionalProperties':
100
- return `**\`[additional property error]\`**
101
- \`${(_a = error.params) === null || _a === void 0 ? void 0 : _a.additionalProperty}\` is not a valid property`;
84
+ return `**\`[${this._trans.__('additional property error')}]\`**
85
+ ${this._trans.__('`%1` is not a valid property', (_a = error.params) === null || _a === void 0 ? void 0 : _a.additionalProperty)}`;
102
86
  case 'syntax':
103
- return `**\`[syntax error]\`** *${error.message}*`;
87
+ return `**\`[${this._trans.__('syntax error')}]\`** *${error.message}*`;
104
88
  case 'type':
105
- return `**\`[type error]\`**
89
+ return `**\`[${this._trans.__('type error')}]\`**
106
90
  \`${error.dataPath}\` ${error.message}`;
107
91
  default:
108
- return `**\`[error]\`** *${error.message}*`;
92
+ return `**\`[${this._trans.__('error')}]\`** *${error.message}*`;
93
+ }
94
+ }
95
+ _validate(raw) {
96
+ const editor = this._editor;
97
+ if (!editor.settings) {
98
+ return null;
109
99
  }
100
+ const { id, schema, version } = editor.settings;
101
+ const data = { composite: {}, user: {} };
102
+ const validator = editor.registry.validator;
103
+ return validator.validateData({ data, id, raw, schema, version }, false);
110
104
  }
111
- })(Private || (Private = {}));
105
+ }
112
106
  //# sourceMappingURL=inspector.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"inspector.js","sourceRoot":"","sources":["../src/inspector.ts"],"names":[],"mappings":"AAAA;;;+EAG+E;AAE/E,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAEL,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAEL,cAAc,EAEf,MAAM,yBAAyB,CAAC;AAIjC;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAiB,EACjB,UAAgC,EAChC,UAAwB;IAExB,UAAU,GAAG,UAAU,IAA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AM,CAAC,QAAQ,EAAE;YACpB,OAAO,IAAI,CAAC;SACb;QACD,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChD,MAAM,IAAI,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QACzC,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;QAE5C,OAAO,SAAS,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;IAC3E,CAAC;CAKF"}
@@ -7,15 +7,15 @@ import { CommandRegistry } from '@lumino/commands';
7
7
  import { JSONObject } from '@lumino/coreutils';
8
8
  import { Message } from '@lumino/messaging';
9
9
  import { ISignal } from '@lumino/signaling';
10
- import { Widget } from '@lumino/widgets';
10
+ import { SplitPanel } from './splitpanel';
11
11
  /**
12
12
  * An interface for modifying and saving application settings.
13
13
  */
14
- export declare class SettingEditor extends Widget {
14
+ export declare class JsonSettingEditor extends SplitPanel {
15
15
  /**
16
16
  * Create a new setting editor.
17
17
  */
18
- constructor(options: SettingEditor.IOptions);
18
+ constructor(options: JsonSettingEditor.IOptions);
19
19
  /**
20
20
  * The state database key for the editor's state management.
21
21
  */
@@ -93,15 +93,14 @@ export declare class SettingEditor extends Widget {
93
93
  private _fetching;
94
94
  private _instructions;
95
95
  private _list;
96
- private _panel;
97
96
  private _saving;
98
97
  private _state;
99
98
  private _when;
100
99
  }
101
100
  /**
102
- * A namespace for `SettingEditor` statics.
101
+ * A namespace for `JsonSettingEditor` statics.
103
102
  */
104
- export declare namespace SettingEditor {
103
+ export declare namespace JsonSettingEditor {
105
104
  /**
106
105
  * The instantiation options for a setting editor.
107
106
  */
@@ -3,11 +3,9 @@
3
3
  | Distributed under the terms of the Modified BSD License.
4
4
  |----------------------------------------------------------------------------*/
5
5
  import { nullTranslator } from '@jupyterlab/translation';
6
- import { jupyterIcon } from '@jupyterlab/ui-components';
6
+ import { jupyterIcon, ReactWidget } from '@jupyterlab/ui-components';
7
7
  import { JSONExt } from '@lumino/coreutils';
8
- import { PanelLayout, Widget } from '@lumino/widgets';
9
8
  import * as React from 'react';
10
- import * as ReactDOM from 'react-dom';
11
9
  import { PluginEditor } from './plugineditor';
12
10
  import { PluginList } from './pluginlist';
13
11
  import { SplitPanel } from './splitpanel';
@@ -25,28 +23,32 @@ const DEFAULT_LAYOUT = {
25
23
  /**
26
24
  * An interface for modifying and saving application settings.
27
25
  */
28
- export class SettingEditor extends Widget {
26
+ export class JsonSettingEditor extends SplitPanel {
29
27
  /**
30
28
  * Create a new setting editor.
31
29
  */
32
30
  constructor(options) {
33
- super();
31
+ super({
32
+ orientation: 'horizontal',
33
+ renderer: SplitPanel.defaultRenderer,
34
+ spacing: 1
35
+ });
34
36
  this._fetching = null;
35
37
  this._saving = false;
36
38
  this._state = JSONExt.deepCopy(DEFAULT_LAYOUT);
37
39
  this.translator = options.translator || nullTranslator;
40
+ const trans = this.translator.load('jupyterlab');
38
41
  this.addClass('jp-SettingEditor');
39
42
  this.key = options.key;
40
43
  this.state = options.state;
41
44
  const { commands, editorFactory, rendermime } = options;
42
- const layout = (this.layout = new PanelLayout());
43
45
  const registry = (this.registry = options.registry);
44
- const panel = (this._panel = new SplitPanel({
45
- orientation: 'horizontal',
46
- renderer: SplitPanel.defaultRenderer,
47
- spacing: 1
48
- }));
49
- const instructions = (this._instructions = new Widget());
46
+ const instructions = (this._instructions = ReactWidget.create(React.createElement(React.Fragment, null,
47
+ React.createElement("h2", null,
48
+ React.createElement(jupyterIcon.react, { className: "jp-SettingEditorInstructions-icon", tag: "span", elementPosition: "center", height: "auto", width: "60px" }),
49
+ React.createElement("span", { className: "jp-SettingEditorInstructions-title" }, trans.__('Settings'))),
50
+ React.createElement("span", { className: "jp-SettingEditorInstructions-text" }, trans.__('Select a plugin from the list to view and edit its preferences.')))));
51
+ instructions.addClass('jp-SettingEditorInstructions');
50
52
  const editor = (this._editor = new PluginEditor({
51
53
  commands,
52
54
  editorFactory,
@@ -61,21 +63,17 @@ export class SettingEditor extends Widget {
61
63
  translator: this.translator
62
64
  }));
63
65
  const when = options.when;
64
- instructions.addClass('jp-SettingEditorInstructions');
65
- Private.populateInstructionsNode(instructions.node, this.translator);
66
66
  if (when) {
67
67
  this._when = Array.isArray(when) ? Promise.all(when) : when;
68
68
  }
69
- panel.addClass('jp-SettingEditor-main');
70
- layout.addWidget(panel);
71
- panel.addWidget(list);
72
- panel.addWidget(instructions);
69
+ this.addWidget(list);
70
+ this.addWidget(instructions);
73
71
  SplitPanel.setStretch(list, 0);
74
72
  SplitPanel.setStretch(instructions, 1);
75
73
  SplitPanel.setStretch(editor, 1);
76
74
  editor.stateChanged.connect(this._onStateChanged, this);
77
75
  list.changed.connect(this._onStateChanged, this);
78
- panel.handleMoved.connect(this._onStateChanged, this);
76
+ this.handleMoved.connect(this._onStateChanged, this);
79
77
  }
80
78
  /**
81
79
  * Whether the raw editor revert functionality is enabled.
@@ -118,7 +116,6 @@ export class SettingEditor extends Widget {
118
116
  this._editor.dispose();
119
117
  this._instructions.dispose();
120
118
  this._list.dispose();
121
- this._panel.dispose();
122
119
  }
123
120
  /**
124
121
  * Revert raw editor back to original settings.
@@ -137,15 +134,15 @@ export class SettingEditor extends Widget {
137
134
  */
138
135
  onAfterAttach(msg) {
139
136
  super.onAfterAttach(msg);
140
- this._panel.hide();
137
+ this.hide();
141
138
  this._fetchState()
142
139
  .then(() => {
143
- this._panel.show();
140
+ this.show();
144
141
  this._setState();
145
142
  })
146
143
  .catch(reason => {
147
144
  console.error('Fetching setting editor state failed', reason);
148
- this._panel.show();
145
+ this.show();
149
146
  this._setState();
150
147
  });
151
148
  }
@@ -184,7 +181,7 @@ export class SettingEditor extends Widget {
184
181
  * Handle root level layout state changes.
185
182
  */
186
183
  async _onStateChanged() {
187
- this._state.sizes = this._panel.relativeSizes();
184
+ this._state.sizes = this.relativeSizes();
188
185
  this._state.container = this._editor.state;
189
186
  this._state.container.plugin = this._list.selection;
190
187
  try {
@@ -216,13 +213,12 @@ export class SettingEditor extends Widget {
216
213
  */
217
214
  _setLayout() {
218
215
  const editor = this._editor;
219
- const panel = this._panel;
220
216
  const state = this._state;
221
217
  editor.state = state.container;
222
218
  // Allow the message queue (which includes fit requests that might disrupt
223
219
  // setting relative sizes) to clear before setting sizes.
224
220
  requestAnimationFrame(() => {
225
- panel.setRelativeSizes(state.sizes);
221
+ this.setRelativeSizes(state.sizes);
226
222
  });
227
223
  }
228
224
  /**
@@ -231,7 +227,6 @@ export class SettingEditor extends Widget {
231
227
  _setState() {
232
228
  const editor = this._editor;
233
229
  const list = this._list;
234
- const panel = this._panel;
235
230
  const { container } = this._state;
236
231
  if (!container.plugin) {
237
232
  editor.settings = null;
@@ -251,7 +246,7 @@ export class SettingEditor extends Widget {
251
246
  instructions.parent = null;
252
247
  }
253
248
  if (!editor.isAttached) {
254
- panel.addWidget(editor);
249
+ this.addWidget(editor);
255
250
  }
256
251
  editor.settings = settings;
257
252
  list.selection = container.plugin;
@@ -270,19 +265,6 @@ export class SettingEditor extends Widget {
270
265
  */
271
266
  var Private;
272
267
  (function (Private) {
273
- /**
274
- * Populate the instructions text node.
275
- */
276
- function populateInstructionsNode(node, translator) {
277
- translator = translator || nullTranslator;
278
- const trans = translator.load('jupyterlab');
279
- ReactDOM.render(React.createElement(React.Fragment, null,
280
- React.createElement("h2", null,
281
- React.createElement(jupyterIcon.react, { className: "jp-SettingEditorInstructions-icon", tag: "span", elementPosition: "center", height: "auto", width: "60px" }),
282
- React.createElement("span", { className: "jp-SettingEditorInstructions-title" }, "Settings")),
283
- React.createElement("span", { className: "jp-SettingEditorInstructions-text" }, trans.__('Select a plugin from the list to view and edit its preferences.'))), node);
284
- }
285
- Private.populateInstructionsNode = populateInstructionsNode;
286
268
  /**
287
269
  * Return a normalized restored layout state that defaults to the presets.
288
270
  */
@@ -320,4 +302,4 @@ var Private;
320
302
  return Array.isArray(value) && value.every(x => typeof x === 'number');
321
303
  }
322
304
  })(Private || (Private = {}));
323
- //# sourceMappingURL=settingeditor.js.map
305
+ //# sourceMappingURL=jsonsettingeditor.js.map