@rjsf/utils 5.1.0 → 5.2.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/dist/index.d.ts +92 -1
- package/dist/utils.cjs.development.js +102 -0
- package/dist/utils.cjs.development.js.map +1 -1
- package/dist/utils.cjs.production.min.js +1 -1
- package/dist/utils.cjs.production.min.js.map +1 -1
- package/dist/utils.esm.js +101 -1
- package/dist/utils.esm.js.map +1 -1
- package/dist/utils.umd.development.js +102 -0
- package/dist/utils.umd.development.js.map +1 -1
- package/dist/utils.umd.production.min.js +1 -1
- package/dist/utils.umd.production.min.js.map +1 -1
- package/package.json +2 -2
|
@@ -1852,6 +1852,36 @@
|
|
|
1852
1852
|
};
|
|
1853
1853
|
}
|
|
1854
1854
|
|
|
1855
|
+
/** Potentially substitutes all replaceable parameters with the associated value(s) from the `params` if available. When
|
|
1856
|
+
* a `params` array is provided, each value in the array is used to replace any of the replaceable parameters in the
|
|
1857
|
+
* `inputString` using the `%1`, `%2`, etc. replacement specifiers.
|
|
1858
|
+
*
|
|
1859
|
+
* @param inputString - The string which will be potentially updated with replacement parameters
|
|
1860
|
+
* @param params - The optional list of replaceable parameter values to substitute into the english string
|
|
1861
|
+
* @returns - The updated string with any replacement specifiers replaced
|
|
1862
|
+
*/
|
|
1863
|
+
function replaceStringParameters(inputString, params) {
|
|
1864
|
+
var output = inputString;
|
|
1865
|
+
if (Array.isArray(params)) {
|
|
1866
|
+
params.forEach(function (param, index) {
|
|
1867
|
+
output = output.replace("%" + (index + 1), param);
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1870
|
+
return output;
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
/** Translates a `TranslatableString` value `stringToTranslate` into english. When a `params` array is provided, each
|
|
1874
|
+
* value in the array is used to replace any of the replaceable parameters in the `stringToTranslate` using the `%1`,
|
|
1875
|
+
* `%2`, etc. replacement specifiers.
|
|
1876
|
+
*
|
|
1877
|
+
* @param stringToTranslate - The `TranslatableString` value to convert to english
|
|
1878
|
+
* @param params - The optional list of replaceable parameter values to substitute into the english string
|
|
1879
|
+
* @returns - The `stringToTranslate` itself with any replaceable parameter values substituted
|
|
1880
|
+
*/
|
|
1881
|
+
function englishStringTranslator(stringToTranslate, params) {
|
|
1882
|
+
return replaceStringParameters(stringToTranslate, params);
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1855
1885
|
/** Returns the value(s) from `allEnumOptions` at the index(es) provided by `valueIndex`. If `valueIndex` is not an
|
|
1856
1886
|
* array AND the index is not valid for `allEnumOptions`, `emptyValue` is returned. If `valueIndex` is an array, AND it
|
|
1857
1887
|
* contains an invalid index, the returned array will have the resulting undefined values filtered out, leaving only
|
|
@@ -2671,6 +2701,76 @@
|
|
|
2671
2701
|
return yyyy + "-" + MM + "-" + dd + "T" + hh + ":" + mm + ":" + ss + "." + SSS;
|
|
2672
2702
|
}
|
|
2673
2703
|
|
|
2704
|
+
/** An enumeration of all the translatable strings used by `@rjsf/core` and its themes. The value of each of the
|
|
2705
|
+
* enumeration keys is expected to be the actual english string. Some strings contain replaceable parameter values
|
|
2706
|
+
* as indicated by `%1`, `%2`, etc. The number after the `%` indicates the order of the parameter. The ordering of
|
|
2707
|
+
* parameters is important because some languages may choose to put the second parameter before the first in its
|
|
2708
|
+
* translation. Also, some strings are rendered using `markdown-to-jsx` and thus support markdown and inline html.
|
|
2709
|
+
*/
|
|
2710
|
+
exports.TranslatableString = void 0;
|
|
2711
|
+
(function (TranslatableString) {
|
|
2712
|
+
/** Fallback title of an array item, used by ArrayField */
|
|
2713
|
+
TranslatableString["ArrayItemTitle"] = "Item";
|
|
2714
|
+
/** Missing items reason, used by ArrayField */
|
|
2715
|
+
TranslatableString["MissingItems"] = "Missing items definition";
|
|
2716
|
+
/** Yes label, used by BooleanField */
|
|
2717
|
+
TranslatableString["YesLabel"] = "Yes";
|
|
2718
|
+
/** No label, used by BooleanField */
|
|
2719
|
+
TranslatableString["NoLabel"] = "No";
|
|
2720
|
+
/** Close label, used by ErrorList */
|
|
2721
|
+
TranslatableString["CloseLabel"] = "Close";
|
|
2722
|
+
/** Errors label, used by ErrorList */
|
|
2723
|
+
TranslatableString["ErrorsLabel"] = "Errors";
|
|
2724
|
+
/** New additionalProperties string default value, used by ObjectField */
|
|
2725
|
+
TranslatableString["NewStringDefault"] = "New Value";
|
|
2726
|
+
/** Add button title, used by AddButton */
|
|
2727
|
+
TranslatableString["AddButton"] = "Add";
|
|
2728
|
+
/** Add button title, used by AddButton */
|
|
2729
|
+
TranslatableString["AddItemButton"] = "Add Item";
|
|
2730
|
+
/** Move down button title, used by IconButton */
|
|
2731
|
+
TranslatableString["MoveDownButton"] = "Move down";
|
|
2732
|
+
/** Move up button title, used by IconButton */
|
|
2733
|
+
TranslatableString["MoveUpButton"] = "Move up";
|
|
2734
|
+
/** Remove button title, used by IconButton */
|
|
2735
|
+
TranslatableString["RemoveButton"] = "Remove";
|
|
2736
|
+
/** Now label, used by AltDateWidget */
|
|
2737
|
+
TranslatableString["NowLabel"] = "Now";
|
|
2738
|
+
/** Clear label, used by AltDateWidget */
|
|
2739
|
+
TranslatableString["ClearLabel"] = "Clear";
|
|
2740
|
+
/** Aria date label, used by DateWidget */
|
|
2741
|
+
TranslatableString["AriaDateLabel"] = "Select a date";
|
|
2742
|
+
/** Decrement button aria label, used by UpDownWidget */
|
|
2743
|
+
TranslatableString["DecrementAriaLabel"] = "Decrease value by 1";
|
|
2744
|
+
/** Increment button aria label, used by UpDownWidget */
|
|
2745
|
+
TranslatableString["IncrementAriaLabel"] = "Increase value by 1";
|
|
2746
|
+
// Strings with replaceable parameters
|
|
2747
|
+
/** Unknown field type reason, where %1 will be replaced with the type as provided by SchemaField */
|
|
2748
|
+
TranslatableString["UnknownFieldType"] = "Unknown field type %1";
|
|
2749
|
+
/** Option prefix, where %1 will be replaced with the option index as provided by MultiSchemaField */
|
|
2750
|
+
TranslatableString["OptionPrefix"] = "Option %1";
|
|
2751
|
+
/** Option prefix, where %1 and %2 will be replaced by the schema title and option index, respectively as provided by
|
|
2752
|
+
* MultiSchemaField
|
|
2753
|
+
*/
|
|
2754
|
+
TranslatableString["TitleOptionPrefix"] = "%1 option %2";
|
|
2755
|
+
/** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */
|
|
2756
|
+
TranslatableString["KeyLabel"] = "%1 Key";
|
|
2757
|
+
// Strings with replaceable parameters AND/OR that support markdown and html
|
|
2758
|
+
/** Unsupported field schema, used by UnsupportedField */
|
|
2759
|
+
TranslatableString["UnsupportedField"] = "Unsupported field schema.";
|
|
2760
|
+
/** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField */
|
|
2761
|
+
TranslatableString["UnsupportedFieldWithId"] = "Unsupported field schema for field <code>%1</code>.";
|
|
2762
|
+
/** Unsupported field schema, where %1 will be replaced by the reason string as provided by UnsupportedField */
|
|
2763
|
+
TranslatableString["UnsupportedFieldWithReason"] = "Unsupported field schema: <em>%1</em>.";
|
|
2764
|
+
/** Unsupported field schema, where %1 and %2 will be replaced by the idSchema.$id and reason strings, respectively,
|
|
2765
|
+
* as provided by UnsupportedField
|
|
2766
|
+
*/
|
|
2767
|
+
TranslatableString["UnsupportedFieldWithIdAndReason"] = "Unsupported field schema for field <code>%1</code>: <em>%2</em>.";
|
|
2768
|
+
/** File name, type and size info, where %1, %2 and %3 will be replaced by the file name, file type and file size as
|
|
2769
|
+
* provided by FileWidget
|
|
2770
|
+
*/
|
|
2771
|
+
TranslatableString["FilesInfo"] = "<strong>%1</strong> (%2, %3 bytes)";
|
|
2772
|
+
})(exports.TranslatableString || (exports.TranslatableString = {}));
|
|
2773
|
+
|
|
2674
2774
|
exports.ADDITIONAL_PROPERTIES_KEY = ADDITIONAL_PROPERTIES_KEY;
|
|
2675
2775
|
exports.ADDITIONAL_PROPERTY_FLAG = ADDITIONAL_PROPERTY_FLAG;
|
|
2676
2776
|
exports.ALL_OF_KEY = ALL_OF_KEY;
|
|
@@ -2702,6 +2802,7 @@
|
|
|
2702
2802
|
exports.dataURItoBlob = dataURItoBlob;
|
|
2703
2803
|
exports.deepEquals = deepEquals;
|
|
2704
2804
|
exports.descriptionId = descriptionId;
|
|
2805
|
+
exports.englishStringTranslator = englishStringTranslator;
|
|
2705
2806
|
exports.enumOptionsDeselectValue = enumOptionsDeselectValue;
|
|
2706
2807
|
exports.enumOptionsIndexForValue = enumOptionsIndexForValue;
|
|
2707
2808
|
exports.enumOptionsIsSelected = enumOptionsIsSelected;
|
|
@@ -2742,6 +2843,7 @@
|
|
|
2742
2843
|
exports.pad = pad;
|
|
2743
2844
|
exports.parseDateString = parseDateString;
|
|
2744
2845
|
exports.rangeSpec = rangeSpec;
|
|
2846
|
+
exports.replaceStringParameters = replaceStringParameters;
|
|
2745
2847
|
exports.retrieveSchema = retrieveSchema;
|
|
2746
2848
|
exports.sanitizeDataForNewSchema = sanitizeDataForNewSchema;
|
|
2747
2849
|
exports.schemaRequiresTrueValue = schemaRequiresTrueValue;
|