@nolwenture/formik-jsonschema-form 0.14.0 → 0.15.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/fields/ArrayField.js +11 -28
- package/dist/fields/StringField.js +5 -1
- package/dist/styledComponents.d.ts +2 -3
- package/dist/styledComponents.js +3 -20
- package/dist/types.d.ts +0 -11
- package/dist/types.js +0 -7
- package/dist/utils/getTypes.d.ts +1 -1
- package/dist/utils/orderByUiSchema.js +7 -49
- package/package.json +1 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useContext, useMemo } from "react";
|
|
3
2
|
import { useField } from "formik";
|
|
3
|
+
import { useContext, useMemo } from "react";
|
|
4
4
|
import { FormRegistry } from "../Form";
|
|
5
|
-
import { ArrayFieldButtonPurpose } from "../types";
|
|
6
5
|
import { useExtractUiSchema, useSetDefault } from "../hooks";
|
|
7
|
-
import { FieldInput
|
|
6
|
+
import { FieldInput } from "../styledComponents";
|
|
8
7
|
import { FieldTemplate } from "../templates";
|
|
9
8
|
import { getEnums } from "../utils";
|
|
10
9
|
const appendArray = (values) => {
|
|
@@ -32,7 +31,8 @@ const moveInArray = (values, index, direction) => {
|
|
|
32
31
|
}
|
|
33
32
|
};
|
|
34
33
|
export const ArrayField = (props) => {
|
|
35
|
-
|
|
34
|
+
var _a, _b, _c, _d;
|
|
35
|
+
const { fields: { SchemaField }, templates: { ArrayFieldTemplate }, components: { ArrayFieldItem, ArrayFieldList, ArrayFieldItemButtons, ArrayFieldAddButton, ArrayFieldRemoveButton, ArrayFieldUpButton, ArrayFieldDownButton, }, useItemsAsAdditionalItems, } = useContext(FormRegistry);
|
|
36
36
|
useSetDefault(props);
|
|
37
37
|
const { name, schema, uiSchema } = props;
|
|
38
38
|
const { type, props: inputProps } = useExtractUiSchema(uiSchema);
|
|
@@ -98,28 +98,11 @@ export const ArrayField = (props) => {
|
|
|
98
98
|
// Backwards compatibility ends
|
|
99
99
|
const { disabled } = useExtractUiSchema(uiSchema);
|
|
100
100
|
const valueArray = Array.isArray(value) ? value : undefined;
|
|
101
|
-
return schema.anyOf !== undefined ? (_jsx(FieldTemplate, Object.assign({}, props, { children: _jsx(FieldInput, Object.assign({ type }, inputProps, { name: name, formikAs: "select", multiple: (enums === null || enums === void 0 ? void 0 : enums.type) === "multiSelect", children: enums === null || enums === void 0 ? void 0 : enums.values.map((option, index) => (_jsx("option", { value: option.const, children: option.title }, index))) })) }))) : (_jsxs(ArrayFieldTemplate, Object.assign({}, props, { children: [_jsxs(ArrayFieldList, { children: [(items || []).map((itemSchema, index) => (_jsx(ArrayFieldItem, { children: _jsx(SchemaField, { name: `${name}[${index}]`, schema: typeof itemSchema !== "boolean" ? itemSchema : {}, uiSchema: (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema[index]) || (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema.items), forceDefaultValue: true }) }, index))), ((valueArray === null || valueArray === void 0 ? void 0 : valueArray.slice(items.length)) || []).map((_, index) =>
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
onClick: () => setValue(removeFromArray(value, index + items.length)),
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
index > 0 &&
|
|
109
|
-
GetArrayFieldButton({
|
|
110
|
-
purpose: ArrayFieldButtonPurpose.MOVE_UP,
|
|
111
|
-
onClick: () => setValue(moveInArray(value, index + items.length, -1)),
|
|
112
|
-
uiSchema,
|
|
113
|
-
}), value.length > 1 &&
|
|
114
|
-
index < (value === null || value === void 0 ? void 0 : value.slice(items.length).length) - 1 &&
|
|
115
|
-
GetArrayFieldButton({
|
|
116
|
-
purpose: ArrayFieldButtonPurpose.MOVE_DOWN,
|
|
117
|
-
onClick: () => setValue(moveInArray(value, index + items.length, 1)),
|
|
118
|
-
uiSchema,
|
|
119
|
-
})] })] }, index)))] }), additionalItems &&
|
|
120
|
-
GetArrayFieldButton({
|
|
121
|
-
purpose: ArrayFieldButtonPurpose.ADD,
|
|
122
|
-
onClick: () => setValue(appendArray(value)),
|
|
123
|
-
uiSchema,
|
|
124
|
-
})] })));
|
|
101
|
+
return schema.anyOf !== undefined ? (_jsx(FieldTemplate, Object.assign({}, props, { children: _jsx(FieldInput, Object.assign({ type }, inputProps, { name: name, formikAs: "select", multiple: (enums === null || enums === void 0 ? void 0 : enums.type) === "multiSelect", children: enums === null || enums === void 0 ? void 0 : enums.values.map((option, index) => (_jsx("option", { value: option.const, children: option.title }, index))) })) }))) : (_jsxs(ArrayFieldTemplate, Object.assign({}, props, { children: [_jsxs(ArrayFieldList, { children: [(items || []).map((itemSchema, index) => (_jsx(ArrayFieldItem, { children: _jsx(SchemaField, { name: `${name}[${index}]`, schema: typeof itemSchema !== "boolean" ? itemSchema : {}, uiSchema: (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema[index]) || (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema.items), forceDefaultValue: true }) }, index))), ((valueArray === null || valueArray === void 0 ? void 0 : valueArray.slice(items.length)) || []).map((_, index) => {
|
|
102
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
103
|
+
return (_jsxs(ArrayFieldItem, { children: [_jsx(SchemaField, { name: `${name}[${index + items.length}]`, schema: additionalItems && typeof additionalItems !== "boolean"
|
|
104
|
+
? additionalItems
|
|
105
|
+
: {}, uiSchema: Object.assign({ disabled }, ((uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema[index + items.length]) || (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema.items))) }), _jsxs(ArrayFieldItemButtons, { children: [_jsx(ArrayFieldRemoveButton, Object.assign({}, ((_b = (_a = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:removeButtonOptions"]) === null || _a === void 0 ? void 0 : _a.props) !== null && _b !== void 0 ? _b : {}), { onClick: () => setValue(removeFromArray(value, index + items.length)), children: (_d = (_c = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:removeButtonOptions"]) === null || _c === void 0 ? void 0 : _c.content) !== null && _d !== void 0 ? _d : "-" })), value.length > 1 && index > 0 && (_jsx(ArrayFieldUpButton, Object.assign({}, ((_f = (_e = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:upButtonOptions"]) === null || _e === void 0 ? void 0 : _e.props) !== null && _f !== void 0 ? _f : {}), { onClick: () => setValue(moveInArray(value, index + items.length, -1)), children: (_h = (_g = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:upButtonOptions"]) === null || _g === void 0 ? void 0 : _g.content) !== null && _h !== void 0 ? _h : "↑" }))), value.length > 1 &&
|
|
106
|
+
index < (value === null || value === void 0 ? void 0 : value.slice(items.length).length) - 1 && (_jsx(ArrayFieldDownButton, Object.assign({}, ((_k = (_j = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:downButtonOptions"]) === null || _j === void 0 ? void 0 : _j.props) !== null && _k !== void 0 ? _k : {}), { onClick: () => setValue(moveInArray(value, index + items.length, 1)), children: (_m = (_l = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:downButtonOptions"]) === null || _l === void 0 ? void 0 : _l.content) !== null && _m !== void 0 ? _m : "↓" })))] })] }, index));
|
|
107
|
+
})] }), additionalItems && (_jsx(ArrayFieldAddButton, Object.assign({}, ((_b = (_a = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:addButtonOptions"]) === null || _a === void 0 ? void 0 : _a.props) !== null && _b !== void 0 ? _b : {}), { onClick: () => setValue(appendArray(value)), children: (_d = (_c = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:addButtonOptions"]) === null || _c === void 0 ? void 0 : _c.content) !== null && _d !== void 0 ? _d : "+" })))] })));
|
|
125
108
|
};
|
|
@@ -12,7 +12,11 @@ export const StringField = (props) => {
|
|
|
12
12
|
const enums = useMemo(() => getEnums(props), [props]);
|
|
13
13
|
switch (enums === null || enums === void 0 ? void 0 : enums.type) {
|
|
14
14
|
case "select":
|
|
15
|
-
return (_jsx(FieldTemplate, Object.assign({}, props, { children: _jsxs(FieldInput, Object.assign({ type }, inputProps, { name: name, formikAs: "select", children: [_jsx("option", Object.assign({ value: "",
|
|
15
|
+
return (_jsx(FieldTemplate, Object.assign({}, props, { children: _jsxs(FieldInput, Object.assign({ type }, inputProps, { name: name, formikAs: "select", children: [_jsx("option", Object.assign({ value: "",
|
|
16
|
+
// If both are true, the first enum will be "selected"
|
|
17
|
+
// and leads to annoying and misleading UX.
|
|
18
|
+
// These defaults will lead to an empty, "nothing selected" component.
|
|
19
|
+
disabled: false,
|
|
16
20
|
hidden: true }, (_a = uiSchema["ui:placeholderOptionOptions"]) === null || _a === void 0 ? void 0 : _a.props, { children: placeholder })), enums === null || enums === void 0 ? void 0 : enums.values.map((option, index) => (_jsx("option", { value: option.const, children: option.title }, index)))] })) })));
|
|
17
21
|
default:
|
|
18
22
|
return (_jsx(FieldTemplate, Object.assign({}, props, { children: _jsx(FieldInput, Object.assign({ type,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="hoist-non-react-statics" />
|
|
2
|
-
import type {
|
|
3
|
-
import React from "react";
|
|
2
|
+
import type { ClickableProps, InfoFieldButtonProps, MultipleChoiceFieldProps, ObjectFieldButtonProps, RadioButtonFieldProps, SelectFieldProps, TextAreaInputFieldProps, ToggleSwitchFieldProps } from "./types";
|
|
4
3
|
import * as formik from "formik";
|
|
4
|
+
import React from "react";
|
|
5
5
|
export declare const Form: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<Omit<React.DetailedHTMLProps<React.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref"> & React.RefAttributes<HTMLFormElement>, "ref"> & {
|
|
6
6
|
ref?: ((instance: HTMLFormElement | null) => void) | React.RefObject<HTMLFormElement> | null | undefined;
|
|
7
7
|
}, never>> & Omit<React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref"> & React.RefAttributes<HTMLFormElement>>, keyof React.Component<any, {}, any>>;
|
|
@@ -74,7 +74,6 @@ export declare const ArrayFieldAddButton: import("styled-components").IStyledCom
|
|
|
74
74
|
}, never>, never>> & Omit<import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, never>, "ref"> & {
|
|
75
75
|
ref?: ((instance: HTMLAnchorElement | null) => void) | React.RefObject<HTMLAnchorElement> | null | undefined;
|
|
76
76
|
}, never>> & Omit<import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, never>>, keyof React.Component<any, {}, any>>, keyof React.Component<any, {}, any>>;
|
|
77
|
-
export declare const GetArrayFieldButton: ({ purpose, onClick, uiSchema, }: ArrayFieldButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
78
77
|
export declare const FieldWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
|
79
78
|
export declare const FieldTitle: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, never>>;
|
|
80
79
|
export declare const FieldDescription: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, never>>;
|
package/dist/styledComponents.js
CHANGED
|
@@ -10,11 +10,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { useContext, useState } from "react";
|
|
14
|
-
import styled from "styled-components";
|
|
15
13
|
import * as formik from "formik";
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
14
|
+
import { useState } from "react";
|
|
15
|
+
import styled from "styled-components";
|
|
16
|
+
import { ObjectFieldButtonPurpose } from "./types";
|
|
18
17
|
import { getStyle } from "./utils/getStyle";
|
|
19
18
|
export const Form = styled(formik.Form) ``;
|
|
20
19
|
export const FormButtonWrapper = styled.div ``;
|
|
@@ -70,22 +69,6 @@ export const ArrayFieldUpButton = styled(ArrayFieldLineButton) ``;
|
|
|
70
69
|
export const ArrayFieldDownButton = styled(ArrayFieldLineButton) ``;
|
|
71
70
|
export const ArrayFieldRemoveButton = styled(ArrayFieldLineButton) ``;
|
|
72
71
|
export const ArrayFieldAddButton = styled(ArrayFieldButton) ``;
|
|
73
|
-
export const GetArrayFieldButton = ({ purpose, onClick, uiSchema, }) => {
|
|
74
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
75
|
-
const { components: { ArrayFieldAddButton, ArrayFieldRemoveButton, ArrayFieldUpButton, ArrayFieldDownButton, }, } = useContext(FormRegistry);
|
|
76
|
-
switch (purpose) {
|
|
77
|
-
case ArrayFieldButtonPurpose.ADD:
|
|
78
|
-
return (_jsx(ArrayFieldAddButton, Object.assign({}, ((_b = (_a = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:addButtonOptions"]) === null || _a === void 0 ? void 0 : _a.props) !== null && _b !== void 0 ? _b : {}), { onClick: onClick, children: (_d = (_c = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:addButtonOptions"]) === null || _c === void 0 ? void 0 : _c.content) !== null && _d !== void 0 ? _d : "+" })));
|
|
79
|
-
case ArrayFieldButtonPurpose.REMOVE:
|
|
80
|
-
return (_jsx(ArrayFieldRemoveButton, Object.assign({}, ((_f = (_e = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:removeButtonOptions"]) === null || _e === void 0 ? void 0 : _e.props) !== null && _f !== void 0 ? _f : {}), { onClick: onClick, children: (_h = (_g = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:removeButtonOptions"]) === null || _g === void 0 ? void 0 : _g.content) !== null && _h !== void 0 ? _h : "-" })));
|
|
81
|
-
case ArrayFieldButtonPurpose.MOVE_UP:
|
|
82
|
-
return (_jsx(ArrayFieldUpButton, Object.assign({}, ((_k = (_j = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:upButtonOptions"]) === null || _j === void 0 ? void 0 : _j.props) !== null && _k !== void 0 ? _k : {}), { onClick: onClick, children: (_m = (_l = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:upButtonOptions"]) === null || _l === void 0 ? void 0 : _l.content) !== null && _m !== void 0 ? _m : "↑" })));
|
|
83
|
-
case ArrayFieldButtonPurpose.MOVE_DOWN:
|
|
84
|
-
return (_jsx(ArrayFieldDownButton, Object.assign({}, ((_p = (_o = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:downButtonOptions"]) === null || _o === void 0 ? void 0 : _o.props) !== null && _p !== void 0 ? _p : {}), { onClick: onClick, children: (_r = (_q = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:downButtonOptions"]) === null || _q === void 0 ? void 0 : _q.content) !== null && _r !== void 0 ? _r : "↓" })));
|
|
85
|
-
default:
|
|
86
|
-
return (_jsx(ArrayFieldButton, Object.assign({}, ((_t = (_s = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:customButtonOptions"]) === null || _s === void 0 ? void 0 : _s.props) !== null && _t !== void 0 ? _t : {}), { onClick: onClick, children: (_v = (_u = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema["ui:customButtonOptions"]) === null || _u === void 0 ? void 0 : _u.content) !== null && _v !== void 0 ? _v : "" })));
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
72
|
export const FieldWrapper = styled.div `
|
|
90
73
|
margin: 0.5rem 0;
|
|
91
74
|
`;
|
package/dist/types.d.ts
CHANGED
|
@@ -159,17 +159,6 @@ export type ObjectFieldButtonProps = {
|
|
|
159
159
|
onClick: () => void;
|
|
160
160
|
uiSchema: UiSchema;
|
|
161
161
|
};
|
|
162
|
-
export declare enum ArrayFieldButtonPurpose {
|
|
163
|
-
ADD = 0,
|
|
164
|
-
REMOVE = 1,
|
|
165
|
-
MOVE_UP = 2,
|
|
166
|
-
MOVE_DOWN = 3
|
|
167
|
-
}
|
|
168
|
-
export type ArrayFieldButtonProps = {
|
|
169
|
-
purpose: ArrayFieldButtonPurpose;
|
|
170
|
-
onClick: () => void;
|
|
171
|
-
uiSchema: UiSchema;
|
|
172
|
-
};
|
|
173
162
|
export type InfoFieldButtonProps = {
|
|
174
163
|
label?: React.ReactNode;
|
|
175
164
|
content: React.ReactNode;
|
package/dist/types.js
CHANGED
|
@@ -5,10 +5,3 @@ export var ObjectFieldButtonPurpose;
|
|
|
5
5
|
ObjectFieldButtonPurpose[ObjectFieldButtonPurpose["MOVE_UP"] = 2] = "MOVE_UP";
|
|
6
6
|
ObjectFieldButtonPurpose[ObjectFieldButtonPurpose["MOVE_DOWN"] = 3] = "MOVE_DOWN";
|
|
7
7
|
})(ObjectFieldButtonPurpose || (ObjectFieldButtonPurpose = {}));
|
|
8
|
-
export var ArrayFieldButtonPurpose;
|
|
9
|
-
(function (ArrayFieldButtonPurpose) {
|
|
10
|
-
ArrayFieldButtonPurpose[ArrayFieldButtonPurpose["ADD"] = 0] = "ADD";
|
|
11
|
-
ArrayFieldButtonPurpose[ArrayFieldButtonPurpose["REMOVE"] = 1] = "REMOVE";
|
|
12
|
-
ArrayFieldButtonPurpose[ArrayFieldButtonPurpose["MOVE_UP"] = 2] = "MOVE_UP";
|
|
13
|
-
ArrayFieldButtonPurpose[ArrayFieldButtonPurpose["MOVE_DOWN"] = 3] = "MOVE_DOWN";
|
|
14
|
-
})(ArrayFieldButtonPurpose || (ArrayFieldButtonPurpose = {}));
|
package/dist/utils/getTypes.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Schema } from "../types";
|
|
2
2
|
export declare const isObject: (object: any) => boolean;
|
|
3
3
|
export declare const getDefaultValueForType: (type: Schema["type"]) => {} | null;
|
|
4
|
-
export declare const guessType: (value: any) => "
|
|
4
|
+
export declare const guessType: (value: any) => "object" | "string" | "number" | "boolean" | "array" | "null";
|
|
5
5
|
export declare const getSchemaType: (schema: Schema) => import("json-schema").JSONSchema7TypeName | import("json-schema").JSONSchema7TypeName[] | undefined;
|
|
@@ -10,58 +10,16 @@ export function orderByUiSchema(order, allProperties) {
|
|
|
10
10
|
return undefined;
|
|
11
11
|
}
|
|
12
12
|
function orderWithAsterisk(order, allProperties) {
|
|
13
|
-
//to avoid issues when asterisk or other strings were wrongly given multiple times
|
|
14
13
|
const orderWithoutDuplicates = [...new Set(order)];
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
? orderWithoutDuplicates.slice(indexOfAsterisk + 1, orderWithoutDuplicates.length)
|
|
21
|
-
: undefined;
|
|
22
|
-
let asteriskArray = [];
|
|
23
|
-
let finalOrderedArray = [];
|
|
24
|
-
if (elementsBeforeAsterisk === undefined &&
|
|
25
|
-
elementsAfterAsterisk === undefined) {
|
|
26
|
-
finalOrderedArray = allProperties;
|
|
27
|
-
}
|
|
28
|
-
if (elementsBeforeAsterisk !== undefined) {
|
|
29
|
-
finalOrderedArray = finalOrderedArray.concat(elementsBeforeAsterisk);
|
|
30
|
-
allProperties.map((property) => {
|
|
31
|
-
elementsBeforeAsterisk.map((e) => {
|
|
32
|
-
if (e !== property) {
|
|
33
|
-
asteriskArray.push(property);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
if (elementsAfterAsterisk === undefined) {
|
|
38
|
-
finalOrderedArray = finalOrderedArray.concat(asteriskArray);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
if (elementsAfterAsterisk !== undefined) {
|
|
42
|
-
if (asteriskArray.length === 0) {
|
|
43
|
-
allProperties.map((property) => {
|
|
44
|
-
elementsAfterAsterisk.map((e) => {
|
|
45
|
-
if (e !== property) {
|
|
46
|
-
asteriskArray.push(property);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
finalOrderedArray = finalOrderedArray.concat(asteriskArray);
|
|
51
|
-
finalOrderedArray = finalOrderedArray.concat(elementsAfterAsterisk);
|
|
14
|
+
const finalOrderedArray = [];
|
|
15
|
+
orderWithoutDuplicates.forEach((element) => {
|
|
16
|
+
if (element === "*") {
|
|
17
|
+
const propertiesWithoutOrder = allProperties.filter((prop) => !orderWithoutDuplicates.includes(prop));
|
|
18
|
+
finalOrderedArray.push(...propertiesWithoutOrder);
|
|
52
19
|
}
|
|
53
20
|
else {
|
|
54
|
-
|
|
55
|
-
elementsAfterAsterisk.map((e) => {
|
|
56
|
-
if (e === property) {
|
|
57
|
-
const index = asteriskArray.indexOf(property);
|
|
58
|
-
asteriskArray.splice(index, 1);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
finalOrderedArray = finalOrderedArray.concat(asteriskArray);
|
|
63
|
-
finalOrderedArray = finalOrderedArray.concat(elementsAfterAsterisk);
|
|
21
|
+
finalOrderedArray.push(element);
|
|
64
22
|
}
|
|
65
|
-
}
|
|
23
|
+
});
|
|
66
24
|
return finalOrderedArray;
|
|
67
25
|
}
|