additional macros

This commit is contained in:
Jan Prochazka 2021-03-25 19:19:14 +01:00
parent 952bdc4baa
commit 9876a76836
3 changed files with 59 additions and 2 deletions

View File

@ -12,7 +12,7 @@
</script>
{#if arg.type == 'text'}
<FormTextField label={arg.label} {name} />
<FormTextField label={arg.label} {name} defaultValue={arg.default} />
{:else if arg.type == 'checkbox'}
<FormCheckboxField label={arg.label} {name} defaultValue={arg.default} />
{:else if arg.type == 'select'}

View File

@ -3,8 +3,13 @@
import TextField from './TextField.svelte';
export let name;
export let defaultValue;
const { values, setFieldValue } = getFormContext();
</script>
<TextField {...$$restProps} value={$values[name]} on:input={e => setFieldValue(name, e.target['value'])} />
<TextField
{...$$restProps}
value={$values[name] ?? defaultValue}
on:input={e => setFieldValue(name, e.target['value'])}
/>

View File

@ -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',