@remoteoss/json-schema-form 0.11.0-beta.0 → 0.11.1-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,3 +1,9 @@
1
+ #### 0.11.1-beta.0 (2024-07-26)
2
+
3
+ ##### Chores
4
+
5
+ * **modify:** Add missing Typescript declarations ([#84](https://github.com/remoteoss/json-schema-form/pull/84)) ([86b3af2a](https://github.com/remoteoss/json-schema-form/commit/86b3af2a31981718ad349ac8d08fbdce3aa86acf))
6
+
1
7
  #### 0.11.0-beta.0 (2024-07-25)
2
8
 
3
9
  ##### Breaking changes
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
2
  /*!
3
3
  Copyright (c) 2024 Remote Technology, Inc.
4
- NPM Package: @remoteoss/json-schema-form@0.11.0-beta.0
5
- Generated: Thu, 25 Jul 2024 16:43:12 GMT
4
+ NPM Package: @remoteoss/json-schema-form@0.11.1-beta.0
5
+ Generated: Fri, 26 Jul 2024 12:33:47 GMT
6
6
 
7
7
  MIT License
8
8
 
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
2
  /*!
3
3
  Copyright (c) 2024 Remote Technology, Inc.
4
- NPM Package: @remoteoss/json-schema-form@0.11.0-beta.0
5
- Generated: Thu, 25 Jul 2024 16:43:12 GMT
4
+ NPM Package: @remoteoss/json-schema-form@0.11.1-beta.0
5
+ Generated: Fri, 26 Jul 2024 12:33:47 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -1,8 +1,8 @@
1
1
 
2
2
  /*!
3
3
  Copyright (c) 2024 Remote Technology, Inc.
4
- NPM Package: @remoteoss/json-schema-form@0.11.0-beta.0
5
- Generated: Thu, 25 Jul 2024 16:43:12 GMT
4
+ NPM Package: @remoteoss/json-schema-form@0.11.1-beta.0
5
+ Generated: Fri, 26 Jul 2024 12:33:47 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -2,7 +2,6 @@
2
2
  * Shorthand to lookup for keys with `x-jsf-*` preffix.
3
3
  */
4
4
  export function pickXKey(node: Object, key: 'presentation' | 'errorMessage'): Object | undefined;
5
-
6
5
  type ValidationTypes =
7
6
  | 'type'
8
7
  | 'minimum'
@@ -104,6 +103,54 @@ type HeadlessFormOutput = {
104
103
  };
105
104
 
106
105
  type JSONSchemaObjectType = Record<string, unknown>;
106
+ type FieldName = string;
107
+ type FieldAttrs = Record<string, unknown>;
108
+
109
+ type FieldAttrsCallbackFn = (fieldName: FieldName, fieldAttrs: FieldAttrs) => FieldAttrs;
110
+
111
+ type ModConfigProperties = Record<FieldName, FieldAttrs | FieldAttrsCallbackFn>;
112
+
113
+ type ModifyConfig = {
114
+ /**
115
+ * An object with the fields to be modified with the returned attributes.
116
+ */
117
+ fields?: ModConfigProperties;
118
+ /**
119
+ * A callback function that runs through all fields, to modify them with the returned attributes.
120
+ */
121
+ allFields?: FieldAttrsCallbackFn;
122
+ /**
123
+ * An object of new fields to be created with the new attributes.
124
+ */
125
+ create?: ModConfigProperties;
126
+ /**
127
+ * An array of the fields to keep, removing the remaining fields.
128
+ */
129
+ pick?: FieldName[];
130
+ /* An array of fieldNames with the new order. Can be an object or callback function */
131
+ orderRoot?: FieldName[] | ((originalOrder: FieldName[]) => FieldName[]);
132
+ /**
133
+ * Mutes any logs or warnings from the library.
134
+ */
135
+ muteLogging?: boolean;
136
+ };
137
+
138
+ type WarningType =
139
+ | 'FIELD_TO_CHANGE_NOT_FOUND'
140
+ | 'ORDER_MISSING_FIELDS'
141
+ | 'FIELD_TO_CREATE_EXISTS'
142
+ | 'PICK_MISSED_FIELD';
143
+
144
+ type Warning = {
145
+ message: string;
146
+ type: WarningType;
147
+ meta?: Record<string, unknown>;
148
+ };
149
+
150
+ type ModifyOutput = {
151
+ schema: JSONSchemaObjectType;
152
+ warnings: Warning[];
153
+ };
107
154
 
108
155
  /**
109
156
  * Generates the Headless form based on the provided JSON schema
@@ -114,27 +161,17 @@ export function createHeadlessForm(
114
161
  customConfig?: JSFConfig
115
162
  ): HeadlessFormOutput;
116
163
 
117
- type MutationsConfig = {
118
- /**
119
- * An object with the list of fields to be mutated.
120
- */
121
- fields: Record<string, unknown>;
122
- /**
123
- * a callback function that applies a mutation to all the fields.
124
- * @param fieldName
125
- * @param fieldAttrs
126
- * @returns
127
- */
128
- allFields: (fieldName: string, fieldAttrs: Record<string, unknown>) => Record<string, unknown>;
129
- };
130
-
164
+ /**
165
+ * Returns a new JSON Schema modified based a given configuration.
166
+ * This does not mutate the original JSON Schema.
167
+ */
131
168
  export function modify(
132
169
  /**
133
- * The original JSON schema to be modified.
170
+ * The original JSON schema as base to the modifications.
134
171
  */
135
172
  originalSchema: JSONSchemaObjectType,
136
173
  /**
137
- * The configuration object containing the fields and allFields properties.
174
+ * The configuration object to create a new JSON Schema based on the originalSchema.
138
175
  */
139
- config?: MutationsConfig
140
- );
176
+ config?: ModifyConfig
177
+ ): ModifyOutput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remoteoss/json-schema-form",
3
- "version": "0.11.0-beta.0",
3
+ "version": "0.11.1-beta.0",
4
4
  "description": "Headless UI form powered by JSON Schemas",
5
5
  "author": "Remote.com <engineering@remote.com> (https://remote.com/)",
6
6
  "license": "MIT",