Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DateField): Add support for class and classes props #244

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/silver-penguins-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte-ux': minor
---

Add support for passing `class` and `classes` props to the DateField component
13 changes: 12 additions & 1 deletion packages/svelte-ux/src/lib/components/DateField.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte';
import { createEventDispatcher, type ComponentProps } from 'svelte';
import { parse as parseDate } from 'date-fns';
import { PeriodType } from '../utils';
import { getComponentSettings, getSettings } from './settings';
import { cls } from '../utils/styles';

import Field from './Field.svelte';

Expand All @@ -21,6 +22,11 @@
$: actualFormat = format ?? $format_ux.settings.formats.dates.baseParsing ?? 'MM/dd/yyyy';
$: actualMask = mask ?? actualFormat.toLowerCase();

export let classes: {
root?: string;
field?: ComponentProps<Field>['classes'];
} = {};

// Field props
export let label = '';
export let labelPlacement = defaults.labelPlacement;
Expand All @@ -46,9 +52,12 @@
dispatch('change', { value });
}
}

$: restProps = { ...defaults, ...$$restProps };
</script>

<Field
{...restProps}
{label}
{value}
{icon}
Expand All @@ -65,6 +74,8 @@
inputValue = undefined;
dispatch('change', { value });
}}
classes={classes.field}
class={cls('DateField', settingsClasses.root, classes.root, $$props.class)}
let:id
>
<Input
Expand Down
Loading