@remoteoss/json-schema-form 0.2.0-beta.0 → 0.4.0-beta.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.
package/CHANGELOG.md CHANGED
@@ -1,12 +1,30 @@
1
+ #### 0.4.0-beta.0 (2023-06-22)
2
+
3
+ ##### New Features
4
+
5
+ BREAKING CHANGES:
6
+
7
+ - **Radio/Select:** In each option, spread `x-jsf-presentation` value to option root ([#17](https://github.com/remoteoss/json-schema-form/pull/17)) ([367688c2](https://github.com/remoteoss/json-schema-form/commit/367688c24e212c1a0a1d2e7b19cbd7efa7021a15))
8
+
9
+ #### 0.3.0-beta.0 (2023-06-21)
10
+
11
+ ##### Fixes
12
+
13
+ - **Text:** Fix validation to only accept strings ([#12](https://github.com/remoteoss/json-schema-form/pull/12)) ([00017c0](https://github.com/remoteoss/json-schema-form/commit/00017c056d8a3583d56d9fefc4d3c7e0f4c1dd99))
14
+
15
+ ##### Chores
16
+
17
+ - Update Yup to v.0.30.0 ([#12](https://github.com/remoteoss/json-schema-form/pull/12)) ([00017c0](https://github.com/remoteoss/json-schema-form/commit/00017c056d8a3583d56d9fefc4d3c7e0f4c1dd99))
18
+
1
19
  #### 0.2.0-beta.0 (2023-06-20)
2
20
 
3
21
  ##### New Features
4
22
 
5
- - Add typescript declarations to the library ([2404188c](https://github.com/remoteoss/json-schema-form/commit/2404188cba52a5a665f257430a65a0ebb938dd44))
23
+ - Add Typescript declarations to the library ([2404188c](https://github.com/remoteoss/json-schema-form/commit/2404188cba52a5a665f257430a65a0ebb938dd44))
6
24
 
7
25
  ##### Fixes
8
26
 
9
- - Support maximum 0 ([#10](https://github.com/remoteoss/json-schema-form/pull/10)) ([1e9d6cf9](https://github.com/remoteoss/json-schema-form/commit/1e9d6cf96436cf16018e045b351567c643e10dac))
27
+ - **Number:** Support maximum 0 ([#10](https://github.com/remoteoss/json-schema-form/pull/10)) ([1e9d6cf9](https://github.com/remoteoss/json-schema-form/commit/1e9d6cf96436cf16018e045b351567c643e10dac))
10
28
 
11
29
  ##### Chores
12
30
 
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
2
  /*!
3
3
  Copyright (c) 2023 Remote Technology, Inc.
4
- NPM Package: @remoteoss/json-schema-form@0.2.0-beta.0
5
- Generated: Tue, 20 Jun 2023 08:31:44 GMT
4
+ NPM Package: @remoteoss/json-schema-form@0.4.0-beta.0
5
+ Generated: Thu, 22 Jun 2023 10:03:23 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -371,8 +371,18 @@ var baseString = (0, import_yup.string)().trim();
371
371
  var todayDateHint = (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
372
372
  var convertBytesToKB = convertDiskSizeFromTo("Bytes", "KB");
373
373
  var convertKbBytesToMB = convertDiskSizeFromTo("KB", "MB");
374
+ var validateOnlyStrings = (0, import_yup.string)().trim().nullable().test(
375
+ "is-string",
376
+ "${path} must be a `string` type, but the final value was: `${value}`.",
377
+ (value, context) => {
378
+ if (context.originalValue !== null && context.originalValue !== void 0) {
379
+ return typeof context.originalValue === "string";
380
+ }
381
+ return true;
382
+ }
383
+ );
374
384
  var yupSchemas = {
375
- text: (0, import_yup.string)().trim().nullable(),
385
+ text: validateOnlyStrings,
376
386
  select: (0, import_yup.string)().trim().nullable(),
377
387
  radio: (0, import_yup.string)().trim().nullable(),
378
388
  date: (0, import_yup.string)().nullable().trim().matches(
@@ -794,12 +804,26 @@ function updateFieldsProperties(fields, formValues, jsonSchema) {
794
804
  clearValuesIfNotVisible(fields, formValues);
795
805
  }
796
806
  var notNullOption = (opt) => opt.const !== null;
807
+ function flatPresentation(item) {
808
+ return Object.entries(item).reduce((newItem, [key, value]) => {
809
+ if (key === "x-jsf-presentation") {
810
+ return {
811
+ ...newItem,
812
+ ...value
813
+ };
814
+ }
815
+ return {
816
+ ...newItem,
817
+ [key]: value
818
+ };
819
+ }, {});
820
+ }
797
821
  function getFieldOptions(node, presentation) {
798
822
  function convertToOptions(nodeOptions) {
799
823
  return nodeOptions.filter(notNullOption).map(({ title, const: cons, ...item }) => ({
800
824
  label: title,
801
825
  value: cons,
802
- ...item
826
+ ...flatPresentation(item)
803
827
  }));
804
828
  }
805
829
  if (presentation.options) {
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
2
  /*!
3
3
  Copyright (c) 2023 Remote Technology, Inc.
4
- NPM Package: @remoteoss/json-schema-form@0.2.0-beta.0
5
- Generated: Tue, 20 Jun 2023 08:31:44 GMT
4
+ NPM Package: @remoteoss/json-schema-form@0.4.0-beta.0
5
+ Generated: Thu, 22 Jun 2023 10:03:23 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -335,8 +335,18 @@ var baseString = string().trim();
335
335
  var todayDateHint = (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
336
336
  var convertBytesToKB = convertDiskSizeFromTo("Bytes", "KB");
337
337
  var convertKbBytesToMB = convertDiskSizeFromTo("KB", "MB");
338
+ var validateOnlyStrings = string().trim().nullable().test(
339
+ "is-string",
340
+ "${path} must be a `string` type, but the final value was: `${value}`.",
341
+ (value, context) => {
342
+ if (context.originalValue !== null && context.originalValue !== void 0) {
343
+ return typeof context.originalValue === "string";
344
+ }
345
+ return true;
346
+ }
347
+ );
338
348
  var yupSchemas = {
339
- text: string().trim().nullable(),
349
+ text: validateOnlyStrings,
340
350
  select: string().trim().nullable(),
341
351
  radio: string().trim().nullable(),
342
352
  date: string().nullable().trim().matches(
@@ -758,12 +768,26 @@ function updateFieldsProperties(fields, formValues, jsonSchema) {
758
768
  clearValuesIfNotVisible(fields, formValues);
759
769
  }
760
770
  var notNullOption = (opt) => opt.const !== null;
771
+ function flatPresentation(item) {
772
+ return Object.entries(item).reduce((newItem, [key, value]) => {
773
+ if (key === "x-jsf-presentation") {
774
+ return {
775
+ ...newItem,
776
+ ...value
777
+ };
778
+ }
779
+ return {
780
+ ...newItem,
781
+ [key]: value
782
+ };
783
+ }, {});
784
+ }
761
785
  function getFieldOptions(node, presentation) {
762
786
  function convertToOptions(nodeOptions) {
763
787
  return nodeOptions.filter(notNullOption).map(({ title, const: cons, ...item }) => ({
764
788
  label: title,
765
789
  value: cons,
766
- ...item
790
+ ...flatPresentation(item)
767
791
  }));
768
792
  }
769
793
  if (presentation.options) {