This commit is contained in:
eewing
2026-02-17 14:10:16 -06:00
parent 2bca5834c5
commit cf73cd3b4c
11246 changed files with 1690552 additions and 0 deletions
@@ -0,0 +1,10 @@
<script lang="ts">
import { DateFieldHiddenInputState } from "../date-field.svelte.js";
import HiddenInput from "../../utilities/hidden-input.svelte";
const hiddenInputState = DateFieldHiddenInputState.create();
</script>
{#if hiddenInputState.shouldRender}
<HiddenInput {...hiddenInputState.props} />
{/if}
@@ -0,0 +1,18 @@
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
$$bindings?: Bindings;
} & Exports;
(internal: unknown, props: {
$$events?: Events;
$$slots?: Slots;
}): Exports & {
$set?: any;
$on?: any;
};
z_$$bindings?: Bindings;
}
declare const DateFieldHiddenInput: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
[evt: string]: CustomEvent<any>;
}, {}, {}, string>;
type DateFieldHiddenInput = InstanceType<typeof DateFieldHiddenInput>;
export default DateFieldHiddenInput;
@@ -0,0 +1,39 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import { DateFieldInputState } from "../date-field.svelte.js";
import type { DateFieldInputProps } from "../types.js";
import DateFieldHiddenInput from "./date-field-hidden-input.svelte";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
id = createId(uid),
ref = $bindable(null),
name = "",
children,
child,
...restProps
}: DateFieldInputProps = $props();
const inputState = DateFieldInputState.create({
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
name: boxWith(() => name),
});
const mergedProps = $derived(mergeProps(restProps, inputState.props));
</script>
{#if child}
{@render child({ props: mergedProps, segments: inputState.root.segmentContents })}
{:else}
<div {...mergedProps}>
{@render children?.({ segments: inputState.root.segmentContents })}
</div>
{/if}
<DateFieldHiddenInput />
@@ -0,0 +1,4 @@
import type { DateFieldInputProps } from "../types.js";
declare const DateFieldInput: import("svelte").Component<DateFieldInputProps, {}, "ref">;
type DateFieldInput = ReturnType<typeof DateFieldInput>;
export default DateFieldInput;
@@ -0,0 +1,34 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import { DateFieldLabelState } from "../date-field.svelte.js";
import type { DateFieldLabelProps } from "../types.js";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
id = createId(uid),
ref = $bindable(null),
children,
child,
...restProps
}: DateFieldLabelProps = $props();
const labelState = DateFieldLabelState.create({
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
});
const mergedProps = $derived(mergeProps(restProps, labelState.props));
</script>
{#if child}
{@render child({ props: mergedProps })}
{:else}
<div {...mergedProps}>
{@render children?.()}
</div>
{/if}
@@ -0,0 +1,4 @@
import type { DateFieldLabelProps } from "../types.js";
declare const DateFieldLabel: import("svelte").Component<DateFieldLabelProps, {}, "ref">;
type DateFieldLabel = ReturnType<typeof DateFieldLabel>;
export default DateFieldLabel;
@@ -0,0 +1,37 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import { DateFieldSegmentState } from "../date-field.svelte.js";
import type { DateFieldSegmentProps } from "../types.js";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
id = createId(uid),
ref = $bindable(null),
children,
child,
part,
...restProps
}: DateFieldSegmentProps = $props();
const segmentState = DateFieldSegmentState.create(part, {
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
});
const mergedProps = $derived(
mergeProps(restProps, segmentState.props as Record<string, unknown>)
);
</script>
{#if child}
{@render child({ props: mergedProps })}
{:else}
<span {...mergedProps}>
{@render children?.()}
</span>
{/if}
@@ -0,0 +1,4 @@
import type { DateFieldSegmentProps } from "../types.js";
declare const DateFieldSegment: import("svelte").Component<DateFieldSegmentProps, {}, "ref">;
type DateFieldSegment = ReturnType<typeof DateFieldSegment>;
export default DateFieldSegment;
+99
View File
@@ -0,0 +1,99 @@
<script lang="ts">
import { watch } from "runed";
import { boxWith } from "svelte-toolbelt";
import { DateFieldRootState } from "../date-field.svelte.js";
import type { DateFieldRootProps } from "../types.js";
import { noop } from "../../../internal/noop.js";
import { getDefaultDate } from "../../../internal/date-time/utils.js";
import { resolveLocaleProp } from "../../utilities/config/prop-resolvers.js";
let {
disabled = false,
granularity,
hideTimeZone = false,
hourCycle,
locale,
maxValue,
minValue,
onPlaceholderChange = noop,
onValueChange = noop,
validate = noop,
onInvalid = noop,
placeholder = $bindable(),
value = $bindable(),
readonly = false,
readonlySegments = [],
required = false,
errorMessageId,
children,
}: DateFieldRootProps = $props();
function handleDefaultPlaceholder(setPlaceholder = true) {
if (placeholder !== undefined) return placeholder;
const defaultPlaceholder = getDefaultDate({
granularity,
defaultValue: value,
minValue,
maxValue,
});
if (setPlaceholder) {
placeholder = defaultPlaceholder;
}
return defaultPlaceholder;
}
// SSR
handleDefaultPlaceholder();
/**
* Covers an edge case where when a spread props object is reassigned,
* the props are reset to their default values, which would make placeholder
* undefined which causes errors to be thrown.
*/
watch.pre(
() => placeholder,
() => {
handleDefaultPlaceholder();
}
);
DateFieldRootState.create({
value: boxWith(
() => value,
(v) => {
value = v;
onValueChange(v);
}
),
placeholder: boxWith(
() => {
if (placeholder === undefined) return handleDefaultPlaceholder(false);
return placeholder;
},
(v) => {
if (v === undefined) return;
placeholder = v;
onPlaceholderChange(v);
}
),
disabled: boxWith(() => disabled),
granularity: boxWith(() => granularity),
hideTimeZone: boxWith(() => hideTimeZone),
hourCycle: boxWith(() => hourCycle),
locale: resolveLocaleProp(() => locale),
maxValue: boxWith(() => maxValue),
minValue: boxWith(() => minValue),
validate: boxWith(() => validate),
readonly: boxWith(() => readonly),
readonlySegments: boxWith(() => readonlySegments),
required: boxWith(() => required),
onInvalid: boxWith(() => onInvalid),
errorMessageId: boxWith(() => errorMessageId),
isInvalidProp: boxWith(() => undefined),
});
</script>
{@render children?.()}
@@ -0,0 +1,3 @@
declare const DateField: import("svelte").Component<import("../types.js").DateFieldRootPropsWithoutHTML, {}, "value" | "placeholder">;
type DateField = ReturnType<typeof DateField>;
export default DateField;
+460
View File
@@ -0,0 +1,460 @@
import type { Updater } from "svelte/store";
import type { DateValue } from "@internationalized/date";
import { type WritableBox, DOMContext, type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
import type { DateRangeFieldRootState } from "../date-range-field/date-range-field.svelte.js";
import type { BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, WithRefOpts, RefAttachment } from "../../internal/types.js";
import type { DateAndTimeSegmentObj, DateOnInvalid, DateSegmentObj, DateSegmentPart, DateValidator, Granularity, HourCycle, SegmentPart, SegmentValueObj, TimeSegmentObj, EditableTimeSegmentPart } from "../../shared/date/types.js";
import { type Formatter } from "../../internal/date-time/formatter.js";
import { type Announcer } from "../../internal/date-time/announcer.js";
export declare const dateFieldAttrs: import("../../internal/attrs.js").CreateBitsAttrsReturn<readonly ["input", "label", "segment"]>;
interface SegmentConfig {
min: number | ((root: DateFieldRootState) => number);
max: number | ((root: DateFieldRootState) => number);
cycle: number;
canBeZero?: boolean;
padZero?: boolean;
getAnnouncement?: (value: number, root: DateFieldRootState) => string | number;
updateLogic?: (props: {
root: DateFieldRootState;
prev: string | null;
num: number;
moveToNext: {
value: boolean;
};
}) => string | null;
}
interface DateFieldRootStateOpts extends WritableBoxedValues<{
value: DateValue | undefined;
placeholder: DateValue;
}>, ReadableBoxedValues<{
readonlySegments: SegmentPart[];
validate: DateValidator | undefined;
onInvalid: DateOnInvalid | undefined;
minValue: DateValue | undefined;
maxValue: DateValue | undefined;
disabled: boolean;
readonly: boolean;
granularity: Granularity | undefined;
hourCycle: HourCycle | undefined;
locale: string;
hideTimeZone: boolean;
required: boolean;
errorMessageId: string | undefined;
isInvalidProp: boolean | undefined;
}> {
}
export declare class DateFieldRootState {
#private;
static create(opts: DateFieldRootStateOpts, rangeRoot?: DateRangeFieldRootState): DateFieldRootState;
value: DateFieldRootStateOpts["value"];
placeholder: WritableBox<DateValue>;
validate: DateFieldRootStateOpts["validate"];
minValue: DateFieldRootStateOpts["minValue"];
maxValue: DateFieldRootStateOpts["maxValue"];
disabled: DateFieldRootStateOpts["disabled"];
readonly: DateFieldRootStateOpts["readonly"];
granularity: DateFieldRootStateOpts["granularity"];
readonlySegments: DateFieldRootStateOpts["readonlySegments"];
hourCycle: DateFieldRootStateOpts["hourCycle"];
locale: DateFieldRootStateOpts["locale"];
hideTimeZone: DateFieldRootStateOpts["hideTimeZone"];
required: DateFieldRootStateOpts["required"];
onInvalid: DateFieldRootStateOpts["onInvalid"];
errorMessageId: DateFieldRootStateOpts["errorMessageId"];
isInvalidProp: DateFieldRootStateOpts["isInvalidProp"];
descriptionId: string;
formatter: Formatter;
initialSegments: SegmentValueObj;
segmentValues: SegmentValueObj;
announcer: Announcer;
readonly readonlySegmentsSet: Set<SegmentPart>;
segmentStates: import("../../internal/date-time/field/types.js").SegmentStateMap;
descriptionNode: HTMLElement | null;
validationNode: HTMLElement | null;
states: import("../../internal/date-time/field/types.js").SegmentStateMap;
dayPeriodNode: HTMLElement | null;
rangeRoot: DateRangeFieldRootState | undefined;
name: string;
domContext: DOMContext;
constructor(props: DateFieldRootStateOpts, rangeRoot?: DateRangeFieldRootState);
setName(name: string): void;
/**
* Sets the field node for the `DateFieldRootState` instance. We use this method so we can
* keep `#fieldNode` private to prevent accidental usage of the incorrect field node.
*/
setFieldNode(node: HTMLElement | null): void;
/**
* Gets the correct field node for the date field regardless of whether it's being
* used in a standalone context or within a `DateRangeField` component.
*/
getFieldNode(): HTMLElement | null;
/**
* Sets the label node for the `DateFieldRootState` instance. We use this method so we can
* keep `#labelNode` private to prevent accidental usage of the incorrect label node.
*/
setLabelNode(node: HTMLElement | null): void;
/**
* Gets the correct label node for the date field regardless of whether it's being used in
* a standalone context or within a `DateRangeField` component.
*/
getLabelNode(): HTMLElement | null;
setValue(value: DateValue | undefined): void;
syncSegmentValues(value: DateValue): void;
readonly validationStatus: false | {
readonly reason: "custom";
readonly message: string | string[];
} | {
readonly reason: "min";
readonly message?: undefined;
} | {
readonly reason: "max";
readonly message?: undefined;
};
readonly isInvalid: boolean;
readonly inferredGranularity: Granularity;
readonly dateRef: DateValue;
readonly allSegmentContent: {
obj: import("../../internal/date-time/field/types.js").SegmentContentObj;
arr: {
part: import("../../internal/date-time/field/types.js").SegmentPart;
value: string;
}[];
};
readonly segmentContents: {
part: import("../../internal/date-time/field/types.js").SegmentPart;
value: string;
}[];
readonly sharedSegmentAttrs: {
role: string;
contenteditable: string;
tabindex: number;
spellcheck: boolean;
inputmode: string;
autocorrect: string;
enterkeyhint: string;
style: {
caretColor: string;
};
};
updateSegment<T extends keyof DateAndTimeSegmentObj>(part: T, cb: T extends DateSegmentPart ? Updater<DateSegmentObj[T]> : T extends EditableTimeSegmentPart ? Updater<TimeSegmentObj[T]> : Updater<DateAndTimeSegmentObj[T]>): void;
handleSegmentClick(e: BitsMouseEvent): void;
getBaseSegmentAttrs(part: SegmentPart, segmentId: string): {
[dateFieldAttrs.segment]: string;
"aria-invalid": "true" | undefined;
"aria-disabled": "true" | "false";
"aria-readonly": "true" | "false";
"data-invalid": "" | undefined;
"data-disabled": "" | undefined;
"data-readonly": "" | undefined;
"data-segment": string;
} | {
"aria-labelledby": string;
contenteditable: string | undefined;
"aria-describedby": string | undefined;
tabindex: number | undefined;
"aria-invalid": "true" | undefined;
"aria-disabled": "true" | "false";
"aria-readonly": "true" | "false";
"data-invalid": "" | undefined;
"data-disabled": "" | undefined;
"data-readonly": "" | undefined;
"data-segment": string;
};
}
interface DateFieldInputStateOpts extends WithRefOpts, ReadableBoxedValues<{
name: string;
}> {
}
export declare class DateFieldInputState {
#private;
static create(opts: DateFieldInputStateOpts): DateFieldInputState;
readonly opts: DateFieldInputStateOpts;
readonly root: DateFieldRootState;
readonly domContext: DOMContext;
readonly attachment: RefAttachment;
constructor(opts: DateFieldInputStateOpts, root: DateFieldRootState);
readonly props: {
readonly id: string;
readonly role: "group";
readonly "aria-labelledby": string | undefined;
readonly "aria-describedby": string | undefined;
readonly "aria-disabled": "true" | "false";
readonly "data-invalid": "" | undefined;
readonly "data-disabled": "" | undefined;
};
}
export declare class DateFieldHiddenInputState {
static create(): DateFieldHiddenInputState;
readonly root: DateFieldRootState;
readonly shouldRender: boolean;
readonly isoValue: string;
constructor(root: DateFieldRootState);
readonly props: {
name: string;
value: string;
required: boolean;
};
}
interface DateFieldLabelStateOpts extends WithRefOpts {
}
export declare class DateFieldLabelState {
static create(opts: DateFieldLabelStateOpts): DateFieldLabelState;
readonly opts: DateFieldLabelStateOpts;
readonly root: DateFieldRootState;
readonly attachment: RefAttachment;
constructor(opts: DateFieldLabelStateOpts, root: DateFieldRootState);
onclick(_: BitsMouseEvent): void;
readonly props: {
readonly id: string;
readonly "data-invalid": "" | undefined;
readonly "data-disabled": "" | undefined;
readonly onclick: (_: BitsMouseEvent) => void;
};
}
declare abstract class BaseNumericSegmentState {
#private;
readonly opts: WithRefOpts;
readonly root: DateFieldRootState;
readonly announcer: Announcer;
readonly part: string;
readonly config: SegmentConfig;
readonly attachment: RefAttachment;
constructor(opts: WithRefOpts, root: DateFieldRootState, part: string, config: SegmentConfig);
onkeydown(e: BitsKeyboardEvent): void;
onfocusout(_: BitsFocusEvent): void;
getSegmentProps(): {
"aria-label": string;
"aria-valuemin": number;
"aria-valuemax": number;
"aria-valuenow": number;
"aria-valuetext": string;
};
readonly props: {
"aria-invalid": "true" | undefined;
"aria-disabled": "true" | "false";
"aria-readonly": "true" | "false";
"data-invalid": "" | undefined;
"data-disabled": "" | undefined;
"data-readonly": "" | undefined;
"data-segment": string;
onkeydown: (e: BitsKeyboardEvent) => void;
onfocusout: (_: BitsFocusEvent) => void;
onclick: (e: BitsMouseEvent) => void;
"aria-label": string;
"aria-valuemin": number;
"aria-valuemax": number;
"aria-valuenow": number;
"aria-valuetext": string;
id: string;
role: string;
contenteditable: string;
tabindex: number;
spellcheck: boolean;
inputmode: string;
autocorrect: string;
enterkeyhint: string;
style: {
caretColor: string;
};
} | {
"aria-labelledby": string;
contenteditable: string | undefined;
"aria-describedby": string | undefined;
tabindex: number | undefined;
"aria-invalid": "true" | undefined;
"aria-disabled": "true" | "false";
"aria-readonly": "true" | "false";
"data-invalid": "" | undefined;
"data-disabled": "" | undefined;
"data-readonly": "" | undefined;
"data-segment": string;
onkeydown: (e: BitsKeyboardEvent) => void;
onfocusout: (_: BitsFocusEvent) => void;
onclick: (e: BitsMouseEvent) => void;
"aria-label": string;
"aria-valuemin": number;
"aria-valuemax": number;
"aria-valuenow": number;
"aria-valuetext": string;
id: string;
role: string;
spellcheck: boolean;
inputmode: string;
autocorrect: string;
enterkeyhint: string;
style: {
caretColor: string;
};
};
}
declare class DateFieldYearSegmentState extends BaseNumericSegmentState {
#private;
constructor(opts: WithRefOpts, root: DateFieldRootState);
onkeydown(e: BitsKeyboardEvent): void;
onfocusout(_: BitsFocusEvent): void;
}
declare class DateFieldDaySegmentState extends BaseNumericSegmentState {
constructor(opts: WithRefOpts, root: DateFieldRootState);
}
declare class DateFieldMonthSegmentState extends BaseNumericSegmentState {
constructor(opts: WithRefOpts, root: DateFieldRootState);
}
declare class DateFieldHourSegmentState extends BaseNumericSegmentState {
constructor(opts: WithRefOpts, root: DateFieldRootState);
onkeydown(e: BitsKeyboardEvent): void;
}
declare class DateFieldMinuteSegmentState extends BaseNumericSegmentState {
constructor(opts: WithRefOpts, root: DateFieldRootState);
}
declare class DateFieldSecondSegmentState extends BaseNumericSegmentState {
constructor(opts: WithRefOpts, root: DateFieldRootState);
}
interface DateFieldDayPeriodSegmentStateOpts extends WithRefOpts {
}
export declare class DateFieldDayPeriodSegmentState {
#private;
static create(opts: DateFieldDayPeriodSegmentStateOpts): DateFieldDayPeriodSegmentState;
readonly opts: DateFieldDayPeriodSegmentStateOpts;
readonly root: DateFieldRootState;
readonly attachment: RefAttachment;
constructor(opts: DateFieldDayPeriodSegmentStateOpts, root: DateFieldRootState);
onkeydown(e: BitsKeyboardEvent): void;
readonly props: {
"aria-invalid": "true" | undefined;
"aria-disabled": "true" | "false";
"aria-readonly": "true" | "false";
"data-invalid": "" | undefined;
"data-disabled": "" | undefined;
"data-readonly": "" | undefined;
"data-segment": string;
id: string;
inputmode: string;
"aria-label": string;
"aria-valuemin": number;
"aria-valuemax": number;
"aria-valuenow": number;
"aria-valuetext": "AM" | "PM";
onkeydown: (e: BitsKeyboardEvent) => void;
onclick: (e: BitsMouseEvent) => void;
role: string;
contenteditable: string;
tabindex: number;
spellcheck: boolean;
autocorrect: string;
enterkeyhint: string;
style: {
caretColor: string;
};
} | {
"aria-labelledby": string;
contenteditable: string | undefined;
"aria-describedby": string | undefined;
tabindex: number | undefined;
"aria-invalid": "true" | undefined;
"aria-disabled": "true" | "false";
"aria-readonly": "true" | "false";
"data-invalid": "" | undefined;
"data-disabled": "" | undefined;
"data-readonly": "" | undefined;
"data-segment": string;
id: string;
inputmode: string;
"aria-label": string;
"aria-valuemin": number;
"aria-valuemax": number;
"aria-valuenow": number;
"aria-valuetext": "AM" | "PM";
onkeydown: (e: BitsKeyboardEvent) => void;
onclick: (e: BitsMouseEvent) => void;
role: string;
spellcheck: boolean;
autocorrect: string;
enterkeyhint: string;
style: {
caretColor: string;
};
} | undefined;
}
interface DateFieldLiteralSegmentStateOpts extends WithRefOpts {
}
export declare class DateFieldLiteralSegmentState {
static create(opts: DateFieldLiteralSegmentStateOpts): DateFieldLiteralSegmentState;
readonly opts: DateFieldLiteralSegmentStateOpts;
readonly root: DateFieldRootState;
readonly attachment: RefAttachment;
constructor(opts: DateFieldLiteralSegmentStateOpts, root: DateFieldRootState);
readonly props: {
readonly "aria-invalid": "true" | undefined;
readonly "aria-disabled": "true" | "false";
readonly "aria-readonly": "true" | "false";
readonly "data-invalid": "" | undefined;
readonly "data-disabled": "" | undefined;
readonly "data-readonly": "" | undefined;
readonly "data-segment": string;
readonly id: string;
readonly "aria-hidden": "true" | undefined;
} | {
readonly "aria-labelledby": string;
readonly contenteditable: string | undefined;
readonly "aria-describedby": string | undefined;
readonly tabindex: number | undefined;
readonly "aria-invalid": "true" | undefined;
readonly "aria-disabled": "true" | "false";
readonly "aria-readonly": "true" | "false";
readonly "data-invalid": "" | undefined;
readonly "data-disabled": "" | undefined;
readonly "data-readonly": "" | undefined;
readonly "data-segment": string;
readonly id: string;
readonly "aria-hidden": "true" | undefined;
};
}
interface DateFieldTimeZoneSegmentStateOpts extends WithRefOpts {
}
export declare class DateFieldTimeZoneSegmentState {
static create(opts: DateFieldTimeZoneSegmentStateOpts): DateFieldTimeZoneSegmentState;
readonly opts: DateFieldTimeZoneSegmentStateOpts;
readonly root: DateFieldRootState;
readonly attachment: RefAttachment;
constructor(opts: DateFieldTimeZoneSegmentStateOpts, root: DateFieldRootState);
onkeydown(e: BitsKeyboardEvent): void;
readonly props: {
readonly "data-readonly": "" | undefined;
readonly "aria-invalid": "true" | undefined;
readonly "aria-disabled": "true" | "false";
readonly "aria-readonly": "true" | "false";
readonly "data-invalid": "" | undefined;
readonly "data-disabled": "" | undefined;
readonly "data-segment": string;
readonly role: "textbox";
readonly id: string;
readonly "aria-label": "timezone, ";
readonly style: {
readonly caretColor: "transparent";
};
readonly onkeydown: (e: BitsKeyboardEvent) => void;
} | {
readonly "data-readonly": "" | undefined;
readonly "aria-labelledby": string;
readonly contenteditable: string | undefined;
readonly "aria-describedby": string | undefined;
readonly tabindex: number | undefined;
readonly "aria-invalid": "true" | undefined;
readonly "aria-disabled": "true" | "false";
readonly "aria-readonly": "true" | "false";
readonly "data-invalid": "" | undefined;
readonly "data-disabled": "" | undefined;
readonly "data-segment": string;
readonly role: "textbox";
readonly id: string;
readonly "aria-label": "timezone, ";
readonly style: {
readonly caretColor: "transparent";
};
readonly onkeydown: (e: BitsKeyboardEvent) => void;
};
}
export declare class DateFieldSegmentState {
static create(part: SegmentPart, opts: WithRefOpts): DateFieldYearSegmentState | DateFieldDaySegmentState | DateFieldMonthSegmentState | DateFieldHourSegmentState | DateFieldMinuteSegmentState | DateFieldSecondSegmentState | DateFieldDayPeriodSegmentState | DateFieldLiteralSegmentState | DateFieldTimeZoneSegmentState;
}
export {};
File diff suppressed because it is too large Load Diff
+5
View File
@@ -0,0 +1,5 @@
export { default as Root } from "./components/date-field.svelte";
export { default as Input } from "./components/date-field-input.svelte";
export { default as Label } from "./components/date-field-label.svelte";
export { default as Segment } from "./components/date-field-segment.svelte";
export type { DateFieldRootProps as RootProps, DateFieldInputProps as InputProps, DateFieldLabelProps as LabelProps, DateFieldSegmentProps as SegmentProps, } from "./types.js";
+4
View File
@@ -0,0 +1,4 @@
export { default as Root } from "./components/date-field.svelte";
export { default as Input } from "./components/date-field-input.svelte";
export { default as Label } from "./components/date-field-label.svelte";
export { default as Segment } from "./components/date-field-segment.svelte";
+1
View File
@@ -0,0 +1 @@
export * as DateField from "./exports.js";
+1
View File
@@ -0,0 +1 @@
export * as DateField from "./exports.js";
+141
View File
@@ -0,0 +1,141 @@
import type { DateValue } from "@internationalized/date";
import type { DateOnInvalid, DateValidator, EditableSegmentPart, SegmentPart, WithChildren } from "../../shared/index.js";
import type { OnChangeFn, WithChild, Without } from "../../internal/types.js";
import type { BitsPrimitiveDivAttributes, BitsPrimitiveSpanAttributes } from "../../shared/attributes.js";
import type { Granularity } from "../../shared/date/types.js";
export type DateFieldRootPropsWithoutHTML = WithChildren<{
/**
* The value of the date field.
*
* @bindable
*/
value?: DateValue;
/**
* A callback that is called when the date field value changes.
*
*/
onValueChange?: OnChangeFn<DateValue | undefined>;
/**
* The placeholder value of the date field. This determines the format
* and what date the field starts at when it is empty.
*
* @bindable
*/
placeholder?: DateValue;
/**
* A callback that is called when the date field's placeholder value changes.
*/
onPlaceholderChange?: OnChangeFn<DateValue | undefined>;
/**
* A function that returns a string or array of strings as validation errors if the date is
* invalid, or nothing if the date is valid
*/
validate?: DateValidator;
/**
* A callback fired when the date field's value is invalid. Use this to display an error
* message to the user.
*/
onInvalid?: DateOnInvalid;
/**
* The minimum acceptable date. When provided, the date field
* will be marked as invalid if the user enters a date before this date.
*/
minValue?: DateValue;
/**
* The maximum acceptable date. When provided, the date field
* will be marked as invalid if the user enters a date after this date.
*/
maxValue?: DateValue;
/**
* If true, the date field will be disabled and users will not be able
* to interact with it. This also disables the hidden input element if
* the date field is used in a form.
*
* @defaultValue false
*/
disabled?: boolean;
/**
* If true, the date field will be readonly, and users will not be able to
* edit the values of any of the individual segments.
*
* @defaultValue false
*/
readonly?: boolean;
/**
* An array of segment names that should be readonly. If provided, only the
* segments not in this array will be editable.
*/
readonlySegments?: EditableSegmentPart[];
/**
* The format to use for displaying the time in the input.
* If using a 12 hour clock, ensure you also include the `dayPeriod`
* segment in your input to ensure the user can select AM/PM.
*
* @defaultValue the locale's default time format
*/
hourCycle?: 12 | 24;
/**
* The locale to use for formatting the date field.
*
* @defaultValue 'en'
*/
locale?: string;
/**
* The granularity of the date field. This determines which
* segments will be includes in the segments array used to
* build the date field.
*
* By default, when a `CalendarDate` value is used, the granularity
* will default to `'day'`, and when a `CalendarDateTime` or `ZonedDateTime`
* value is used, the granularity will default to `'minute'`.
*
* Granularity is only used for visual purposes, and does not impact
* the value of the date field. You can have the same value synced
* between multiple date fields with different granularities and they
* will all contain the same value.
*
* @defaultValue 'day'
*/
granularity?: Granularity;
/**
* Whether or not to hide the timeZoneName segment from the date field.
*
* @defaultValue false;
*/
hideTimeZone?: boolean;
/**
* Whether or not the hidden input of the date field requires a value
* to be submitted.
*
* @defaultValue false
*/
required?: boolean;
/**
* The `id` of the element which contains the error messages for the date field when the
* date is invalid.
*/
errorMessageId?: string;
}>;
export type DateFieldRootProps = DateFieldRootPropsWithoutHTML;
export type DateFieldInputSnippetProps = {
segments: Array<{
part: SegmentPart;
value: string;
}>;
};
export type DateFieldInputPropsWithoutHTML = WithChild<{
/**
* The name to use for the hidden input element of the date field,
* which is used to submit the ISO string value of the date field
* to a server. If not provided, the hidden input element will not
* be rendered.
*/
name?: string;
}, DateFieldInputSnippetProps>;
export type DateFieldInputProps = DateFieldInputPropsWithoutHTML & Without<BitsPrimitiveDivAttributes, DateFieldInputPropsWithoutHTML>;
export type DateFieldSegmentPropsWithoutHTML = WithChild<{
part: SegmentPart;
}>;
export type DateFieldSegmentProps = DateFieldSegmentPropsWithoutHTML & Without<BitsPrimitiveSpanAttributes, DateFieldSegmentPropsWithoutHTML>;
export type DateFieldLabelPropsWithoutHTML = WithChild;
export type DateFieldLabelProps = DateFieldLabelPropsWithoutHTML & Without<BitsPrimitiveDivAttributes, DateFieldLabelPropsWithoutHTML>;
+1
View File
@@ -0,0 +1 @@
export {};