@jupyterlab/metadataform 4.0.0-alpha.18 → 4.0.0-alpha.20

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/lib/form.js CHANGED
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import { ReactWidget } from '@jupyterlab/apputils';
8
8
  import { FormComponent } from '@jupyterlab/ui-components';
9
+ import validatorAjv8 from '@rjsf/validator-ajv8';
9
10
  import React from 'react';
10
11
  /**
11
12
  * A ReactWidget with the form itself.
@@ -28,8 +29,8 @@ export class FormWidget extends ReactWidget {
28
29
  defaultFormData: this._props.settings.default(),
29
30
  updateMetadata: this._props.metadataFormWidget.updateMetadata
30
31
  };
31
- return (React.createElement(FormComponent, { schema: this._props.properties, formData: this._props.formData, formContext: formContext, uiSchema: this._props.uiSchema, liveValidate: true, idPrefix: `jp-MetadataForm-${this._props.pluginId}`, onChange: (e) => {
32
- this._props.metadataFormWidget.updateMetadata(e.formData);
32
+ return (React.createElement(FormComponent, { validator: validatorAjv8, schema: this._props.properties, formData: this._props.formData, formContext: formContext, uiSchema: this._props.uiSchema, liveValidate: true, idPrefix: `jp-MetadataForm-${this._props.pluginId}`, onChange: (e) => {
33
+ this._props.metadataFormWidget.updateMetadata(e.formData || {});
33
34
  }, compact: true, showModifiedFromDefault: this._props.showModified, translator: this._props.translator }));
34
35
  }
35
36
  }
package/lib/form.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"form.js","sourceRoot":"","sources":["../src/form.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAC3D;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAI1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,WAAW;IACzC;;OAEG;IACH,YAAY,KAA0B;QACpC,KA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AW;IACzC;;OAEG;IACH,YAAY,KAA0B;QACpC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,MAAM;QACJ,MAAM,WAAW,GAAG;YAClB,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE;YAC/C,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,cAAc;SAC9D,CAAC;QACF,OAAO,CACL,oBAAC,aAAa,IACZ,SAAS,EAAE,aAAa,EACxB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,UAAyB,EAC7C,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAA+B,EACrD,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAC9B,YAAY,QACZ,QAAQ,EAAE,mBAAmB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EACnD,QAAQ,EAAE,CAAC,CAA0C,EAAE,EAAE;gBACvD,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;YAClE,CAAC,EACD,OAAO,EAAE,IAAI,EACb,uBAAuB,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY,EACjD,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,GAClC,CACH,CAAC;IACJ,CAAC;CAGF"}
@@ -309,7 +309,7 @@ export class MetadataFormWidget extends NotebookTools.Tool {
309
309
  return;
310
310
  const formProperties = JSONExt.deepCopy(this._metadataSchema);
311
311
  const formData = {};
312
- for (let metadataKey of Object.keys(this._metadataSchema.properties)) {
312
+ for (let metadataKey of Object.keys(this._metadataSchema.properties || JSONExt.emptyObject)) {
313
313
  // Do not display the field if it's Notebook metadata and the notebook model is null.
314
314
  if (((_a = this._metaInformation[metadataKey]) === null || _a === void 0 ? void 0 : _a.level) === 'notebook' &&
315
315
  this._notebookModelNull) {
@@ -1 +1 @@
1
- {"version":3,"file":"metadataform.js","sourceRoot":"","sources":["../src/metadataform.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAC3D;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAEL,cAAc,EAEf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,OAAO,EAOR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAG1D,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;GAEG;AACH,MAAM,OAAO,kBACX,SAAQ,aAAa,CAAC,IAAI;IAG1B;;OAEG;IACH,YAAY,OAA8B;QACxC,KAAK,EAAE,CAAC;QA8FV;;;;;;;;;;;;WAYG;QACH,mBAAc,GAAG,CACf,QAAmC,EACnC,MAAgB,EACV,EAAE;;YACR,IAAI,IAAI,CAAC,aAAa,IAAI,SAAS;gBAAE,OAAO;YAE5C,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC;YAExD,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC;YAC3C,IAAI,IAAI,IAAI,IAAI;gBAAE,OAAO;YAEzB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;YAE9B,sDAAsD;YACtD,MAAM,kBAAkB,GAAoC,EAAE,CAAC;YAE/D,0DAA0D;YAC1D,MAAM,sBAAsB,GAAoC,EAAE,CAAC;YAEnE,KAAK,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;gBACzD,wDAAwD;gBACxD,IA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AU,EAAE,IAAI,CAAC,UAAU,IAAI,IAAI;YACnC,QAAQ,EAAE,QAAQ;YAClB,kBAAkB,EAAE,IAAI;YACxB,YAAY,EAAE,IAAI,CAAC,aAAa;YAChC,QAAQ,EAAE,IAAI,CAAC,SAAS;SACzB,CAAC,CAAC;IACL,CAAC;CAaF;AAED,IAAU,OAAO,CAgChB;AAhCD,WAAU,OAAO;IAQf;;;;;;;OAOG;IACH,SAAgB,iBAAiB,CAC/B,cAAiC,EACjC,gBAA+B;QAE/B,IAAI,WAAW,GAAG,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC3C,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,IAAI,cAAc,EAAE;YAC9D,IAAI,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAsB,CAAC,CAAC,MAAM;gBACtE,cAAc,CAAC,WAAW,CAAC,GAAG,iBAAiB,CAC7C,cAAc,CAAC,WAAW,CAAsB,EAChD,gBAAgB,CACjB,CAAC;YACJ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAsB,CAAC,CAAC,MAAM;gBACvE,OAAO,cAAc,CAAC,WAAW,CAAC,CAAC;SACtC;QACD,OAAO,cAAc,CAAC;IACxB,CAAC;IAfe,yBAAiB,oBAehC,CAAA;AACH,CAAC,EAhCS,OAAO,KAAP,OAAO,QAgChB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyterlab/metadataform",
3
- "version": "4.0.0-alpha.18",
3
+ "version": "4.0.0-alpha.20",
4
4
  "description": "A helper to build form for metadata",
5
5
  "keywords": [
6
6
  "jupyter",
@@ -30,7 +30,8 @@
30
30
  "lib/*.js.map",
31
31
  "lib/*.js",
32
32
  "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}",
33
- "style/index.js"
33
+ "style/index.js",
34
+ "src/**/*.{ts,tsx}"
34
35
  ],
35
36
  "scripts": {
36
37
  "build": "tsc -b",
@@ -44,26 +45,27 @@
44
45
  "watch": "tsc -w --listEmittedFiles"
45
46
  },
46
47
  "dependencies": {
47
- "@jupyterlab/apputils": "^4.0.0-alpha.18",
48
- "@jupyterlab/nbformat": "^4.0.0-alpha.18",
49
- "@jupyterlab/notebook": "^4.0.0-alpha.18",
50
- "@jupyterlab/settingregistry": "^4.0.0-alpha.18",
51
- "@jupyterlab/translation": "^4.0.0-alpha.18",
52
- "@jupyterlab/ui-components": "^4.0.0-alpha.33",
53
- "@lumino/coreutils": "^2.0.0-alpha.6",
54
- "@lumino/messaging": "^2.0.0-alpha.6",
55
- "@lumino/widgets": "^2.0.0-alpha.6",
56
- "@rjsf/core": "^4.2.0",
48
+ "@jupyterlab/apputils": "^4.0.0-alpha.20",
49
+ "@jupyterlab/nbformat": "^4.0.0-alpha.20",
50
+ "@jupyterlab/notebook": "^4.0.0-alpha.20",
51
+ "@jupyterlab/settingregistry": "^4.0.0-alpha.20",
52
+ "@jupyterlab/translation": "^4.0.0-alpha.20",
53
+ "@jupyterlab/ui-components": "^4.0.0-alpha.35",
54
+ "@lumino/coreutils": "^2.0.0-rc.0",
55
+ "@lumino/messaging": "^2.0.0-rc.0",
56
+ "@lumino/widgets": "^2.0.0-rc.0",
57
+ "@rjsf/core": "^5.1.0",
58
+ "@rjsf/validator-ajv8": "^5.1.0",
57
59
  "json-schema": "^0.4.0",
58
60
  "react": "^18.2.0"
59
61
  },
60
62
  "devDependencies": {
61
- "@jupyterlab/testing": "^4.0.0-alpha.18",
63
+ "@jupyterlab/testing": "^4.0.0-alpha.20",
62
64
  "@types/jest": "^29.2.0",
63
65
  "@types/react": "^18.0.26",
64
66
  "rimraf": "~3.0.0",
65
- "typedoc": "~0.22.10",
66
- "typescript": "~4.7.3"
67
+ "typedoc": "~0.23.25",
68
+ "typescript": "~5.0.0-beta"
67
69
  },
68
70
  "publishConfig": {
69
71
  "access": "public"
package/src/form.tsx ADDED
@@ -0,0 +1,60 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ /**
4
+ * @packageDocumentation
5
+ * @module metadataform
6
+ */
7
+
8
+ import { ReactWidget } from '@jupyterlab/apputils';
9
+ import { FormComponent } from '@jupyterlab/ui-components';
10
+ import { ReadonlyPartialJSONObject } from '@lumino/coreutils';
11
+ import { IChangeEvent } from '@rjsf/core';
12
+ import validatorAjv8 from '@rjsf/validator-ajv8';
13
+ import { JSONSchema7 } from 'json-schema';
14
+ import React from 'react';
15
+
16
+ import { MetadataForm } from './token';
17
+
18
+ /**
19
+ * A ReactWidget with the form itself.
20
+ */
21
+ export class FormWidget extends ReactWidget {
22
+ /**
23
+ * Constructs a new FormWidget.
24
+ */
25
+ constructor(props: MetadataForm.IProps) {
26
+ super();
27
+ this.addClass('jp-FormWidget');
28
+ this._props = props;
29
+ }
30
+
31
+ /**
32
+ * Render the form.
33
+ * @returns - The rendered form
34
+ */
35
+ render(): JSX.Element {
36
+ const formContext = {
37
+ defaultFormData: this._props.settings.default(),
38
+ updateMetadata: this._props.metadataFormWidget.updateMetadata
39
+ };
40
+ return (
41
+ <FormComponent
42
+ validator={validatorAjv8}
43
+ schema={this._props.properties as JSONSchema7}
44
+ formData={this._props.formData as Record<string, any>}
45
+ formContext={formContext}
46
+ uiSchema={this._props.uiSchema}
47
+ liveValidate
48
+ idPrefix={`jp-MetadataForm-${this._props.pluginId}`}
49
+ onChange={(e: IChangeEvent<ReadonlyPartialJSONObject>) => {
50
+ this._props.metadataFormWidget.updateMetadata(e.formData || {});
51
+ }}
52
+ compact={true}
53
+ showModifiedFromDefault={this._props.showModified}
54
+ translator={this._props.translator}
55
+ />
56
+ );
57
+ }
58
+
59
+ private _props: MetadataForm.IProps;
60
+ }
package/src/index.ts ADDED
@@ -0,0 +1,11 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ /**
4
+ * @packageDocumentation
5
+ * @module metadataform
6
+ */
7
+
8
+ export * from './form';
9
+ export * from './metadataform';
10
+ export * from './metadataformProvider';
11
+ export * from './token';
@@ -0,0 +1,489 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ /**
4
+ * @packageDocumentation
5
+ * @module metadataform
6
+ */
7
+
8
+ import { NotebookTools } from '@jupyterlab/notebook';
9
+ import { BaseSettings } from '@jupyterlab/settingregistry';
10
+ import {
11
+ ITranslator,
12
+ nullTranslator,
13
+ TranslationBundle
14
+ } from '@jupyterlab/translation';
15
+ import {
16
+ JSONExt,
17
+ JSONObject,
18
+ JSONValue,
19
+ PartialJSONObject,
20
+ PartialJSONValue,
21
+ ReadonlyPartialJSONObject,
22
+ ReadonlyPartialJSONValue
23
+ } from '@lumino/coreutils';
24
+ import { Message } from '@lumino/messaging';
25
+ import { SingletonLayout, Widget } from '@lumino/widgets';
26
+
27
+ import { MetadataForm } from './token';
28
+ import { FormWidget } from './form';
29
+
30
+ /**
31
+ * A class that create a metadata form widget
32
+ */
33
+ export class MetadataFormWidget
34
+ extends NotebookTools.Tool
35
+ implements MetadataForm.IMetadataForm
36
+ {
37
+ /**
38
+ * Construct an empty widget.
39
+ */
40
+ constructor(options: MetadataForm.IOptions) {
41
+ super();
42
+ this._metadataSchema = options.metadataSchema;
43
+ this._metaInformation = options.metaInformation;
44
+ this._uiSchema = options.uiSchema || {};
45
+ this._pluginId = options.pluginId;
46
+ this._showModified = options.showModified || false;
47
+ this.translator = options.translator || nullTranslator;
48
+ this._trans = this.translator.load('jupyterlab');
49
+ this._updatingMetadata = false;
50
+ const layout = (this.layout = new SingletonLayout());
51
+
52
+ const node = document.createElement('div');
53
+ const content = document.createElement('div');
54
+ content.textContent = this._trans.__('No metadata.');
55
+ content.className = 'jp-MetadataForm-placeholderContent';
56
+ node.appendChild(content);
57
+ this._placeholder = new Widget({ node });
58
+ this._placeholder.addClass('jp-MetadataForm-placeholder');
59
+ layout.widget = this._placeholder;
60
+ }
61
+
62
+ /**
63
+ * Get the form object itself.
64
+ */
65
+ get form(): FormWidget | undefined {
66
+ return this._form;
67
+ }
68
+
69
+ /**
70
+ * Get the list of existing metadataKey (array of string).
71
+ *
72
+ * ## NOTE:
73
+ * The list contains also the conditional fields, which are not necessary
74
+ * displayed and filled.
75
+ */
76
+ get metadataKeys(): string[] {
77
+ const metadataKeys: string[] = [];
78
+
79
+ // MetadataKey from schema.
80
+ for (let metadataKey of Object.keys(this._metadataSchema.properties)) {
81
+ metadataKeys.push(metadataKey);
82
+ }
83
+
84
+ // Possible additional metadataKeys from conditional schema.
85
+ this._metadataSchema.allOf?.forEach(conditional => {
86
+ if (conditional.then !== undefined) {
87
+ if ((conditional.then as PartialJSONObject).properties !== undefined) {
88
+ let properties = (conditional.then as PartialJSONObject)
89
+ .properties as PartialJSONObject;
90
+ for (let metadataKey of Object.keys(properties)) {
91
+ if (!metadataKeys.includes(metadataKey))
92
+ metadataKeys.push(metadataKey);
93
+ }
94
+ }
95
+ }
96
+
97
+ if (conditional.else !== undefined) {
98
+ if ((conditional.else as PartialJSONObject).properties !== undefined) {
99
+ let properties = (conditional.else as PartialJSONObject)
100
+ .properties as PartialJSONObject;
101
+ for (let metadataKey of Object.keys(properties)) {
102
+ if (!metadataKeys.includes(metadataKey))
103
+ metadataKeys.push(metadataKey);
104
+ }
105
+ }
106
+ }
107
+ });
108
+
109
+ return metadataKeys;
110
+ }
111
+
112
+ /**
113
+ * Get the properties of a MetadataKey.
114
+ *
115
+ * @param metadataKey - metadataKey (string).
116
+ */
117
+ getProperties(metadataKey: string): PartialJSONObject | null {
118
+ return (
119
+ JSONExt.deepCopy(this._metadataSchema.properties[metadataKey]) || null
120
+ );
121
+ }
122
+
123
+ /**
124
+ * Set properties to a metadataKey.
125
+ *
126
+ * @param metadataKey - metadataKey (string).
127
+ * @param properties - the properties to add or modify.
128
+ */
129
+ setProperties(metadataKey: string, properties: PartialJSONObject): void {
130
+ Object.entries(properties).forEach(([key, value]) => {
131
+ this._metadataSchema.properties[metadataKey][key] = value;
132
+ });
133
+ }
134
+
135
+ /**
136
+ * Update the metadata of the current cell or notebook.
137
+ *
138
+ * @param formData - the cell metadata set in the form.
139
+ * @param reload - whether to update the form after updating the metadata.
140
+ *
141
+ * ## Notes
142
+ * Metadata are updated from root only. If some metadata is nested,
143
+ * the whole root object must be updated.
144
+ * This function build an object with all the root object to update
145
+ * in metadata before performing update.
146
+ * It uses an arrow function to allow using 'this' properly when called from a custom field.
147
+ */
148
+ updateMetadata = (
149
+ formData: ReadonlyPartialJSONObject,
150
+ reload?: boolean
151
+ ): void => {
152
+ if (this.notebookTools == undefined) return;
153
+
154
+ const notebook = this.notebookTools.activeNotebookPanel;
155
+
156
+ const cell = this.notebookTools.activeCell;
157
+ if (cell == null) return;
158
+
159
+ this._updatingMetadata = true;
160
+
161
+ // An object representing the cell metadata to modify.
162
+ const cellMetadataObject: Private.IMetadataRepresentation = {};
163
+
164
+ // An object representing the notebook metadata to modify.
165
+ const notebookMetadataObject: Private.IMetadataRepresentation = {};
166
+
167
+ for (let [metadataKey, value] of Object.entries(formData)) {
168
+ // Continue if the metadataKey does not exist in schema.
169
+ if (!this.metadataKeys.includes(metadataKey)) continue;
170
+
171
+ // Continue if the metadataKey is a notebook level one and there is no NotebookModel.
172
+ if (
173
+ this._metaInformation[metadataKey]?.level === 'notebook' &&
174
+ this._notebookModelNull
175
+ )
176
+ continue;
177
+
178
+ // Continue if the metadataKey is not applicable to the cell type.
179
+ if (
180
+ this._metaInformation[metadataKey]?.cellTypes &&
181
+ !this._metaInformation[metadataKey]?.cellTypes?.includes(
182
+ cell.model.type
183
+ )
184
+ ) {
185
+ continue;
186
+ }
187
+ let currentMetadata: PartialJSONObject;
188
+ let metadataObject: Private.IMetadataRepresentation;
189
+
190
+ // Linking the working variable to the corresponding metadata and representation.
191
+ if (this._metaInformation[metadataKey]?.level === 'notebook') {
192
+ // Working on notebook metadata.
193
+ currentMetadata = notebook!.model!.metadata;
194
+ metadataObject = notebookMetadataObject;
195
+ } else {
196
+ // Working on cell metadata.
197
+ currentMetadata = cell.model.metadata;
198
+ metadataObject = cellMetadataObject;
199
+ }
200
+
201
+ // Remove first and last '/' if necessary and split the path.
202
+ let nestedKey = metadataKey
203
+ .replace(/^\/+/, '')
204
+ .replace(/\/+$/, '')
205
+ .split('/');
206
+
207
+ let baseMetadataKey = nestedKey[0];
208
+ if (baseMetadataKey == undefined) continue;
209
+
210
+ let writeFinalData =
211
+ value !== undefined &&
212
+ ((this._metaInformation[metadataKey]?.writeDefault ?? true) ||
213
+ value !== this._metaInformation[metadataKey]?.default);
214
+
215
+ // If metadata key is at root of metadata no need to go further.
216
+ if (nestedKey.length == 1) {
217
+ if (writeFinalData)
218
+ metadataObject[baseMetadataKey] = value as PartialJSONValue;
219
+ else metadataObject[baseMetadataKey] = undefined;
220
+ continue;
221
+ }
222
+
223
+ let intermediateMetadataKeys = nestedKey.slice(1, -1);
224
+ let finalMetadataKey = nestedKey[nestedKey.length - 1];
225
+
226
+ // Deep copy of the metadata if not already done.
227
+ if (!(baseMetadataKey in metadataObject)) {
228
+ metadataObject[baseMetadataKey] = currentMetadata[baseMetadataKey];
229
+ }
230
+ if (metadataObject[baseMetadataKey] === undefined)
231
+ metadataObject[baseMetadataKey] = {};
232
+
233
+ // Let's have an object which points to the nested key.
234
+ let workingObject: PartialJSONObject = metadataObject[
235
+ baseMetadataKey
236
+ ] as PartialJSONObject;
237
+
238
+ let finalObjectReached = true;
239
+
240
+ for (let nested of intermediateMetadataKeys) {
241
+ // If one of the nested object does not exist, this object is created
242
+ // only if there is a final data to write.
243
+ if (!(nested in workingObject)) {
244
+ if (!writeFinalData) {
245
+ finalObjectReached = false;
246
+ break;
247
+ } else workingObject[nested] = {};
248
+ }
249
+ workingObject = workingObject[nested] as PartialJSONObject;
250
+ }
251
+
252
+ // Write the value to the nested key or remove all empty object before the nested key,
253
+ // only if the final object has been reached.
254
+ if (finalObjectReached) {
255
+ if (!writeFinalData) delete workingObject[finalMetadataKey];
256
+ else workingObject[finalMetadataKey] = value as PartialJSONValue;
257
+ }
258
+
259
+ // If the final nested data has been deleted, let see if there is not remaining
260
+ // empty objects to remove.
261
+ if (!writeFinalData) {
262
+ metadataObject[baseMetadataKey] = Private.deleteEmptyNested(
263
+ metadataObject[baseMetadataKey] as PartialJSONObject,
264
+ nestedKey.slice(1)
265
+ );
266
+ if (
267
+ !Object.keys(metadataObject[baseMetadataKey] as PartialJSONObject)
268
+ .length
269
+ )
270
+ metadataObject[baseMetadataKey] = undefined;
271
+ }
272
+ }
273
+
274
+ // Set the cell metadata or delete it if value is undefined or empty object.
275
+ for (let [key, value] of Object.entries(cellMetadataObject)) {
276
+ if (value === undefined) cell.model.deleteMetadata(key);
277
+ else cell.model.setMetadata(key, value as ReadonlyPartialJSONValue);
278
+ }
279
+
280
+ // Set the notebook metadata or delete it if value is undefined or empty object.
281
+ if (!this._notebookModelNull) {
282
+ for (let [key, value] of Object.entries(notebookMetadataObject)) {
283
+ if (value === undefined) notebook!.model!.deleteMetadata(key);
284
+ else
285
+ notebook!.model!.setMetadata(key, value as ReadonlyPartialJSONValue);
286
+ }
287
+ }
288
+
289
+ this._updatingMetadata = false;
290
+
291
+ if (reload) {
292
+ this._update();
293
+ }
294
+ };
295
+
296
+ /**
297
+ * Set the content of the widget.
298
+ */
299
+ protected setContent(content: Widget | null): void {
300
+ const layout = this.layout as SingletonLayout;
301
+ if (layout.widget) {
302
+ layout.widget.removeClass('jp-MetadataForm-content');
303
+ layout.removeWidget(layout.widget);
304
+ }
305
+ if (!content) {
306
+ content = this._placeholder;
307
+ }
308
+ content.addClass('jp-MetadataForm-content');
309
+ layout.widget = content;
310
+ }
311
+
312
+ /**
313
+ * Build widget.
314
+ */
315
+ protected buildWidget(props: MetadataForm.IProps): void {
316
+ this._form = new FormWidget(props);
317
+ this._form.addClass('jp-MetadataForm');
318
+ this.setContent(this._form);
319
+ }
320
+
321
+ /**
322
+ * Update the form when the widget is displayed.
323
+ */
324
+ protected onAfterShow(msg: Message): void {
325
+ this._update();
326
+ }
327
+
328
+ /**
329
+ * Handle a change to the active cell.
330
+ */
331
+ protected onActiveCellChanged(msg: Message): void {
332
+ if (this.isVisible) this._update();
333
+ }
334
+
335
+ /**
336
+ * Handle a change to the active cell metadata.
337
+ */
338
+ protected onActiveCellMetadataChanged(msg: Message): void {
339
+ if (!this._updatingMetadata && this.isVisible) this._update();
340
+ }
341
+
342
+ protected onActiveNotebookPanelChanged(msg: Message): void {
343
+ // Do not use notebook metadata if model is null.
344
+ let notebook = this.notebookTools.activeNotebookPanel;
345
+ if (notebook === null || notebook.model === null) {
346
+ console.warn('Notebook model is null, its metadata cannot be updated.');
347
+ this._notebookModelNull = true;
348
+ } else {
349
+ this._notebookModelNull = false;
350
+ }
351
+ if (!this._updatingMetadata && this.isVisible) this._update();
352
+ }
353
+
354
+ /**
355
+ * Handle a change to the active notebook metadata.
356
+ */
357
+ protected onActiveNotebookPanelMetadataChanged(msg: Message): void {
358
+ if (!this._updatingMetadata && this.isVisible) this._update();
359
+ }
360
+
361
+ /**
362
+ * Update the form with current cell metadata, and remove inconsistent fields.
363
+ */
364
+ private _update(): void {
365
+ const notebook = this.notebookTools.activeNotebookPanel;
366
+
367
+ const cell = this.notebookTools.activeCell;
368
+ if (cell == undefined) return;
369
+
370
+ const formProperties: MetadataForm.IMetadataSchema = JSONExt.deepCopy(
371
+ this._metadataSchema
372
+ );
373
+
374
+ const formData = {} as JSONObject;
375
+
376
+ for (let metadataKey of Object.keys(
377
+ this._metadataSchema.properties || JSONExt.emptyObject
378
+ )) {
379
+ // Do not display the field if it's Notebook metadata and the notebook model is null.
380
+ if (
381
+ this._metaInformation[metadataKey]?.level === 'notebook' &&
382
+ this._notebookModelNull
383
+ ) {
384
+ delete formProperties.properties![metadataKey];
385
+ continue;
386
+ }
387
+
388
+ // Do not display the field if the active cell's type is not involved.
389
+ if (
390
+ this._metaInformation[metadataKey]?.cellTypes &&
391
+ !this._metaInformation[metadataKey]?.cellTypes?.includes(
392
+ cell.model.type
393
+ )
394
+ ) {
395
+ delete formProperties.properties![metadataKey];
396
+ continue;
397
+ }
398
+
399
+ let workingObject: PartialJSONObject;
400
+
401
+ // Remove the first and last '/' if exist, nad split the path.
402
+ let nestedKeys = metadataKey
403
+ .replace(/^\/+/, '')
404
+ .replace(/\/+$/, '')
405
+ .split('/');
406
+
407
+ // Associates the correct metadata object to the working object.
408
+ if (this._metaInformation[metadataKey]?.level === 'notebook') {
409
+ workingObject = notebook!.model!.metadata;
410
+ } else {
411
+ workingObject = cell.model.metadata;
412
+ }
413
+
414
+ let hasValue = true;
415
+
416
+ // Navigate to the value.
417
+ for (let nested of nestedKeys) {
418
+ if (nested in workingObject)
419
+ workingObject = workingObject[nested] as JSONObject;
420
+ else {
421
+ hasValue = false;
422
+ break;
423
+ }
424
+ }
425
+
426
+ // Fill the formData with the current metadata value.
427
+ if (hasValue) formData[metadataKey] = workingObject as JSONValue;
428
+ }
429
+
430
+ this.buildWidget({
431
+ properties: formProperties,
432
+ settings: new BaseSettings({
433
+ schema: this._metadataSchema as PartialJSONObject
434
+ }),
435
+ uiSchema: this._uiSchema,
436
+ translator: this.translator || null,
437
+ formData: formData,
438
+ metadataFormWidget: this,
439
+ showModified: this._showModified,
440
+ pluginId: this._pluginId
441
+ });
442
+ }
443
+
444
+ protected translator: ITranslator;
445
+ private _form: FormWidget | undefined;
446
+ private _metadataSchema: MetadataForm.IMetadataSchema;
447
+ private _metaInformation: MetadataForm.IMetaInformation;
448
+ private _uiSchema: MetadataForm.IUiSchema;
449
+ private _trans: TranslationBundle;
450
+ private _placeholder: Widget;
451
+ private _updatingMetadata: boolean;
452
+ private _pluginId: string | undefined;
453
+ private _showModified: boolean;
454
+ private _notebookModelNull: boolean = false;
455
+ }
456
+
457
+ namespace Private {
458
+ /**
459
+ * The metadata representation object.
460
+ */
461
+ export interface IMetadataRepresentation {
462
+ [metadata: string]: PartialJSONObject | PartialJSONValue | undefined;
463
+ }
464
+
465
+ /**
466
+ * Recursive function to clean the empty nested metadata before updating real metadata.
467
+ * this function is called when a nested metadata is undefined (or default), so maybe some
468
+ * object are now empty.
469
+ * @param metadataObject: PartialJSONObject representing the metadata to update.
470
+ * @param metadataKeysList: Array<string> of the undefined nested metadata.
471
+ * @returns PartialJSONObject without empty object.
472
+ */
473
+ export function deleteEmptyNested(
474
+ metadataObject: PartialJSONObject,
475
+ metadataKeysList: Array<string>
476
+ ): PartialJSONObject {
477
+ let metadataKey = metadataKeysList.shift();
478
+ if (metadataKey !== undefined && metadataKey in metadataObject) {
479
+ if (Object.keys(metadataObject[metadataKey] as PartialJSONObject).length)
480
+ metadataObject[metadataKey] = deleteEmptyNested(
481
+ metadataObject[metadataKey] as PartialJSONObject,
482
+ metadataKeysList
483
+ );
484
+ if (!Object.keys(metadataObject[metadataKey] as PartialJSONObject).length)
485
+ delete metadataObject[metadataKey];
486
+ }
487
+ return metadataObject;
488
+ }
489
+ }
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Copyright (c) Jupyter Development Team.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+
6
+ import { IMetadataFormProvider, MetadataForm } from './token';
7
+
8
+ export class MetadataFormProvider implements IMetadataFormProvider {
9
+ add(id: string, widget: MetadataForm.IMetadataForm) {
10
+ if (!this._items[id]) {
11
+ this._items[id] = widget;
12
+ } else {
13
+ console.warn(`A MetadataformWidget is already registered with id ${id}`);
14
+ }
15
+ }
16
+
17
+ get(id: string): MetadataForm.IMetadataForm | undefined {
18
+ if (!this._items[id]) {
19
+ return this._items[id];
20
+ } else {
21
+ console.warn(`There is no MetadataformWidget registered with id ${id}`);
22
+ }
23
+ }
24
+
25
+ _items: { [id: string]: MetadataForm.IMetadataForm } = {};
26
+ }
package/src/token.ts ADDED
@@ -0,0 +1,220 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ /**
4
+ * @packageDocumentation
5
+ * @module metadataform
6
+ */
7
+
8
+ import { CellType } from '@jupyterlab/nbformat';
9
+ import { NotebookTools } from '@jupyterlab/notebook';
10
+ import { BaseSettings, ISettingRegistry } from '@jupyterlab/settingregistry';
11
+ import { ITranslator } from '@jupyterlab/translation';
12
+ import {
13
+ PartialJSONObject,
14
+ ReadonlyJSONObject,
15
+ Token
16
+ } from '@lumino/coreutils';
17
+ import { MetadataFormWidget } from './metadataform';
18
+
19
+ export namespace MetadataForm {
20
+ /**
21
+ * The metadata schema as defined in JSON schema.
22
+ */
23
+ export type IMetadataSchema = ISettingRegistry.IMetadataSchema;
24
+
25
+ /**
26
+ * The meta information associated to all properties.
27
+ */
28
+ export interface IMetaInformation {
29
+ [metadataKey: string]: ISingleMetaInformation;
30
+ }
31
+
32
+ /**
33
+ * The meta information associated to a property.
34
+ */
35
+ export interface ISingleMetaInformation {
36
+ /**
37
+ * The metadata level, 'cell' or 'notebook'.
38
+ */
39
+ level?: 'cell' | 'notebook';
40
+
41
+ /**
42
+ * The cell types to display this metadata field.
43
+ */
44
+ cellTypes?: CellType[];
45
+
46
+ /**
47
+ * The default value for this metadata.
48
+ */
49
+ default?: any;
50
+
51
+ /**
52
+ * Whether to avoid writing default value in metadata.
53
+ */
54
+ writeDefault?: boolean;
55
+ }
56
+
57
+ /**
58
+ * RJSF ui:schema.
59
+ */
60
+ export interface IUiSchema {
61
+ [metadataKey: string]: IUiSchemaOption;
62
+ }
63
+
64
+ /**
65
+ * RJSF ui:schema options.
66
+ */
67
+ export interface IUiSchemaOption {
68
+ [option: string]: any;
69
+ }
70
+
71
+ /**
72
+ * Options passed to MetadataFormWidget.
73
+ */
74
+ export interface IOptions {
75
+ /**
76
+ * MetadataSchema defined from the settings.
77
+ */
78
+ metadataSchema: IMetadataSchema;
79
+
80
+ /**
81
+ * The meta information associated to all properties.
82
+ */
83
+ metaInformation: IMetaInformation;
84
+
85
+ /**
86
+ * The uiSchema built when loading schemas.
87
+ */
88
+ uiSchema?: IUiSchema;
89
+
90
+ /**
91
+ * The plugin ID.
92
+ */
93
+ pluginId?: string;
94
+
95
+ /**
96
+ * Translator object.
97
+ */
98
+ translator?: ITranslator;
99
+
100
+ /**
101
+ * Whether to show the modified field from default value.
102
+ */
103
+ showModified?: boolean;
104
+ }
105
+
106
+ /**
107
+ * Props passed to the FormWidget component.
108
+ */
109
+ export interface IProps {
110
+ /**
111
+ * Properties defined from the settings.
112
+ */
113
+ properties: IMetadataSchema;
114
+
115
+ /**
116
+ * Meta information associated to properties.
117
+ */
118
+ settings: BaseSettings;
119
+
120
+ /**
121
+ * Current data of the form.
122
+ */
123
+ formData: ReadonlyJSONObject;
124
+
125
+ /**
126
+ * Translator object.
127
+ */
128
+ translator: ITranslator;
129
+
130
+ /**
131
+ * The parent object of the form.
132
+ */
133
+ metadataFormWidget: MetadataFormWidget;
134
+
135
+ /**
136
+ * The uiSchema built when loading schemas.
137
+ */
138
+ uiSchema: IUiSchema;
139
+
140
+ /**
141
+ * Whether to show the modified field from default value.
142
+ */
143
+ showModified: boolean;
144
+
145
+ /**
146
+ * The plugin ID.
147
+ */
148
+ pluginId?: string;
149
+ }
150
+
151
+ /**
152
+ * A metadata form interface provided when registering
153
+ * to a metadata form provider. Allows an owner widget
154
+ * to set the metadata form content for itself.
155
+ */
156
+ export interface IMetadataForm extends NotebookTools.Tool {
157
+ /**
158
+ * Get the list of existing metadataKey (array of string).
159
+ *
160
+ * ## NOTE:
161
+ * The list contains also the conditional fields, which are not necessary
162
+ * displayed and filled.
163
+ */
164
+ readonly metadataKeys: string[];
165
+
166
+ /**
167
+ * Get the properties of a MetadataKey.
168
+ * @param metadataKey - metadataKey (array of string).
169
+ */
170
+ getProperties(metadataKey: string): PartialJSONObject | null;
171
+
172
+ /**
173
+ * Set properties to a metadataKey.
174
+ * @param metadataKey - metadataKey (array of string).
175
+ * @param properties - the properties to add or modify.
176
+ */
177
+ setProperties(metadataKey: string, properties: PartialJSONObject): void;
178
+
179
+ /**
180
+ * Update the metadata of the current cell or notebook.
181
+ *
182
+ * @param formData: the cell metadata set in the form.
183
+ * @param reload: whether to update the form after updating the metadata.
184
+ *
185
+ * ## Notes
186
+ * Metadata are updated from root only. If some metadata is nested,
187
+ * the whole root object must be updated.
188
+ * This function build an object with all the root object to update
189
+ * in metadata before performing update.
190
+ */
191
+ updateMetadata(formData: ReadonlyJSONObject, reload?: boolean): void;
192
+ }
193
+ }
194
+
195
+ /**
196
+ * A provider for metadata form.
197
+ */
198
+ export interface IMetadataFormProvider {
199
+ /**
200
+ * Add a MetadataFormWidget to the provider.
201
+ */
202
+ add(id: string, widget: MetadataForm.IMetadataForm): void;
203
+
204
+ /**
205
+ * Get a MetadataFormWidget from id.
206
+ */
207
+ get(id: string): MetadataForm.IMetadataForm | undefined;
208
+
209
+ /**
210
+ * Each ID must be described in schema.
211
+ */
212
+ _items: { [id: string]: MetadataForm.IMetadataForm };
213
+ }
214
+
215
+ /**
216
+ * The property inspector provider token.
217
+ */
218
+ export const IMetadataFormProvider = new Token<IMetadataFormProvider>(
219
+ '@jupyterlab/metadataform:IMetadataFormProvider'
220
+ );