@happeouikit/form-elements 3.0.0-alpha.2 → 3.0.0-alpha.3
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/DatePicker.styles.d.ts +1 -5
- package/dist/DatePicker.types.d.ts +4 -8
- package/dist/MonthDayPicker.types.d.ts +4 -8
- package/dist/dateLocale.d.ts +27 -40
- package/dist/index.cjs.js +164 -152
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.es.js +10688 -7243
- package/dist/index.es.js.map +1 -1
- package/package.json +2 -2
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
* so MonthDayPicker does not load DatePicker's moment.js imports.
|
|
4
4
|
*/
|
|
5
5
|
export declare const InputContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
|
-
export declare const StyledInput: import("styled-components").StyledComponent<"input", any, {
|
|
7
|
-
$hasError?: boolean | undefined;
|
|
8
|
-
}, never>;
|
|
9
|
-
/** Below the input, same error-message convention as form-elements' own `Input` component. */
|
|
10
|
-
export declare const ValidationErrorContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
|
+
export declare const StyledInput: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
11
7
|
export declare const OverlayContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
12
8
|
export declare const YearMonthSelectContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
13
9
|
export declare const MonthUl: import("styled-components").StyledComponent<"ul", any, {}, never>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { DayPickerProps } from "react-day-picker";
|
|
3
|
+
import type { DateFormat } from "./dateLocale";
|
|
3
4
|
export interface DateRange {
|
|
4
5
|
from: Date | number | string;
|
|
5
6
|
to: Date | number | string;
|
|
@@ -10,14 +11,10 @@ export interface DisabledDays {
|
|
|
10
11
|
}
|
|
11
12
|
export interface DatePickerProps {
|
|
12
13
|
label?: React.ReactNode;
|
|
14
|
+
/** BCP 47 locale for written month names only (e.g. the "MMMM YYYY" caption). */
|
|
13
15
|
locale?: string;
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
* `locale`, this should be a language the surrounding app is actually
|
|
17
|
-
* displaying its own UI copy in (never a raw OS/browser locale) — falls
|
|
18
|
-
* back to English when omitted.
|
|
19
|
-
*/
|
|
20
|
-
calendarLanguage?: string;
|
|
16
|
+
/** Numeric day/month/year order; see `dateLocale.ts`. Defaults to `DD/MM/YYYY`. */
|
|
17
|
+
dateFormat?: DateFormat;
|
|
21
18
|
width?: string;
|
|
22
19
|
date?: DateRange;
|
|
23
20
|
type?: "from" | "to";
|
|
@@ -38,7 +35,6 @@ export interface DatePickerProps {
|
|
|
38
35
|
export interface MonthPickerProps {
|
|
39
36
|
date: Date;
|
|
40
37
|
disabledDays: DisabledDays;
|
|
41
|
-
calendarLanguage?: string;
|
|
42
38
|
onChange: (val: {
|
|
43
39
|
month: number;
|
|
44
40
|
year: number;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import type { DateFormat } from "./dateLocale";
|
|
2
3
|
export interface MonthDay {
|
|
3
4
|
/** 1-12 */
|
|
4
5
|
month: number;
|
|
@@ -7,15 +8,10 @@ export interface MonthDay {
|
|
|
7
8
|
}
|
|
8
9
|
export interface MonthDayPickerProps {
|
|
9
10
|
label?: React.ReactNode;
|
|
10
|
-
/** BCP 47 locale for
|
|
11
|
+
/** BCP 47 locale for written month names only (e.g. "en-gb" or "en-us"). */
|
|
11
12
|
locale?: string;
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
* `locale`, this should be a language the surrounding app is actually
|
|
15
|
-
* displaying its own UI copy in (never a raw OS/browser locale) — falls
|
|
16
|
-
* back to English when omitted.
|
|
17
|
-
*/
|
|
18
|
-
calendarLanguage?: string;
|
|
13
|
+
/** Numeric day/month order; see `dateLocale.ts`. Defaults to `DD/MM/YYYY`. */
|
|
14
|
+
dateFormat?: DateFormat;
|
|
19
15
|
width?: string;
|
|
20
16
|
value?: MonthDay | null;
|
|
21
17
|
inputProps?: React.InputHTMLAttributes<HTMLInputElement> & {
|
package/dist/dateLocale.d.ts
CHANGED
|
@@ -1,46 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Happeo's two supported numeric date formats. Always `/`-separated; written
|
|
3
|
+
* month/weekday names are a separate concern (driven by `locale`, unrelated
|
|
4
|
+
* to this).
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
export declare const
|
|
8
|
-
/**
|
|
9
|
-
export declare const
|
|
10
|
-
/**
|
|
11
|
-
export declare const
|
|
6
|
+
export type DateFormat = "MM/DD/YYYY" | "DD/MM/YYYY";
|
|
7
|
+
export declare const DEFAULT_DATE_FORMAT: DateFormat;
|
|
8
|
+
/** The literal placeholder for a month-and-day-only input, e.g. "MM/DD". */
|
|
9
|
+
export declare const monthDayPlaceholder: (dateFormat: DateFormat) => string;
|
|
10
|
+
/** e.g. "12/23/1996" for `MM/DD/YYYY`, "23/12/1996" for `DD/MM/YYYY`. */
|
|
11
|
+
export declare const formatNumericDate: (date: Date, dateFormat: DateFormat) => string;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* here like any other malformed input, so the caller can surface a
|
|
19
|
-
* validation error instead of silently accepting a converted value.
|
|
13
|
+
* Parses typed input in one of Happeo's two supported numeric date formats.
|
|
14
|
+
* Day/month may be 1 or 2 digits, year must be 4. Only ASCII digits match
|
|
15
|
+
* (`\d` does not match a native-script digit, e.g. Devanagari or Persian) —
|
|
16
|
+
* such input simply fails to parse here, it is never converted. Returns null
|
|
17
|
+
* for a syntactically-matching but impossible date (e.g. 31/02).
|
|
20
18
|
*/
|
|
21
|
-
export declare const
|
|
19
|
+
export declare const parseNumericDate: (input: string, dateFormat: DateFormat) => Date | null;
|
|
20
|
+
/** Same as `formatNumericDate`, but month/day only (e.g. for a birthday). */
|
|
21
|
+
export declare const formatNumericMonthDay: ({ month, day }: {
|
|
22
|
+
month: number;
|
|
23
|
+
day: number;
|
|
24
|
+
}, dateFormat: DateFormat) => string;
|
|
22
25
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* `new Date("2024-03-01")` would parse it as.
|
|
26
|
+
* Same as `parseNumericDate`, but month/day only. Does not bounds-check
|
|
27
|
+
* `day` against the month (e.g. Feb 30) — the caller does, since that
|
|
28
|
+
* depends on whether a leap-year day (29 Feb) should be allowed.
|
|
27
29
|
*/
|
|
28
|
-
export declare const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* written text must only switch language when the caller can vouch that the
|
|
33
|
-
* rest of the app is displaying in that language too (a Happeo UI language,
|
|
34
|
-
* not a raw system locale) — an unrecognised or missing locale falls back to
|
|
35
|
-
* English instead.
|
|
36
|
-
*/
|
|
37
|
-
export declare const getMonthNames: (locale?: string) => {
|
|
38
|
-
long: string;
|
|
39
|
-
short: string;
|
|
40
|
-
}[];
|
|
41
|
-
/**
|
|
42
|
-
* Short written weekday names for a calendar's header row (e.g. "Sun", "Mon"),
|
|
43
|
-
* indexed like `Date#getDay()` (0 = Sunday). Same English-only-unless-vouched-for
|
|
44
|
-
* fallback as `getMonthNames`.
|
|
45
|
-
*/
|
|
46
|
-
export declare const getWeekdayNames: (locale?: string) => string[];
|
|
30
|
+
export declare const parseNumericMonthDay: (input: string, dateFormat: DateFormat) => {
|
|
31
|
+
month: number;
|
|
32
|
+
day: number;
|
|
33
|
+
} | null;
|