@rjsf/utils 5.0.0-beta.1
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/LICENSE.md +201 -0
- package/README.md +106 -0
- package/dist/allowAdditionalItems.d.ts +8 -0
- package/dist/asNumber.d.ts +10 -0
- package/dist/canExpand.d.ts +11 -0
- package/dist/constants.d.ts +27 -0
- package/dist/createSchemaUtils.d.ts +9 -0
- package/dist/dataURItoBlob.d.ts +10 -0
- package/dist/deepEquals.d.ts +8 -0
- package/dist/findSchemaDefinition.d.ts +20 -0
- package/dist/getInputProps.d.ts +10 -0
- package/dist/getSchemaType.d.ts +13 -0
- package/dist/getSubmitButtonOptions.d.ts +10 -0
- package/dist/getTemplate.d.ts +10 -0
- package/dist/getUiOptions.d.ts +8 -0
- package/dist/getWidget.d.ts +13 -0
- package/dist/guessType.d.ts +7 -0
- package/dist/hasWidget.d.ts +10 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +8 -0
- package/dist/isConstant.d.ts +8 -0
- package/dist/isCustomWidget.d.ts +7 -0
- package/dist/isFixedItems.d.ts +8 -0
- package/dist/isObject.d.ts +7 -0
- package/dist/localToUTC.d.ts +6 -0
- package/dist/mergeDefaultsWithFormData.d.ts +15 -0
- package/dist/mergeObjects.d.ts +9 -0
- package/dist/mergeSchemas.d.ts +10 -0
- package/dist/optionsList.d.ts +10 -0
- package/dist/orderProperties.d.ts +11 -0
- package/dist/pad.d.ts +7 -0
- package/dist/parseDateString.d.ts +9 -0
- package/dist/processSelectValue.d.ts +11 -0
- package/dist/rangeSpec.d.ts +9 -0
- package/dist/schema/getDefaultFormState.d.ts +47 -0
- package/dist/schema/getDisplayLabel.d.ts +11 -0
- package/dist/schema/getMatchingOption.d.ts +10 -0
- package/dist/schema/index.d.ts +11 -0
- package/dist/schema/isFilesArray.d.ts +10 -0
- package/dist/schema/isMultiSelect.d.ts +9 -0
- package/dist/schema/isSelect.d.ts +9 -0
- package/dist/schema/mergeValidationData.d.ts +12 -0
- package/dist/schema/retrieveSchema.d.ts +98 -0
- package/dist/schema/toIdSchema.d.ts +13 -0
- package/dist/schema/toPathSchema.d.ts +11 -0
- package/dist/schemaRequiresTrueValue.d.ts +11 -0
- package/dist/shouldRender.d.ts +10 -0
- package/dist/toConstant.d.ts +9 -0
- package/dist/toDateString.d.ts +9 -0
- package/dist/types.d.ts +755 -0
- package/dist/utcToLocal.d.ts +6 -0
- package/dist/utils.cjs.development.js +2274 -0
- package/dist/utils.cjs.development.js.map +1 -0
- package/dist/utils.cjs.production.min.js +2 -0
- package/dist/utils.cjs.production.min.js.map +1 -0
- package/dist/utils.esm.js +2192 -0
- package/dist/utils.esm.js.map +1 -0
- package/dist/utils.umd.development.js +2269 -0
- package/dist/utils.umd.development.js.map +1 -0
- package/dist/utils.umd.production.min.js +2 -0
- package/dist/utils.umd.production.min.js.map +1 -0
- package/package.json +79 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
[![Build Status][build-shield]][build-url]
|
|
2
|
+
[![npm][npm-shield]][npm-url]
|
|
3
|
+
[![npm downloads][npm-dl-shield]][npm-dl-url]
|
|
4
|
+
[![Contributors][contributors-shield]][contributors-url]
|
|
5
|
+
[![Apache 2.0 License][license-shield]][license-url]
|
|
6
|
+
|
|
7
|
+
<!-- PROJECT LOGO -->
|
|
8
|
+
<br />
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://github.com/rjsf-team/react-jsonschema-form">
|
|
11
|
+
<img src="https://raw.githubusercontent.com/rjsf-team/react-jsonschema-form/59a8206e148474bea854bbb004f624143fbcbac8/packages/utils/logo.png" alt="Logo" width="120" height="120">
|
|
12
|
+
</a>
|
|
13
|
+
|
|
14
|
+
<h3 align="center">@rjsf/utils</h3>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
AJV-6 based validator plugin for <a href="https://github.com/rjsf-team/react-jsonschema-form/"><code>react-jsonschema-form</code></a>.
|
|
18
|
+
<br />
|
|
19
|
+
<a href="https://react-jsonschema-form.readthedocs.io/en/stable/"><strong>Explore the docs »</strong></a>
|
|
20
|
+
<br />
|
|
21
|
+
<br />
|
|
22
|
+
<a href="https://rjsf-team.github.io/react-jsonschema-form/">View Playground</a>
|
|
23
|
+
·
|
|
24
|
+
<a href="https://github.com/rjsf-team/react-jsonschema-form/issues">Report Bug</a>
|
|
25
|
+
·
|
|
26
|
+
<a href="https://github.com/rjsf-team/react-jsonschema-form/issues">Request Feature</a>
|
|
27
|
+
</p>
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
<!-- TABLE OF CONTENTS -->
|
|
31
|
+
|
|
32
|
+
## Table of Contents
|
|
33
|
+
|
|
34
|
+
- [About The Project](#about-the-project)
|
|
35
|
+
- [Getting Started](#getting-started)
|
|
36
|
+
- [Prerequisites](#prerequisites)
|
|
37
|
+
- [Installation](#installation)
|
|
38
|
+
- [Usage](#usage)
|
|
39
|
+
- [Roadmap](#roadmap)
|
|
40
|
+
- [Contributing](#contributing)
|
|
41
|
+
- [Contact](#contact)
|
|
42
|
+
|
|
43
|
+
<!-- ABOUT THE PROJECT -->
|
|
44
|
+
|
|
45
|
+
## About The Project
|
|
46
|
+
|
|
47
|
+
Exports `utils` plugin for `react-jsonschema-form`.
|
|
48
|
+
|
|
49
|
+
### Built With
|
|
50
|
+
|
|
51
|
+
- [react-jsonschema-form](https://github.com/rjsf-team/react-jsonschema-form/)
|
|
52
|
+
- [AJV](https://github.com/ajv-validator/ajv/)
|
|
53
|
+
- [TypeScript](https://www.typescriptlang.org/)
|
|
54
|
+
|
|
55
|
+
<!-- GETTING STARTED -->
|
|
56
|
+
|
|
57
|
+
## Getting Started
|
|
58
|
+
|
|
59
|
+
### Installation
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
yarn add @rjsf/utils
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
<!-- USAGE EXAMPLES -->
|
|
66
|
+
|
|
67
|
+
## Usage
|
|
68
|
+
|
|
69
|
+
```jsx
|
|
70
|
+
import * as Utils from '@rjsf/utils';
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
<!-- ROADMAP -->
|
|
74
|
+
|
|
75
|
+
## Roadmap
|
|
76
|
+
|
|
77
|
+
See the [open issues](https://github.com/rjsf-team/react-jsonschema-form/issues) for a list of proposed features (and known issues).
|
|
78
|
+
|
|
79
|
+
<!-- CONTRIBUTING -->
|
|
80
|
+
|
|
81
|
+
## Contributing
|
|
82
|
+
|
|
83
|
+
Read our [contributors' guide](https://react-jsonschema-form.readthedocs.io/en/stable/contributing/) to get started.
|
|
84
|
+
|
|
85
|
+
<!-- CONTACT -->
|
|
86
|
+
|
|
87
|
+
## Contact
|
|
88
|
+
|
|
89
|
+
rjsf team: [https://github.com/orgs/rjsf-team/people](https://github.com/orgs/rjsf-team/people)
|
|
90
|
+
|
|
91
|
+
GitHub repository: [https://github.com/rjsf-team/react-jsonschema-form](https://github.com/rjsf-team/react-jsonschema-form)
|
|
92
|
+
|
|
93
|
+
<!-- MARKDOWN LINKS & IMAGES -->
|
|
94
|
+
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
|
|
95
|
+
|
|
96
|
+
[build-shield]: https://github.com/rjsf-team/react-jsonschema-form/workflows/CI/badge.svg
|
|
97
|
+
[build-url]: https://github.com/rjsf-team/react-jsonschema-form/actions
|
|
98
|
+
[contributors-shield]: https://img.shields.io/github/contributors/rjsf-team/react-jsonschema-form.svg
|
|
99
|
+
[contributors-url]: https://github.com/rjsf-team/react-jsonschema-form/graphs/contributors
|
|
100
|
+
[license-shield]: https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat-square
|
|
101
|
+
[license-url]: https://choosealicense.com/licenses/apache-2.0/
|
|
102
|
+
[npm-shield]: https://img.shields.io/npm/v/@rjsf/material-ui/latest.svg?style=flat-square
|
|
103
|
+
[npm-url]: https://www.npmjs.com/package/@rjsf/material-ui
|
|
104
|
+
[npm-dl-shield]: https://img.shields.io/npm/dm/@rjsf/material-ui.svg?style=flat-square
|
|
105
|
+
[npm-dl-url]: https://www.npmjs.com/package/@rjsf/material-ui
|
|
106
|
+
[product-screenshot]: https://raw.githubusercontent.com/rjsf-team/react-jsonschema-form/e2e1181d1020f18cad0c80c661ddae28edb9794e/packages/material-ui/screenshot5.png
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RJSFSchema } from "./types";
|
|
2
|
+
/** Checks the schema to see if it is allowing additional items, by verifying that `schema.additionalItems` is an
|
|
3
|
+
* object. The user is warned in the console if `schema.additionalItems` has the value `true`.
|
|
4
|
+
*
|
|
5
|
+
* @param schema - The schema object to check
|
|
6
|
+
* @returns - True if additional items is allowed, otherwise false
|
|
7
|
+
*/
|
|
8
|
+
export default function allowAdditionalItems(schema: RJSFSchema): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Attempts to convert the string into a number. If an empty string is provided, then `undefined` is returned. If a
|
|
2
|
+
* `null` is provided, it is returned. If the string ends in a `.` then the string is returned because the user may be
|
|
3
|
+
* in the middle of typing a float number. If a number ends in a pattern like `.0`, `.20`, `.030`, string is returned
|
|
4
|
+
* because the user may be typing number that will end in a non-zero digit. Otherwise, the string is wrapped by
|
|
5
|
+
* `Number()` and if that result is not `NaN`, that number will be returned, otherwise the string `value` will be.
|
|
6
|
+
*
|
|
7
|
+
* @param value - The string or null value to convert to a number
|
|
8
|
+
* @returns - The `value` converted to a number when appropriate, otherwise the `value`
|
|
9
|
+
*/
|
|
10
|
+
export default function asNumber(value: string | null): string | number | null | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RJSFSchema, UiSchema } from "./types";
|
|
2
|
+
/** Checks whether the field described by `schema`, having the `uiSchema` and `formData` supports expanding. The UI for
|
|
3
|
+
* the field can expand if it has additional properties, is not forced as non-expandable by the `uiSchema` and the
|
|
4
|
+
* `formData` object doesn't already have `schema.maxProperties` elements.
|
|
5
|
+
*
|
|
6
|
+
* @param schema - The schema for the field that is being checked
|
|
7
|
+
* @param [uiSchema={}] - The uiSchema for the field
|
|
8
|
+
* @param [formData] - The formData for the field
|
|
9
|
+
* @returns - True if the schema element has additionalProperties, is expandable, and not at the maxProperties limit
|
|
10
|
+
*/
|
|
11
|
+
export default function canExpand<T = any, F = any>(schema: RJSFSchema, uiSchema?: UiSchema<T, F>, formData?: T): boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Below are the list of all the keys into various elements of a RJSFSchema or UiSchema that are used by the various
|
|
2
|
+
* utility functions. In addition to those keys, there are the special `ADDITIONAL_PROPERTY_FLAG` and
|
|
3
|
+
* `RJSF_ADDITONAL_PROPERTIES_FLAG` flags that is added to a schema under certain conditions by the `retrieveSchema()`
|
|
4
|
+
* utility.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ADDITIONAL_PROPERTY_FLAG = "__additional_property";
|
|
7
|
+
export declare const ADDITIONAL_PROPERTIES_KEY = "additionalProperties";
|
|
8
|
+
export declare const ALL_OF_KEY = "allOf";
|
|
9
|
+
export declare const ANY_OF_KEY = "anyOf";
|
|
10
|
+
export declare const CONST_KEY = "const";
|
|
11
|
+
export declare const DEFAULT_KEY = "default";
|
|
12
|
+
export declare const DEFINITIONS_KEY = "definitions";
|
|
13
|
+
export declare const DEPENDENCIES_KEY = "dependencies";
|
|
14
|
+
export declare const ENUM_KEY = "enum";
|
|
15
|
+
export declare const ERRORS_KEY = "__errors";
|
|
16
|
+
export declare const ID_KEY = "$id";
|
|
17
|
+
export declare const ITEMS_KEY = "items";
|
|
18
|
+
export declare const NAME_KEY = "$name";
|
|
19
|
+
export declare const ONE_OF_KEY = "oneOf";
|
|
20
|
+
export declare const PROPERTIES_KEY = "properties";
|
|
21
|
+
export declare const REQUIRED_KEY = "required";
|
|
22
|
+
export declare const SUBMIT_BTN_OPTIONS_KEY = "submitButtonOptions";
|
|
23
|
+
export declare const REF_KEY = "$ref";
|
|
24
|
+
export declare const RJSF_ADDITONAL_PROPERTIES_FLAG = "__rjsf_additionalProperties";
|
|
25
|
+
export declare const UI_FIELD_KEY = "ui:field";
|
|
26
|
+
export declare const UI_WIDGET_KEY = "ui:widget";
|
|
27
|
+
export declare const UI_OPTIONS_KEY = "ui:options";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RJSFSchema, SchemaUtilsType, ValidatorType } from "./types";
|
|
2
|
+
/** Creates a `SchemaUtilsType` interface that is based around the given `validator` and `rootSchema` parameters. The
|
|
3
|
+
* resulting interface implementation will forward the `validator` and `rootSchema` to all the wrapped APIs.
|
|
4
|
+
*
|
|
5
|
+
* @param validator - an implementation of the `ValidatorType` interface that will be forwarded to all the APIs
|
|
6
|
+
* @param rootSchema - The root schema that will be forwarded to all the APIs
|
|
7
|
+
* @returns - An implementation of a `SchemaUtilsType` interface
|
|
8
|
+
*/
|
|
9
|
+
export default function createSchemaUtils<T = any>(validator: ValidatorType, rootSchema: RJSFSchema): SchemaUtilsType<T>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Given the `FileReader.readAsDataURL()` based `dataURI` extracts that data into an actual Blob along with the name
|
|
2
|
+
* of that Blob if provided in the URL. If no name is provided, then the name falls back to `unknown`.
|
|
3
|
+
*
|
|
4
|
+
* @param dataURI - The `DataUrl` potentially containing name and raw data to be converted to a Blob
|
|
5
|
+
* @returns - an object containing a Blob and its name, extracted from the URI
|
|
6
|
+
*/
|
|
7
|
+
export default function dataURItoBlob(dataURI: string): {
|
|
8
|
+
blob: Blob;
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Implements a deep equals using the `lodash.isEqualWith` function, that provides a customized comparator that
|
|
2
|
+
* assumes all functions are equivalent.
|
|
3
|
+
*
|
|
4
|
+
* @param a - The first element to compare
|
|
5
|
+
* @param b - The second element to compare
|
|
6
|
+
* @returns - True if the `a` and `b` are deeply equal, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
export default function deepEquals(a: any, b: any): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GenericObjectType, RJSFSchema } from "./types";
|
|
2
|
+
/** Splits out the value at the `key` in `object` from the `object`, returning an array that contains in the first
|
|
3
|
+
* location, the `object` minus the `key: value` and in the second location the `value`.
|
|
4
|
+
*
|
|
5
|
+
* @param key - The key from the object to extract
|
|
6
|
+
* @param object - The object from which to extract the element
|
|
7
|
+
* @returns - An array with the first value being the object minus the `key` element and the second element being the
|
|
8
|
+
* value from `object[key]`
|
|
9
|
+
*/
|
|
10
|
+
export declare function splitKeyElementFromObject(key: string, object: GenericObjectType): any[];
|
|
11
|
+
/** Given the name of a `$ref` from within a schema, using the `rootSchema`, look up and return the sub-schema using the
|
|
12
|
+
* path provided by that reference. If `#` is not the first character of the reference, or the path does not exist in
|
|
13
|
+
* the schema, then throw an Error. Otherwise return the sub-schema. Also deals with nested `$ref`s in the sub-schema.
|
|
14
|
+
*
|
|
15
|
+
* @param $ref - The ref string for which the schema definition is desired
|
|
16
|
+
* @param [rootSchema={}] - The root schema in which to search for the definition
|
|
17
|
+
* @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists
|
|
18
|
+
* @throws - Error indicating that no schema for that reference exists
|
|
19
|
+
*/
|
|
20
|
+
export default function findSchemaDefinition($ref?: string, rootSchema?: RJSFSchema): RJSFSchema;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InputPropsType, RJSFSchema, UIOptionsType } from "./types";
|
|
2
|
+
/** Using the `schema`, `defaultType` and `options`, extract out the props for the <input> element that make sense.
|
|
3
|
+
*
|
|
4
|
+
* @param schema - The schema for the field provided by the widget
|
|
5
|
+
* @param [defaultType] - The default type, if any, for the field provided by the widget
|
|
6
|
+
* @param [options={}] - The UI Options for the field provided by the widget
|
|
7
|
+
* @param [autoDefaultStepAny=true] - Determines whether to auto-default step=any when the type is number and no step
|
|
8
|
+
* @returns - The extracted `InputPropsType` object
|
|
9
|
+
*/
|
|
10
|
+
export default function getInputProps<T = any, F = any>(schema: RJSFSchema, defaultType?: string, options?: UIOptionsType<T, F>, autoDefaultStepAny?: boolean): InputPropsType;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RJSFSchema } from "./types";
|
|
2
|
+
/** Gets the type of a given `schema`. If the type is not explicitly defined, then an attempt is made to infer it from
|
|
3
|
+
* other elements of the schema as follows:
|
|
4
|
+
* - schema.const: Returns the `guessType()` of that value
|
|
5
|
+
* - schema.enum: Returns `string`
|
|
6
|
+
* - schema.properties: Returns `object`
|
|
7
|
+
* - schema.additionalProperties: Returns `object`
|
|
8
|
+
* - type is an array with a length of 2 and one type is 'null': Returns the other type
|
|
9
|
+
*
|
|
10
|
+
* @param schema - The schema for which to get the type
|
|
11
|
+
* @returns - The type of the schema
|
|
12
|
+
*/
|
|
13
|
+
export default function getSchemaType(schema: RJSFSchema): string | string[] | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UiSchema, UISchemaSubmitButtonOptions } from "./types";
|
|
2
|
+
/** The default submit button options, exported for testing purposes
|
|
3
|
+
*/
|
|
4
|
+
export declare const DEFAULT_OPTIONS: UISchemaSubmitButtonOptions;
|
|
5
|
+
/** Extracts any `ui:submitButtonOptions` from the `uiSchema` and merges them onto the `DEFAULT_OPTIONS`
|
|
6
|
+
*
|
|
7
|
+
* @param [uiSchema={}] - the UI Schema from which to extract submit button props
|
|
8
|
+
* @returns - The merging of the `DEFAULT_OPTIONS` with any custom ones
|
|
9
|
+
*/
|
|
10
|
+
export default function getSubmitButtonOptions<T = any, F = any>(uiSchema?: UiSchema<T, F>): UISchemaSubmitButtonOptions;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TemplatesType, Registry, UIOptionsType } from "./types";
|
|
2
|
+
/** Returns the template with the given `name` from either the `uiSchema` if it is defined or from the `registry`
|
|
3
|
+
* otherwise. NOTE, since `ButtonTemplates` are not overridden in `uiSchema` only those in the `registry` are returned.
|
|
4
|
+
*
|
|
5
|
+
* @param name - The name of the template to fetch, restricted to the keys of `TemplatesType`
|
|
6
|
+
* @param registry - The `Registry` from which to read the template
|
|
7
|
+
* @param [uiOptions={}] - The `UIOptionsType` from which to read an alternate template
|
|
8
|
+
* @returns - The template from either the `uiSchema` or `registry` for the `name`
|
|
9
|
+
*/
|
|
10
|
+
export default function getTemplate<Name extends keyof TemplatesType<T, F>, T = any, F = any>(name: Name, registry: Registry<T, F>, uiOptions?: UIOptionsType<T, F>): TemplatesType<T, F>[Name];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UIOptionsType, UiSchema } from "./types";
|
|
2
|
+
/** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`
|
|
3
|
+
* stripped off.
|
|
4
|
+
*
|
|
5
|
+
* @param [uiSchema={}] - The UI Schema from which to get any `ui:xxx` options
|
|
6
|
+
* @returns - An object containing all of the `ui:xxx` options with the stripped off
|
|
7
|
+
*/
|
|
8
|
+
export default function getUiOptions<T = any, F = any>(uiSchema?: UiSchema<T, F>): UIOptionsType<T, F>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RJSFSchema, Widget, RegistryWidgetsType } from "./types";
|
|
2
|
+
/** Given a schema representing a field to render and either the name or actual `Widget` implementation, returns the
|
|
3
|
+
* React component that is used to render the widget. If the `widget` is already a React component, then it is wrapped
|
|
4
|
+
* with a `MergedWidget`. Otherwise an attempt is made to look up the widget inside of the `registeredWidgets` map based
|
|
5
|
+
* on the schema type and `widget` name. If no widget component can be found an `Error` is thrown.
|
|
6
|
+
*
|
|
7
|
+
* @param schema - The schema for the field
|
|
8
|
+
* @param [widget] - Either the name of the widget OR a `Widget` implementation to use
|
|
9
|
+
* @param [registeredWidgets={}] - A registry of widget name to `Widget` implementation
|
|
10
|
+
* @returns - The `Widget` component to use
|
|
11
|
+
* @throws - An error if there is no `Widget` component that can be returned
|
|
12
|
+
*/
|
|
13
|
+
export default function getWidget<T = any, F = any>(schema: RJSFSchema, widget?: Widget<T, F> | string, registeredWidgets?: RegistryWidgetsType<T, F>): Widget<T, F>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Given a specific `value` attempts to guess the type of a schema element. In the case where we have to implicitly
|
|
2
|
+
* create a schema, it is useful to know what type to use based on the data we are defining.
|
|
3
|
+
*
|
|
4
|
+
* @param value - The value from which to guess the type
|
|
5
|
+
* @returns - The best guess for the object type
|
|
6
|
+
*/
|
|
7
|
+
export default function guessType(value: any): "array" | "string" | "null" | "boolean" | "number" | "object";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RegistryWidgetsType, RJSFSchema, Widget } from "./types";
|
|
2
|
+
/** Detects whether the `widget` exists for the `schema` with the associated `registryWidgets` and returns true if it
|
|
3
|
+
* does, or false if it doesn't.
|
|
4
|
+
*
|
|
5
|
+
* @param schema - The schema for the field
|
|
6
|
+
* @param widget - Either the name of the widget OR a `Widget` implementation to use
|
|
7
|
+
* @param [registeredWidgets={}] - A registry of widget name to `Widget` implementation
|
|
8
|
+
* @returns - True if the widget exists, false otherwise
|
|
9
|
+
*/
|
|
10
|
+
export default function hasWidget<T = any, F = any>(schema: RJSFSchema, widget: Widget<T, F> | string, registeredWidgets?: RegistryWidgetsType<T, F>): boolean;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import allowAdditionalItems from "./allowAdditionalItems";
|
|
2
|
+
import asNumber from "./asNumber";
|
|
3
|
+
import canExpand from "./canExpand";
|
|
4
|
+
import createSchemaUtils from "./createSchemaUtils";
|
|
5
|
+
import dataURItoBlob from "./dataURItoBlob";
|
|
6
|
+
import deepEquals from "./deepEquals";
|
|
7
|
+
import findSchemaDefinition from "./findSchemaDefinition";
|
|
8
|
+
import getInputProps from "./getInputProps";
|
|
9
|
+
import getSchemaType from "./getSchemaType";
|
|
10
|
+
import getSubmitButtonOptions from "./getSubmitButtonOptions";
|
|
11
|
+
import getTemplate from "./getTemplate";
|
|
12
|
+
import getUiOptions from "./getUiOptions";
|
|
13
|
+
import getWidget from "./getWidget";
|
|
14
|
+
import guessType from "./guessType";
|
|
15
|
+
import hasWidget from "./hasWidget";
|
|
16
|
+
import isConstant from "./isConstant";
|
|
17
|
+
import isCustomWidget from "./isCustomWidget";
|
|
18
|
+
import isFixedItems from "./isFixedItems";
|
|
19
|
+
import isObject from "./isObject";
|
|
20
|
+
import localToUTC from "./localToUTC";
|
|
21
|
+
import mergeDefaultsWithFormData from "./mergeDefaultsWithFormData";
|
|
22
|
+
import mergeObjects from "./mergeObjects";
|
|
23
|
+
import mergeSchemas from "./mergeSchemas";
|
|
24
|
+
import optionsList from "./optionsList";
|
|
25
|
+
import orderProperties from "./orderProperties";
|
|
26
|
+
import pad from "./pad";
|
|
27
|
+
import parseDateString from "./parseDateString";
|
|
28
|
+
import processSelectValue from "./processSelectValue";
|
|
29
|
+
import rangeSpec from "./rangeSpec";
|
|
30
|
+
import schemaRequiresTrueValue from "./schemaRequiresTrueValue";
|
|
31
|
+
import shouldRender from "./shouldRender";
|
|
32
|
+
import toConstant from "./toConstant";
|
|
33
|
+
import toDateString from "./toDateString";
|
|
34
|
+
import utcToLocal from "./utcToLocal";
|
|
35
|
+
export * from "./types";
|
|
36
|
+
export * from "./constants";
|
|
37
|
+
export * from "./schema";
|
|
38
|
+
export { allowAdditionalItems, asNumber, canExpand, createSchemaUtils, dataURItoBlob, deepEquals, findSchemaDefinition, getInputProps, getSchemaType, getSubmitButtonOptions, getTemplate, getUiOptions, getWidget, guessType, hasWidget, isConstant, isCustomWidget, isFixedItems, isObject, localToUTC, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionsList, orderProperties, pad, parseDateString, processSelectValue, rangeSpec, schemaRequiresTrueValue, shouldRender, toConstant, toDateString, utcToLocal, };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RJSFSchema } from "./types";
|
|
2
|
+
/** This function checks if the given `schema` matches a single constant value. This happens when either the schema has
|
|
3
|
+
* an `enum` array with a single value or there is a `const` defined.
|
|
4
|
+
*
|
|
5
|
+
* @param schema - The schema for a field
|
|
6
|
+
* @returns - True if the `schema` has a single constant value, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
export default function isConstant(schema: RJSFSchema): boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UiSchema } from "./types";
|
|
2
|
+
/** Checks to see if the `uiSchema` contains the `widget` field and that the widget is not `hidden`
|
|
3
|
+
*
|
|
4
|
+
* @param uiSchema - The UI Schema from which to detect if it is customized
|
|
5
|
+
* @returns - True if the `uiSchema` describes a custom widget, false otherwise
|
|
6
|
+
*/
|
|
7
|
+
export default function isCustomWidget<T = any, F = any>(uiSchema?: UiSchema<T, F>): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RJSFSchema } from "./types";
|
|
2
|
+
/** Detects whether the given `schema` contains fixed items. This is the case when `schema.items` is a non-empty array
|
|
3
|
+
* that only contains objects.
|
|
4
|
+
*
|
|
5
|
+
* @param schema - The schema in which to check for fixed items
|
|
6
|
+
* @returns - True if there are fixed items in the schema, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
export default function isFixedItems(schema: RJSFSchema): boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Determines whether a `thing` is an object for the purposes of RSJF. In this case, `thing` is an object if it has
|
|
2
|
+
* the type `object` but is NOT null, an array or a File.
|
|
3
|
+
*
|
|
4
|
+
* @param thing - The thing to check to see whether it is an object
|
|
5
|
+
* @returns - True if it is a non-null, non-array, non-File object
|
|
6
|
+
*/
|
|
7
|
+
export default function isObject(thing: any): boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Converts a local Date string into a UTC date string
|
|
2
|
+
*
|
|
3
|
+
* @param dateString - The string representation of a date as accepted by the `Date()` constructor
|
|
4
|
+
* @returns - A UTC date string if `dateString` is truthy, otherwise undefined
|
|
5
|
+
*/
|
|
6
|
+
export default function localToUTC(dateString: string): string | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Merges the `defaults` object of type `T` into the `formData` of type `T`
|
|
2
|
+
*
|
|
3
|
+
* When merging defaults and form data, we want to merge in this specific way:
|
|
4
|
+
* - objects are deeply merged
|
|
5
|
+
* - arrays are merged in such a way that:
|
|
6
|
+
* - when the array is set in form data, only array entries set in form data
|
|
7
|
+
* are deeply merged; additional entries from the defaults are ignored
|
|
8
|
+
* - when the array is not set in form data, the default is copied over
|
|
9
|
+
* - scalars are overwritten/set by form data
|
|
10
|
+
*
|
|
11
|
+
* @param defaults - The defaults to merge
|
|
12
|
+
* @param formData - The form data into which the defaults will be merged
|
|
13
|
+
* @returns - The resulting merged form data with defaults
|
|
14
|
+
*/
|
|
15
|
+
export default function mergeDefaultsWithFormData<T = any>(defaults: T, formData: T): T;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GenericObjectType } from "./types";
|
|
2
|
+
/** Recursively merge deeply nested objects.
|
|
3
|
+
*
|
|
4
|
+
* @param obj1 - The first object to merge
|
|
5
|
+
* @param obj2 - The second object to merge
|
|
6
|
+
* @param [concatArrays=false] - Optional flag that, when true, will cause arrays to be concatenated
|
|
7
|
+
* @returns - A new object that is the merge of the two given objects
|
|
8
|
+
*/
|
|
9
|
+
export default function mergeObjects(obj1: GenericObjectType, obj2: GenericObjectType, concatArrays?: boolean): GenericObjectType;
|