@veevarts/design-system 2.0.0-alpha.57 → 2.0.0-alpha.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DatePicker/DatePicker.d.ts +9 -2
- package/dist/components/DatePicker/defaults.d.ts +28 -0
- package/dist/components/DatePicker/index.d.ts +1 -0
- package/dist/components/index.d.ts +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.js +4475 -4301
- package/dist/patterns/TimeField/TimeField.d.ts +6 -0
- package/dist/patterns/TimeField/index.d.ts +3 -0
- package/dist/patterns/TimeField/time.d.ts +40 -0
- package/dist/patterns/TimeField/types.d.ts +77 -0
- package/dist/patterns/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
import { TimeFieldProps } from './types';
|
|
3
|
+
export declare function TimeField({ value: valueProp, defaultValue, onChange, label, 'aria-label': ariaLabel, placeholder, emptyContent, invalidMessage, minTime, minTimeMessage, listStart, listEnd, listStep, locale, isRequired, isDisabled, isInvalid, errorMessage, isClearable, clearLabel, onBlur, size, variant, labelPlacement, className, inputProps, popoverProps, 'data-testid': dataTestId, }: TimeFieldProps): JSX.Element;
|
|
4
|
+
export declare namespace TimeField {
|
|
5
|
+
var displayName: string;
|
|
6
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The time logic behind {@link TimeField}, kept free of React so it can be
|
|
3
|
+
* tested and reused on its own. Every time in and out is 24-hour `"HH:mm"`.
|
|
4
|
+
*/
|
|
5
|
+
/** Minutes since midnight of an `"HH:mm"` time. */
|
|
6
|
+
export declare function toMinutes(time: string): number;
|
|
7
|
+
/**
|
|
8
|
+
* Read typed text as a time: `"HH:mm"`, or `null` when it is not one.
|
|
9
|
+
*
|
|
10
|
+
* Forgiving on purpose: `"7:15 pm"`, `"7:15pm"`, `"715p"`, `"7p"`, `"19:15"`,
|
|
11
|
+
* `"1915"` and `"7"` all work; case, spaces and dots do not matter
|
|
12
|
+
* (`"7:15 P.M."`). Without am/pm, hours 1–6 read as afternoon (no venue opens
|
|
13
|
+
* at 3 AM) and every other hour as 24-hour: `"3"` is 15:00, `"7"` is 07:00,
|
|
14
|
+
* `"19"` is 19:00, `"0"` is midnight.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* parseTimeInput('715p'); // '19:15'
|
|
18
|
+
* parseTimeInput('3'); // '15:00'
|
|
19
|
+
* parseTimeInput('25'); // null
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseTimeInput(input: string): string | null;
|
|
22
|
+
/**
|
|
23
|
+
* The suggested times: `start` to `end` inclusive, every `step` whole
|
|
24
|
+
* minutes. Empty when `step` is under a minute or `end` is before `start`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildTimeOptions(start: string, end: string, step: number): string[];
|
|
27
|
+
/**
|
|
28
|
+
* Whether the list keeps `time` while `query` is typed. It compares against
|
|
29
|
+
* the 12-hour form (`"7:30"`) and the 24-hour forms (`"19:30"`, `"07:30"`), so
|
|
30
|
+
* it does not depend on how the label is formatted: `"7"` keeps 7:00 and
|
|
31
|
+
* 7:30 AM and PM, `"7p"` only the PM ones, `"19"` the 7 PM ones, `"p"` every
|
|
32
|
+
* PM time.
|
|
33
|
+
*/
|
|
34
|
+
export declare function matchesTimeQuery(time: string, query: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The label for a time in `locale`: `"7:15 PM"` in `en-US`, `"19:15"` in
|
|
37
|
+
* `en-GB`, `"7:15 p. m."` in `es-CO`. No-break spaces become plain ones, so
|
|
38
|
+
* the label matches what people type and what tests search for.
|
|
39
|
+
*/
|
|
40
|
+
export declare function formatTimeLabel(time: string, locale: string): string;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { FocusEvent, ReactNode } from 'react';
|
|
2
|
+
import { AutocompleteProps } from '../../components';
|
|
3
|
+
/** One row of the list: the `"HH:mm"` key and its locale label. */
|
|
4
|
+
export interface TimeFieldOption {
|
|
5
|
+
key: string;
|
|
6
|
+
label: string;
|
|
7
|
+
}
|
|
8
|
+
export interface TimeFieldProps {
|
|
9
|
+
/**
|
|
10
|
+
* The time as 24-hour `"HH:mm"` text, or `null` for none. Omit for
|
|
11
|
+
* uncontrolled mode.
|
|
12
|
+
*/
|
|
13
|
+
value?: string | null;
|
|
14
|
+
/** Starting time in uncontrolled mode. */
|
|
15
|
+
defaultValue?: string | null;
|
|
16
|
+
/** Called with the committed `"HH:mm"`, or `null` when a clearable field is emptied. */
|
|
17
|
+
onChange?: (time: string | null) => void;
|
|
18
|
+
/** Visible label. Without one, pass `aria-label`. */
|
|
19
|
+
label?: ReactNode;
|
|
20
|
+
'aria-label'?: string;
|
|
21
|
+
/** "e.g. 7:15 PM". */
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Shown in the list when nothing matches the typed text, or the text was
|
|
25
|
+
* erased ("Type a time like 7:15 PM"). Required and non-empty: HeroUI's
|
|
26
|
+
* own is English, and an Autocomplete that hides an empty list loses its
|
|
27
|
+
* options to `aria-hidden` when they come back.
|
|
28
|
+
*/
|
|
29
|
+
emptyContent: ReactNode;
|
|
30
|
+
/** Shown when the typed text is not a time ("Enter a time like 7:15 PM."). */
|
|
31
|
+
invalidMessage: ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* Earliest allowed `"HH:mm"`. Earlier times leave the list, and typing
|
|
34
|
+
* one, or receiving one as `value`, shows `minTimeMessage`.
|
|
35
|
+
*/
|
|
36
|
+
minTime?: string;
|
|
37
|
+
/** Shown for a time before `minTime` ("Ends after it starts."). Defaults to `invalidMessage`. */
|
|
38
|
+
minTimeMessage?: ReactNode;
|
|
39
|
+
/** First time the list suggests. @default '07:00' */
|
|
40
|
+
listStart?: string;
|
|
41
|
+
/** Last time the list suggests, inclusive. @default '21:00' */
|
|
42
|
+
listEnd?: string;
|
|
43
|
+
/** Minutes between suggested times. @default 30 */
|
|
44
|
+
listStep?: number;
|
|
45
|
+
/**
|
|
46
|
+
* BCP 47 locale the times are written in: "7:15 PM" in `en-US`, "19:15"
|
|
47
|
+
* in `en-GB`. Pass the same one as `HeroUIProvider`. @default 'en-US'
|
|
48
|
+
*/
|
|
49
|
+
locale?: string;
|
|
50
|
+
isRequired?: boolean;
|
|
51
|
+
isDisabled?: boolean;
|
|
52
|
+
/** Marks the field invalid from outside; `errorMessage` is shown with it. */
|
|
53
|
+
isInvalid?: boolean;
|
|
54
|
+
errorMessage?: ReactNode;
|
|
55
|
+
/**
|
|
56
|
+
* Whether the field may be emptied: a clear button shows, and leaving it
|
|
57
|
+
* empty commits `null`. Otherwise leaving it empty restores the time it
|
|
58
|
+
* had. @default false
|
|
59
|
+
*/
|
|
60
|
+
isClearable?: boolean;
|
|
61
|
+
/** Accessible name of the clear button ("Clear time"); HeroUI gives it none. */
|
|
62
|
+
clearLabel?: string;
|
|
63
|
+
/** Called after the field has committed what was typed (react-hook-form's `field.onBlur`). */
|
|
64
|
+
onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
|
|
65
|
+
size?: AutocompleteProps['size'];
|
|
66
|
+
/** @default 'bordered' */
|
|
67
|
+
variant?: AutocompleteProps['variant'];
|
|
68
|
+
/** @default 'outside-top' */
|
|
69
|
+
labelPlacement?: AutocompleteProps['labelPlacement'];
|
|
70
|
+
className?: string;
|
|
71
|
+
/** Passed to HeroUI's input: `{ classNames: { inputWrapper: 'h-11' } }`. */
|
|
72
|
+
inputProps?: AutocompleteProps['inputProps'];
|
|
73
|
+
/** Passed to HeroUI's popover. */
|
|
74
|
+
popoverProps?: AutocompleteProps['popoverProps'];
|
|
75
|
+
/** Lands on the `<input>`. Options get `${data-testid}-option-${HH:mm}`. */
|
|
76
|
+
'data-testid'?: string;
|
|
77
|
+
}
|
package/dist/patterns/index.d.ts
CHANGED
|
@@ -71,6 +71,8 @@ export { UnderlineTabs } from './UnderlineTabs';
|
|
|
71
71
|
export type { UnderlineTabsProps, UnderlineTabItem, UnderlineTabsSize, UnderlineTabsLevel } from './UnderlineTabs';
|
|
72
72
|
export { AdminFieldLabel, AdminTextField, adminFieldErrorClass, adminFieldHelpButtonClass, adminFieldHelpContentClass, adminFieldHelpIconClass, adminFieldHintClass, adminFieldLabelClass, adminFieldLabelNoAutoMarkClass, adminFieldLabelRowClass, adminFieldLabelSuffixClass, adminFieldRequiredClass, adminInputClass, adminInputReadOnlyClass, adminInputWrapperClass, } from './AdminTextField';
|
|
73
73
|
export type { AdminTextFieldProps, AdminFieldLabelProps, AdminFieldRequiredProps, AdminFieldHelpProps, } from './AdminTextField';
|
|
74
|
+
export { TimeField, parseTimeInput } from './TimeField';
|
|
75
|
+
export type { TimeFieldProps } from './TimeField';
|
|
74
76
|
export { RowActions } from './RowActions';
|
|
75
77
|
export type { RowActionsProps, RowAction } from './RowActions';
|
|
76
78
|
export { PickerRow } from './PickerRow';
|