@rjsf/core 6.0.2 → 6.1.0

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 (33) hide show
  1. package/dist/core.umd.js +61 -38
  2. package/dist/index.cjs +293 -263
  3. package/dist/index.cjs.map +4 -4
  4. package/dist/index.esm.js +171 -138
  5. package/dist/index.esm.js.map +4 -4
  6. package/lib/components/RichHelp.d.ts +20 -0
  7. package/lib/components/RichHelp.d.ts.map +1 -0
  8. package/lib/components/RichHelp.js +17 -0
  9. package/lib/components/fields/ArrayField.d.ts.map +1 -1
  10. package/lib/components/fields/ArrayField.js +6 -1
  11. package/lib/components/fields/StringField.d.ts.map +1 -1
  12. package/lib/components/fields/StringField.js +3 -3
  13. package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -1
  14. package/lib/components/templates/ArrayFieldItemTemplate.js +5 -5
  15. package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -1
  16. package/lib/components/templates/ButtonTemplates/AddButton.js +1 -1
  17. package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -1
  18. package/lib/components/templates/FieldHelpTemplate.js +3 -6
  19. package/lib/components/templates/WrapIfAdditionalTemplate.d.ts.map +1 -1
  20. package/lib/components/templates/WrapIfAdditionalTemplate.js +4 -2
  21. package/lib/index.d.ts +3 -2
  22. package/lib/index.d.ts.map +1 -1
  23. package/lib/index.js +2 -1
  24. package/lib/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +1 -1
  26. package/src/components/RichHelp.tsx +46 -0
  27. package/src/components/fields/ArrayField.tsx +7 -0
  28. package/src/components/fields/StringField.tsx +3 -2
  29. package/src/components/templates/ArrayFieldItemTemplate.tsx +8 -11
  30. package/src/components/templates/ButtonTemplates/AddButton.tsx +3 -1
  31. package/src/components/templates/FieldHelpTemplate.tsx +5 -11
  32. package/src/components/templates/WrapIfAdditionalTemplate.tsx +7 -3
  33. package/src/index.ts +3 -2
package/dist/core.umd.js CHANGED
@@ -247,7 +247,9 @@
247
247
  handleReorderItems
248
248
  } = props;
249
249
  const {
250
- fields: { ArraySchemaField, SchemaField: SchemaField2 }
250
+ schemaUtils,
251
+ fields: { ArraySchemaField, SchemaField: SchemaField2 },
252
+ globalUiOptions
251
253
  } = registry;
252
254
  const fieldPathId = utils.useDeepCompareMemo(itemFieldPathId);
253
255
  const ItemSchemaField = ArraySchemaField || SchemaField2;
@@ -256,6 +258,9 @@
256
258
  registry,
257
259
  uiOptions
258
260
  );
261
+ const displayLabel = schemaUtils.getDisplayLabel(itemSchema, itemUiSchema, globalUiOptions);
262
+ const { description } = utils.getUiOptions(itemUiSchema);
263
+ const hasDescription = !!description || !!itemSchema.description;
259
264
  const { orderable = true, removable = true, copyable = false } = uiOptions;
260
265
  const has4 = {
261
266
  moveUp: orderable && canMoveUp,
@@ -349,7 +354,9 @@
349
354
  registry,
350
355
  schema: itemSchema,
351
356
  uiSchema: itemUiSchema,
352
- parentUiSchema
357
+ parentUiSchema,
358
+ displayLabel,
359
+ hasDescription
353
360
  };
354
361
  return /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemTemplate2, { ...templateProps });
355
362
  }
@@ -2301,9 +2308,10 @@
2301
2308
  onFocus,
2302
2309
  registry,
2303
2310
  rawErrors,
2304
- hideError
2311
+ hideError,
2312
+ title
2305
2313
  } = props;
2306
- const { title, format } = schema;
2314
+ const { title: schemaTitle, format } = schema;
2307
2315
  const { widgets: widgets2, schemaUtils, globalUiOptions } = registry;
2308
2316
  const enumOptions = schemaUtils.isSelect(schema) ? utils.optionsList(schema, uiSchema) : void 0;
2309
2317
  let defaultWidget = enumOptions ? "select" : "text";
@@ -2312,7 +2320,7 @@
2312
2320
  }
2313
2321
  const { widget = defaultWidget, placeholder = "", title: uiTitle, ...options } = utils.getUiOptions(uiSchema);
2314
2322
  const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
2315
- const label = uiTitle ?? title ?? name;
2323
+ const label = uiTitle ?? title ?? schemaTitle ?? name;
2316
2324
  const Widget = utils.getWidget(schema, widget, widgets2);
2317
2325
  const onWidgetChange = react.useCallback(
2318
2326
  (value, errorSchema, id) => {
@@ -2403,7 +2411,7 @@
2403
2411
  );
2404
2412
  }
2405
2413
  function ArrayFieldItemTemplate(props) {
2406
- const { children, className, buttonsProps, hasToolbar, registry, uiSchema } = props;
2414
+ const { children, className, buttonsProps, displayLabel, hasDescription, hasToolbar, registry, uiSchema } = props;
2407
2415
  const uiOptions = utils.getUiOptions(uiSchema);
2408
2416
  const ArrayFieldItemButtonsTemplate2 = utils.getTemplate(
2409
2417
  "ArrayFieldItemButtonsTemplate",
@@ -2416,19 +2424,12 @@
2416
2424
  paddingRight: 6,
2417
2425
  fontWeight: "bold"
2418
2426
  };
2419
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
2420
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: hasToolbar ? "col-xs-9" : "col-xs-12", children }),
2421
- hasToolbar && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-xs-3 array-item-toolbox", children: /* @__PURE__ */ jsxRuntime.jsx(
2422
- "div",
2423
- {
2424
- className: "btn-group",
2425
- style: {
2426
- display: "flex",
2427
- justifyContent: "space-around"
2428
- },
2429
- children: /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemButtonsTemplate2, { ...buttonsProps, style: btnStyle })
2430
- }
2431
- ) })
2427
+ const margin = hasDescription ? 31 : 9;
2428
+ const containerStyle = { display: "flex", alignItems: displayLabel ? "center" : "baseline" };
2429
+ const toolbarStyle = { display: "flex", justifyContent: "flex-end", marginTop: displayLabel ? `${margin}px` : 0 };
2430
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: containerStyle, children: [
2431
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: hasToolbar ? "col-xs-9 col-md-10 col-xl-11" : "col-xs-12", children }),
2432
+ hasToolbar && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-xs-3 col-md-2 col-xl-1 array-item-toolbox", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "btn-group", style: toolbarStyle, children: /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemButtonsTemplate2, { ...buttonsProps, style: btnStyle }) }) })
2432
2433
  ] });
2433
2434
  }
2434
2435
  function ArrayFieldItemButtonsTemplate(props) {
@@ -2708,19 +2709,25 @@
2708
2709
  registry
2709
2710
  }) {
2710
2711
  const { translateString } = registry;
2711
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "row", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: `col-xs-3 col-xs-offset-9 text-right ${className}`, children: /* @__PURE__ */ jsxRuntime.jsx(
2712
- IconButton,
2712
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "row", children: /* @__PURE__ */ jsxRuntime.jsx(
2713
+ "p",
2713
2714
  {
2714
- id,
2715
- iconType: "info",
2716
- icon: "plus",
2717
- className: "btn-add col-xs-12",
2718
- title: translateString(utils.TranslatableString.AddButton),
2719
- onClick,
2720
- disabled,
2721
- registry
2715
+ className: `col-xs-4 col-sm-2 col-lg-1 col-xs-offset-8 col-sm-offset-10 col-lg-offset-11 text-right ${className}`,
2716
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2717
+ IconButton,
2718
+ {
2719
+ id,
2720
+ iconType: "info",
2721
+ icon: "plus",
2722
+ className: "btn-add col-xs-12",
2723
+ title: translateString(utils.TranslatableString.AddButton),
2724
+ onClick,
2725
+ disabled,
2726
+ registry
2727
+ }
2728
+ )
2722
2729
  }
2723
- ) }) });
2730
+ ) });
2724
2731
  }
2725
2732
 
2726
2733
  // src/components/templates/ButtonTemplates/index.ts
@@ -2824,16 +2831,26 @@
2824
2831
  return /* @__PURE__ */ jsxRuntime.jsx("li", { className: "text-danger", children: error }, index);
2825
2832
  }) }) });
2826
2833
  }
2834
+ var TEST_IDS2 = utils.getTestIds();
2835
+ function RichHelp({
2836
+ help,
2837
+ registry,
2838
+ uiSchema = {}
2839
+ }) {
2840
+ const { globalUiOptions } = registry;
2841
+ const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
2842
+ if (uiOptions.enableMarkdownInHelp && typeof help === "string") {
2843
+ return /* @__PURE__ */ jsxRuntime.jsx(Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS2.markdown, children: help });
2844
+ }
2845
+ return help;
2846
+ }
2847
+ RichHelp.TEST_IDS = TEST_IDS2;
2827
2848
  function FieldHelpTemplate(props) {
2828
- const { fieldPathId, help } = props;
2849
+ const { fieldPathId, help, uiSchema, registry } = props;
2829
2850
  if (!help) {
2830
2851
  return null;
2831
2852
  }
2832
- const id = utils.helpId(fieldPathId);
2833
- if (typeof help === "string") {
2834
- return /* @__PURE__ */ jsxRuntime.jsx("p", { id, className: "help-block", children: help });
2835
- }
2836
- return /* @__PURE__ */ jsxRuntime.jsx("div", { id, className: "help-block", children: help });
2853
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { id: utils.helpId(fieldPathId), className: "help-block", children: /* @__PURE__ */ jsxRuntime.jsx(RichHelp, { help, registry, uiSchema }) });
2837
2854
  }
2838
2855
  function GridTemplate(props) {
2839
2856
  const { children, column, className, ...rest } = props;
@@ -2975,9 +2992,11 @@
2975
2992
  classNames,
2976
2993
  style,
2977
2994
  disabled,
2995
+ displayLabel,
2978
2996
  label,
2979
2997
  onKeyRenameBlur,
2980
2998
  onRemoveProperty,
2999
+ rawDescription,
2981
3000
  readonly,
2982
3001
  required,
2983
3002
  schema,
@@ -2991,6 +3010,7 @@
2991
3010
  const { RemoveButton: RemoveButton2 } = templates2.ButtonTemplates;
2992
3011
  const keyLabel = translateString(utils.TranslatableString.KeyLabel, [label]);
2993
3012
  const additional = utils.ADDITIONAL_PROPERTY_FLAG in schema;
3013
+ const hasDescription = !!rawDescription;
2994
3014
  const classNamesList = ["form-group", classNames];
2995
3015
  if (!hideError && rawErrors && rawErrors.length > 0) {
2996
3016
  classNamesList.push("has-error has-danger");
@@ -2999,9 +3019,11 @@
2999
3019
  if (!additional) {
3000
3020
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: uiClassNames, style, children });
3001
3021
  }
3022
+ const margin = hasDescription ? 46 : 26;
3002
3023
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: uiClassNames, style, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "row", children: [
3003
3024
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-xs-5 form-additional", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "form-group", children: [
3004
- /* @__PURE__ */ jsxRuntime.jsx(Label, { label: keyLabel, required, id: `${id}-key` }),
3025
+ displayLabel && /* @__PURE__ */ jsxRuntime.jsx(Label, { label: keyLabel, required, id: `${id}-key` }),
3026
+ displayLabel && rawDescription && /* @__PURE__ */ jsxRuntime.jsx("div", { children: "\xA0" }),
3005
3027
  /* @__PURE__ */ jsxRuntime.jsx(
3006
3028
  "input",
3007
3029
  {
@@ -3014,7 +3036,7 @@
3014
3036
  )
3015
3037
  ] }) }),
3016
3038
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "form-additional form-group col-xs-5", children }),
3017
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-xs-2", children: /* @__PURE__ */ jsxRuntime.jsx(
3039
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-xs-2", style: { marginTop: displayLabel ? `${margin}px` : void 0 }, children: /* @__PURE__ */ jsxRuntime.jsx(
3018
3040
  RemoveButton2,
3019
3041
  {
3020
3042
  id: utils.buttonId(id, "remove"),
@@ -4596,6 +4618,7 @@
4596
4618
  var index_default = Form;
4597
4619
 
4598
4620
  exports.RichDescription = RichDescription;
4621
+ exports.RichHelp = RichHelp;
4599
4622
  exports.default = index_default;
4600
4623
  exports.getDefaultRegistry = getDefaultRegistry;
4601
4624
  exports.getTestRegistry = getTestRegistry;