Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
795b9c8
Added map custom prop type
jonathanalvares9009 Nov 10, 2022
7164cb9
Added attribute custom property type
jonathanalvares9009 Nov 10, 2022
0dfd8c5
Removed map type from SimpleCustomProp type
jonathanalvares9009 Nov 10, 2022
ba96e12
Created a tab body field for map custom prop
jonathanalvares9009 Nov 10, 2022
a53efee
Component was calling EnumList instead of Map changed that
jonathanalvares9009 Nov 10, 2022
a54fe9e
Created Object type custom prop to accept text input
jonathanalvares9009 Nov 10, 2022
b38dfb5
Map custom prop can take all the supported types as field value
jonathanalvares9009 Nov 11, 2022
dacf60d
Moved common functionality from tab body into a new component
jonathanalvares9009 Nov 11, 2022
ed87a17
Created a map type custom prop
jonathanalvares9009 Nov 11, 2022
e7454ea
Made text change generic object values
jonathanalvares9009 Nov 11, 2022
4784896
Now object can store text values
jonathanalvares9009 Nov 11, 2022
7d9f95c
Object can store number type
jonathanalvares9009 Nov 11, 2022
dc7716f
Created a function for create object
jonathanalvares9009 Nov 11, 2022
b7addea
Made the boolean custom type generic
jonathanalvares9009 Nov 11, 2022
3c133ce
Made the color custom prop accept generic property
jonathanalvares9009 Nov 11, 2022
2b8b768
Made external link custom prop accept generic object
jonathanalvares9009 Nov 11, 2022
d5b3cc1
Made internal custom prop accept generic object
jonathanalvares9009 Nov 11, 2022
ac5ffba
Large text custom prop can now accept generic object
jonathanalvares9009 Nov 11, 2022
8d6a0d8
Enum custom prop can now accept generic objects
jonathanalvares9009 Nov 11, 2022
c116eb4
Ability to take generic objects in boolean list
jonathanalvares9009 Nov 12, 2022
5e700ef
EnumList can now accept generic objects
jonathanalvares9009 Nov 12, 2022
d6d503c
List custom prop now can accept generic objects
jonathanalvares9009 Nov 12, 2022
0559144
Number list custom prop can now take generic object
jonathanalvares9009 Nov 12, 2022
c188079
Static asset custom prop can now take generic object
jonathanalvares9009 Nov 12, 2022
65a4392
Static asset list custom prop can take generic objects
jonathanalvares9009 Nov 12, 2022
5696016
Component selector can now accept generic objects
jonathanalvares9009 Nov 12, 2022
9988a18
Console log removed
jonathanalvares9009 Nov 12, 2022
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Object can store number type
  • Loading branch information
jonathanalvares9009 committed Nov 11, 2022
commit 7d9f95c3ccdd403a316fa800d447316f6f0dc40c
33 changes: 27 additions & 6 deletions packages/custom-props-layer/src/components/number/Number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,42 @@ import { useMemo, useCallback } from "react";
import { PropertyContainer } from "../commons/PropertyContainer";
import { Label } from "../commons/Label";
import { NumberInput } from "../commons/NumberInput";

export const Number: React.FC<ComponentProps> = (props) => {
const propValue = useMemo(() => {
return props.customProps[props.propName] || "";
const selector = useMemo(() => {
return props.selector || [];
}, [props]);
const propValue = useMemo(() => {
let currentValue = props.customProps;
for (let prop of selector) {
currentValue = currentValue[prop];
}
return currentValue || 0;
}, [props, selector]);

const callPatchCb = useCallback(
(e: React.ChangeEvent<HTMLInputElement>) => {
const createObject = (fields: string[], value: string | number) => {
const reducer: any = (
acc: string,
item: string,
index: number,
arr: string[]
) => ({
[item]: index + 1 < arr.length ? acc : value,
});
return fields.reduceRight(reducer, {});
};
props.patchCb({
property: {
custom: {
[props.propName]: e.target.value ? parseFloat(e.target.value) : "",
},
custom: createObject(
selector,
e.target.value ? parseFloat(e.target.value) : ""
),
},
});
},
[props]
[props, selector]
);
return (
<PropertyContainer>
Expand Down