From 9876a7683660cf842ce57c4ff2faf729bb2e9566 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Thu, 25 Mar 2021 19:19:14 +0100 Subject: [PATCH] additional macros --- packages/web/src/forms/FormArgument.svelte | 2 +- .../web/src/forms/FormTextFieldRaw.svelte | 7 ++- packages/web/src/freetable/macros.js | 52 +++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/packages/web/src/forms/FormArgument.svelte b/packages/web/src/forms/FormArgument.svelte index 6882a78c..853509c6 100644 --- a/packages/web/src/forms/FormArgument.svelte +++ b/packages/web/src/forms/FormArgument.svelte @@ -12,7 +12,7 @@ {#if arg.type == 'text'} - + {:else if arg.type == 'checkbox'} {:else if arg.type == 'select'} diff --git a/packages/web/src/forms/FormTextFieldRaw.svelte b/packages/web/src/forms/FormTextFieldRaw.svelte index 6e148cee..215c0317 100644 --- a/packages/web/src/forms/FormTextFieldRaw.svelte +++ b/packages/web/src/forms/FormTextFieldRaw.svelte @@ -3,8 +3,13 @@ import TextField from './TextField.svelte'; export let name; + export let defaultValue; const { values, setFieldValue } = getFormContext(); - setFieldValue(name, e.target['value'])} /> + setFieldValue(name, e.target['value'])} +/> diff --git a/packages/web/src/freetable/macros.js b/packages/web/src/freetable/macros.js index f614dba4..dd08b4ab 100644 --- a/packages/web/src/freetable/macros.js +++ b/packages/web/src/freetable/macros.js @@ -58,6 +58,58 @@ return value ? value.toString().replace(new RegExp(rtext, rflags), args.replace ], code: `return modules.lodash[args.type](value)`, }, + { + title: 'Pad left', + name: 'padLeft', + group: 'Text', + args: [ + { + type: 'text', + label: 'Character', + name: 'character', + default: '0', + }, + { + type: 'text', + label: 'Length', + name: 'length', + default: '3', + }, + ], + description: 'Returns string of a specified length in which the beginning of the current string is padded with spaces or other character', + type: 'transformValue', + code: `return modules.lodash.padStart(value, +args.length, args.character)`, + }, + { + title: 'Pad right', + name: 'padRight', + group: 'Text', + args: [ + { + type: 'text', + label: 'Character', + name: 'character', + default: '0', + }, + { + type: 'text', + label: 'Length', + name: 'length', + default: '3', + }, + ], + description: 'Returns string of a specified length in which the end of the current string is padded with spaces or other character', + type: 'transformValue', + code: `return modules.lodash.padEnd(value, +args.length, args.character)`, + }, + { + title: 'Trim', + name: 'trim', + group: 'Text', + description: 'Removes leading and trailing whitespace ', + type: 'transformValue', + code: `return modules.lodash.trim(value)`, + }, { title: 'Row index', name: 'rowIndex',