PromucFlow_constructor/app/client/src/widgets/SelectWidget/widget/parseDerivedProperties.ts
Tolulope Adetula ef956ecad0
feat: Select defaultValue Validation Check for ServerSide Filtering(On/Off) (#15133)
* feat: defualt value check

* fix: Empty commit trigger deploy

* Fix: add more tests

* fix: improve validation

* Feat: improve jest test

* fix: more tests

* Fix: add github link

* Update app/client/src/widgets/SelectWidget/widget/index.tsx

Co-authored-by: ashit-rath <ashit@appsmith.com>

* fix: add more comment to issue

* fix: failing test

* fix: cypress config

* Fix: empty commit

* fix: select issue

* Fix: failing tests

* fix: failing Tests

Co-authored-by: ashit-rath <ashit@appsmith.com>
Co-authored-by: somangshu <somangshu.goswami1508@gmail.com>
2022-08-01 06:02:48 +01:00

36 lines
965 B
TypeScript

// @ts-expect-error: loader types not available
import widgetPropertyFns from "!!raw-loader!./derived.js";
// TODO(abhinav):
// Add unit test cases
// Handle edge cases
// Error out on wrong values
const derivedProperties: any = {};
// const regex = /(\w+):\s?\(props\)\s?=>\s?{([\w\W]*?)},/gim;
const regex = /(\w+):\s?\(props, moment, _\)\s?=>\s?{([\w\W\n]*?)},\n?\s+?\/\//gim;
let m;
while ((m = regex.exec((widgetPropertyFns as unknown) as string)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
let key = "";
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
if (groupIndex === 1) {
key = match;
}
if (groupIndex === 2) {
derivedProperties[key] = match
.trim()
.replace(/\n/g, "")
.replace(/props\./g, "this.");
}
});
}
export default derivedProperties;