add tests for stirngs helpers, fix leftover mistakes from merge

This commit is contained in:
Arman committed 2023-03-23 12:16:02 +01:00
1 parent f55c5865e8
commit e9510db0ba
5 files changed
+122 -4

No files matched your search

+20
View File
@@ -20,3 +20,23 @@ export function capitalize(str: string): string {
export function singular(str: string): string {
return str.replace(/s$/, '');
}
/**
* Convert a dash/underscore/space separated string to camelCase.
*
* @export
* @param {string} str - The string to convert.
* @returns {string} The camelized string.
*/
export function camelize(str: string): string {
if (!str) {
return '';
}
return str
.replace(/[-_\s]+(.)?/g, (_, char: string) => {
return char ? char.toUpperCase() : '';
})
.replace(/^(.)/, (firstChar) => {
return firstChar.toLowerCase();
});
}
@@ -61,7 +61,7 @@
} else updateButtonDisabled = true;
</script>
<Modal size="big" bind:show={showEdit} on:submit={submit} icon={option?.icon}>
<Modal size="big" bind:show={showEdit} onSubmit={submit} icon={option?.icon}>
<svelte:fragment slot="header">
{attr?.type}
{#if attr?.type === 'Relationship'}
@@ -157,7 +157,7 @@
bind:value={data.related}
required
placeholder="Select a collection"
options={collectionList?.collections?.map((n) => ({ value: n.$id, label: n.name })) ?? []} />
options={collections?.map((n) => ({ value: n.$id, label: n.name })) ?? []} />
{#if data?.related}
{@const selectedCol = collections?.find((n) => n.$id === data.related)}
@@ -7,7 +7,7 @@
import { Button, Form, InputSelectSearch, InputText } from '$lib/elements/forms';
import { difference } from '$lib/helpers/array';
import { addNotification } from '$lib/stores/notifications';
import { sdkForProject } from '$lib/stores/sdk';
import { sdk } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import { attributes, collection } from '../store';
@@ -57,7 +57,7 @@
(displayNames?.length && !displayNames[displayNames?.length - 1]);
</script>
<Form on:submit={updateDisplayName}>
<Form onSubmit={updateDisplayName}>
<CardGrid>
<Heading tag="h6" size="7">Display Name</Heading>
<p class="text">