@gravitee/graphene-core 2.49.0-graphene-142-code-editor.6ff118a → 2.49.0-json-schema-form-context.da98610

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.
Files changed (38) hide show
  1. package/dist/{CodeEditor-mEBgpud-.js → Skeleton-C30qULzD.js} +461 -704
  2. package/dist/__stories__/fixtures/index.d.ts +1 -1
  3. package/dist/__stories__/fixtures/index.d.ts.map +1 -1
  4. package/dist/__stories__/fixtures/json-schema-form/disableIf.fixture.d.ts.map +1 -1
  5. package/dist/__stories__/fixtures/json-schema-form/displayIf.fixture.d.ts.map +1 -1
  6. package/dist/__stories__/fixtures/json-schema-form/index.d.ts +0 -1
  7. package/dist/__stories__/fixtures/json-schema-form/index.d.ts.map +1 -1
  8. package/dist/code-editor/index.js +228 -2
  9. package/dist/composed/AppLayout/AppLayout.d.ts.map +1 -1
  10. package/dist/composed/CodeEditor/CodeEditor.d.ts.map +1 -1
  11. package/dist/composed/CodeEditor/setupCodeEditor.d.ts +39 -34
  12. package/dist/composed/CodeEditor/setupCodeEditor.d.ts.map +1 -1
  13. package/dist/composed/JsonSchemaForm/JsonSchemaForm.d.ts.map +1 -1
  14. package/dist/composed/JsonSchemaForm/SchemaField.d.ts.map +1 -1
  15. package/dist/composed/JsonSchemaForm/conditional/ConditionalGate.d.ts.map +1 -1
  16. package/dist/composed/JsonSchemaForm/conditional/concretizeCondition.d.ts.map +1 -1
  17. package/dist/composed/JsonSchemaForm/conditional/evalCondition.d.ts +6 -6
  18. package/dist/composed/JsonSchemaForm/conditional/evalCondition.d.ts.map +1 -1
  19. package/dist/composed/JsonSchemaForm/fields/__test-utils__/setupJsonSchemaForm.d.ts +1 -0
  20. package/dist/composed/JsonSchemaForm/fields/__test-utils__/setupJsonSchemaForm.d.ts.map +1 -1
  21. package/dist/composed/JsonSchemaForm/form-bindings/resolveAt.d.ts.map +1 -1
  22. package/dist/composed/JsonSchemaForm/schema/buildIndex.d.ts.map +1 -1
  23. package/dist/composed/JsonSchemaForm/schema/types.d.ts +3 -1
  24. package/dist/composed/JsonSchemaForm/schema/types.d.ts.map +1 -1
  25. package/dist/composed/JsonSchemaForm/utils/readPath.d.ts +12 -0
  26. package/dist/composed/JsonSchemaForm/utils/readPath.d.ts.map +1 -0
  27. package/dist/composed/JsonSchemaForm/utils/schemaShape.d.ts +1 -2
  28. package/dist/composed/JsonSchemaForm/utils/schemaShape.d.ts.map +1 -1
  29. package/dist/index.js +8302 -8333
  30. package/dist/styles/custom-variants.css +15 -0
  31. package/dist/styles/globals.css +1 -1
  32. package/package.json +2 -2
  33. package/snippets/json-schema-form-simple.tsx +20 -2
  34. package/snippets/json-schema-form-with-meta.tsx +18 -3
  35. package/dist/__stories__/fixtures/json-schema-form/code-editor.fixture.d.ts +0 -14
  36. package/dist/__stories__/fixtures/json-schema-form/code-editor.fixture.d.ts.map +0 -1
  37. package/dist/composed/JsonSchemaForm/fields/code-editor/CodeEditorField.d.ts +0 -8
  38. package/dist/composed/JsonSchemaForm/fields/code-editor/CodeEditorField.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravitee/graphene-core",
3
- "version": "2.49.0-graphene-142-code-editor.6ff118a",
3
+ "version": "2.49.0-json-schema-form-context.da98610",
4
4
  "type": "module",
5
5
  "description": "Gravitee's Graphene design system: accessible React components, design tokens, icons, and shared ESLint/TypeScript configs. Built on shadcn/ui and Tailwind.",
6
6
  "keywords": [
@@ -95,7 +95,7 @@
95
95
  },
96
96
  "peerDependencies": {
97
97
  "@fontsource/dm-sans": ">=5.0.0",
98
- "@gravitee/graphene-core": "2.49.0-graphene-142-code-editor.6ff118a",
98
+ "@gravitee/graphene-core": "2.49.0-json-schema-form-context.da98610",
99
99
  "@monaco-editor/react": "^4.7.0",
100
100
  "@tanstack/react-table": "^8.0.0",
101
101
  "@testing-library/dom": ">=10.0.0",
@@ -24,10 +24,23 @@ interface PluginConfigPageProps {
24
24
  // at the call site). A fresh object on every parent render defeats the `defaultValues`
25
25
  // memo and re-seeds the form, wiping in-progress user edits.
26
26
  readonly initialValue?: Record<string, unknown>;
27
+
28
+ // Host environment / feature flags / lock state read by `gioConfig.displayIf` /
29
+ // `gioConfig.disableIf` conditions of the form `{ "context.X": value }`. Remove this prop
30
+ // entirely if your schemas declare no `context.X` references.
31
+ readonly environment: 'production' | 'staging' | 'dev';
32
+ readonly readonlyMode: boolean;
33
+
27
34
  readonly onSave: (data: Record<string, unknown>) => void;
28
35
  }
29
36
 
30
- export function PluginConfigPage({ pluginSchema, initialValue, onSave }: PluginConfigPageProps) {
37
+ export function PluginConfigPage({
38
+ pluginSchema,
39
+ initialValue,
40
+ environment,
41
+ readonlyMode,
42
+ onSave,
43
+ }: PluginConfigPageProps) {
31
44
  // Memoize so `jsonSchemaResolver` does not recompile ajv on every parent render.
32
45
  const resolver = useMemo(() => jsonSchemaResolver(pluginSchema), [pluginSchema]);
33
46
  const defaultValues = useMemo(
@@ -35,6 +48,11 @@ export function PluginConfigPage({ pluginSchema, initialValue, onSave }: PluginC
35
48
  [pluginSchema, initialValue],
36
49
  );
37
50
 
51
+ // Stable object identity for the `context` prop. An inline `context={{ environment, readonlyMode }}`
52
+ // would create a new ref on every parent render and bust JsonSchemaForm's internal memo, re-rendering
53
+ // every field. `useMemo` keyed on the actual values keeps the ref stable until they change.
54
+ const formContext = useMemo(() => ({ environment, readonlyMode }), [environment, readonlyMode]);
55
+
38
56
  const form = useForm({
39
57
  resolver,
40
58
  defaultValues,
@@ -46,7 +64,7 @@ export function PluginConfigPage({ pluginSchema, initialValue, onSave }: PluginC
46
64
  // <FieldError> remain the single source of validation messages.
47
65
  return (
48
66
  <form noValidate onSubmit={form.handleSubmit(onSave)} className="flex flex-1 flex-col gap-4 p-8">
49
- <JsonSchemaForm schema={pluginSchema} control={form.control} name="" />
67
+ <JsonSchemaForm schema={pluginSchema} control={form.control} name="" context={formContext} />
50
68
  <Button type="submit">Save</Button>
51
69
  </form>
52
70
  );
@@ -40,10 +40,14 @@ type FormValues = z.infer<typeof metaSchema> & { config: Record<string, unknown>
40
40
  interface PluginConfigPageProps {
41
41
  readonly pluginSchema: JsonSchema;
42
42
  readonly initialValue?: Partial<FormValues>;
43
+ // Host environment / feature flags read by `gioConfig.displayIf` / `gioConfig.disableIf`
44
+ // conditions of the form `{ "context.X": value }`. Remove if your schemas declare no
45
+ // `context.X` references.
46
+ readonly environment: 'production' | 'staging' | 'dev';
43
47
  readonly onSave: (data: FormValues) => void;
44
48
  }
45
49
 
46
- export function PluginConfigPage({ pluginSchema, initialValue, onSave }: PluginConfigPageProps) {
50
+ export function PluginConfigPage({ pluginSchema, initialValue, environment, onSave }: PluginConfigPageProps) {
47
51
  // `basePath: 'config'` must match the `name` prop on <JsonSchemaForm> below.
48
52
  // Cast widens zodResolver to the composite values shape — each inner resolver reads
49
53
  // only its own slice of `values` at runtime, so the cast is sound.
@@ -66,6 +70,10 @@ export function PluginConfigPage({ pluginSchema, initialValue, onSave }: PluginC
66
70
  [pluginSchema],
67
71
  );
68
72
 
73
+ // Stable identity for the `context` prop on JsonSchemaForm — inline `{{ environment }}`
74
+ // would create a fresh ref each render and re-render every field downstream.
75
+ const formContext = useMemo(() => ({ environment }), [environment]);
76
+
69
77
  const form = useForm<FormValues>({
70
78
  resolver,
71
79
  mode: 'onTouched',
@@ -88,8 +96,15 @@ export function PluginConfigPage({ pluginSchema, initialValue, onSave }: PluginC
88
96
  </Field>
89
97
 
90
98
  {/* Plugin sub-tree — fields registered under `values.config.*`. JsonSchemaForm is typed
91
- against the generic RHF FieldValues; cast widens the narrow composite control. */}
92
- <JsonSchemaForm schema={pluginSchema} control={form.control as unknown as Control} name="config" />
99
+ against the generic RHF FieldValues; cast widens the narrow composite control.
100
+ `context` is memoized at the call site (here, via the `formContext` const below) so
101
+ a fresh ref does not bust JsonSchemaForm's internal memo every parent render. */}
102
+ <JsonSchemaForm
103
+ schema={pluginSchema}
104
+ control={form.control as unknown as Control}
105
+ name="config"
106
+ context={formContext}
107
+ />
93
108
 
94
109
  <Button type="submit">Save</Button>
95
110
  </form>
@@ -1,14 +0,0 @@
1
- import { JsonSchema } from '../../../composed/JsonSchemaForm';
2
- /**
3
- * Mirrors ui-particles' `codeEditorExample`
4
- * (`gio-form-json-schema/json-schema-example/code-editor.ts`) and the shape used by real APIM
5
- * plugins (`format: 'gio-code-editor'`, e.g. the dynamic-properties HTTP service's JOLT
6
- * transformation field). Forcing function for ISO behaviour: a Particles-authored schema must
7
- * render the same widget in Graphene.
8
- *
9
- * The trigger is `type: 'string'` + `format: 'gio-code-editor'`. The language is read from
10
- * `gioConfig.monacoEditorConfig.language` when present; otherwise the editor falls back to JSON
11
- * auto-detection (JSON payload → `json`, else `plaintext`), matching Particles.
12
- */
13
- export declare const jsonSchemaFormCodeEditorSchema: JsonSchema;
14
- //# sourceMappingURL=code-editor.fixture.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"code-editor.fixture.d.ts","sourceRoot":"","sources":["../../../../src/__stories__/fixtures/json-schema-form/code-editor.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iDAAiD,CAAC;AAElF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,8BAA8B,EAAE,UA2C5C,CAAC"}
@@ -1,8 +0,0 @@
1
- import { SchemaNode } from '../../schema/types';
2
- interface CodeEditorFieldProps {
3
- readonly node: SchemaNode;
4
- readonly name: string;
5
- }
6
- declare function CodeEditorField({ node, name }: CodeEditorFieldProps): import("react").JSX.Element;
7
- export { CodeEditorField };
8
- //# sourceMappingURL=CodeEditorField.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CodeEditorField.d.ts","sourceRoot":"","sources":["../../../../../src/composed/JsonSchemaForm/fields/code-editor/CodeEditorField.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAKrD,UAAU,oBAAoB;IAC5B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAoBD,iBAAS,eAAe,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,oBAAoB,+BAuC5D;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}