@allxsmith/bestax-bulma 5.26.5 → 5.27.0
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/bestax.css +1 -1
- package/dist/bestax.css.map +1 -1
- package/dist/extras.css +1 -1
- package/dist/extras.css.map +1 -1
- package/dist/index.cjs +974 -96
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +973 -97
- package/dist/index.esm.js.map +1 -1
- package/dist/types/components/Tabs.d.ts +25 -3
- package/dist/types/form/DateInputBase.d.ts +5 -2
- package/dist/types/form/DateRangeInput.d.ts +91 -0
- package/dist/types/form/DateRangeInputBase.d.ts +172 -0
- package/dist/types/form/DateTimeInputBase.d.ts +7 -2
- package/dist/types/form/File.d.ts +15 -2
- package/dist/types/form/FormContext.d.ts +11 -0
- package/dist/types/form/Numberinput.d.ts +8 -1
- package/dist/types/form/TimeInputBase.d.ts +1 -1
- package/dist/types/form/_pickerInternals/Calendar.d.ts +45 -4
- package/dist/types/form/_pickerInternals/PickerPopover.d.ts +1 -0
- package/dist/types/form/_pickerInternals/dateUtils.d.ts +24 -0
- package/dist/types/form/_pickerInternals/formatters.d.ts +14 -0
- package/dist/types/form/_pickerInternals/pickerTypes.d.ts +27 -0
- package/dist/types/form/_pickerInternals/useSegmentedEntry.d.ts +12 -3
- package/dist/types/helpers/statusRegion.d.ts +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types-cjs/components/Tabs.d.ts +25 -3
- package/dist/types-cjs/form/DateInputBase.d.ts +5 -2
- package/dist/types-cjs/form/DateRangeInput.d.ts +91 -0
- package/dist/types-cjs/form/DateRangeInputBase.d.ts +172 -0
- package/dist/types-cjs/form/DateTimeInputBase.d.ts +7 -2
- package/dist/types-cjs/form/File.d.ts +15 -2
- package/dist/types-cjs/form/FormContext.d.ts +11 -0
- package/dist/types-cjs/form/Numberinput.d.ts +8 -1
- package/dist/types-cjs/form/TimeInputBase.d.ts +1 -1
- package/dist/types-cjs/form/_pickerInternals/Calendar.d.ts +45 -4
- package/dist/types-cjs/form/_pickerInternals/PickerPopover.d.ts +1 -0
- package/dist/types-cjs/form/_pickerInternals/dateUtils.d.ts +24 -0
- package/dist/types-cjs/form/_pickerInternals/formatters.d.ts +14 -0
- package/dist/types-cjs/form/_pickerInternals/pickerTypes.d.ts +27 -0
- package/dist/types-cjs/form/_pickerInternals/useSegmentedEntry.d.ts +12 -3
- package/dist/types-cjs/helpers/statusRegion.d.ts +1 -0
- package/dist/types-cjs/index.d.ts +4 -0
- package/dist/versions/bestax-no-dark-mode.css +1 -1
- package/dist/versions/bestax-no-dark-mode.css.map +1 -1
- package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
- package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
- package/dist/versions/bestax-no-helpers.css +1 -1
- package/dist/versions/bestax-no-helpers.css.map +1 -1
- package/dist/versions/bestax-prefixed.css +1 -1
- package/dist/versions/bestax-prefixed.css.map +1 -1
- package/package.json +1 -1
- package/src/scss/components/_tabs.scss +44 -0
- package/src/scss/form/_dateinput.scss +58 -3
- package/src/scss/form/_daterangeinput.scss +63 -0
- package/src/scss/form/_file.scss +37 -0
- package/src/scss/form/_index.scss +2 -0
|
@@ -37,19 +37,28 @@ export interface UseSegmentedEntryParams {
|
|
|
37
37
|
* every manual-entry commit; return true to reject the candidate value.
|
|
38
38
|
*/
|
|
39
39
|
isBlocked?: (d: Date) => boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Rejects a candidate only while the digits typed into its segment leave
|
|
42
|
+
* it unfinished, such as the first digits of a year. The digit stays in
|
|
43
|
+
* the segment and the next one tries again, so a value passing through a
|
|
44
|
+
* candidate it can't commit on the way to one it can costs nothing. A
|
|
45
|
+
* finished segment, an arrow step and parsed text answer to `isBlocked`
|
|
46
|
+
* alone.
|
|
47
|
+
*/
|
|
48
|
+
isUnfinishedBlocked?: (d: Date) => boolean;
|
|
40
49
|
disabled?: boolean;
|
|
41
50
|
readOnly?: boolean;
|
|
42
51
|
/** Allow segmented typing. When false, segment mode never engages. */
|
|
43
52
|
editable?: boolean;
|
|
44
|
-
/** Whether a popover exists; gates open-on-focus / click / ArrowDown. */
|
|
53
|
+
/** Whether a popover exists; gates open-on-focus / click / Alt+ArrowDown. */
|
|
45
54
|
popover?: boolean;
|
|
46
55
|
openOnFocus?: boolean;
|
|
47
56
|
closeOnSelect?: boolean;
|
|
48
57
|
isOpen: boolean;
|
|
49
58
|
/**
|
|
50
59
|
* The host's open-state setter. The hook asks it to open on focus, click
|
|
51
|
-
* or ArrowDown, but not on the focus the popover's focus trap hands
|
|
52
|
-
* to the input as it closes, which is not the user arriving.
|
|
60
|
+
* or Alt+ArrowDown, but not on the focus the popover's focus trap hands
|
|
61
|
+
* back to the input as it closes, which is not the user arriving.
|
|
53
62
|
*/
|
|
54
63
|
setOpen: (next: boolean) => void;
|
|
55
64
|
inputRef: React.RefObject<HTMLInputElement | null>;
|
|
@@ -13,6 +13,7 @@ export declare const announceDelay = 100;
|
|
|
13
13
|
* again.
|
|
14
14
|
*/
|
|
15
15
|
export declare const announcementLifetime = 1000;
|
|
16
|
+
export declare const visuallyHidden: React.CSSProperties;
|
|
16
17
|
/**
|
|
17
18
|
* Reads an element out roughly the way a screen reader would: its text, with
|
|
18
19
|
* an element's `aria-label`, or an image's `alt`, standing in for what's
|
package/dist/types/index.d.ts
CHANGED
|
@@ -98,6 +98,10 @@ export { DateTimeInputBase } from './form/DateTimeInputBase.js';
|
|
|
98
98
|
export type { DateTimeInputBaseProps } from './form/DateTimeInputBase.js';
|
|
99
99
|
export { DateTimeInput } from './form/DateTimeInput.js';
|
|
100
100
|
export type { DateTimeInputProps } from './form/DateTimeInput.js';
|
|
101
|
+
export { DateRangeInputBase } from './form/DateRangeInputBase.js';
|
|
102
|
+
export type { DateRangeInputBaseProps, DateRangeValue, } from './form/DateRangeInputBase.js';
|
|
103
|
+
export { DateRangeInput } from './form/DateRangeInput.js';
|
|
104
|
+
export type { DateRangeInputProps } from './form/DateRangeInput.js';
|
|
101
105
|
export { useInsideField, useInsideControl } from './form/FormContext.js';
|
|
102
106
|
export type { FormFieldProps } from './form/fieldProps.js';
|
|
103
107
|
export * from './grid/Cell.js';
|
|
@@ -31,11 +31,22 @@ export interface TabsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'o
|
|
|
31
31
|
color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger' | 'black' | 'dark' | 'light' | 'white';
|
|
32
32
|
/** Controlled active tab index. */
|
|
33
33
|
value?: number;
|
|
34
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Callback when active tab changes. Called with the tab's `index` when a
|
|
36
|
+
* `Tabs.Tab` is activated: clicked, or Enter or Space pressed on it.
|
|
37
|
+
* Moving focus with the arrow keys, Home or End does not call it, because
|
|
38
|
+
* activation is manual: focus moves freely and the selected tab changes
|
|
39
|
+
* only when the user picks one.
|
|
40
|
+
*/
|
|
35
41
|
onChange?: (index: number) => void;
|
|
36
42
|
/** Initial active tab index (uncontrolled). */
|
|
37
43
|
defaultValue?: number;
|
|
38
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Renders tabs vertically. With a `Tabs.Content`, the tab list is also
|
|
46
|
+
* marked `aria-orientation="vertical"` and ArrowUp and ArrowDown move focus
|
|
47
|
+
* between tabs, alongside ArrowLeft and ArrowRight (the layout stacks
|
|
48
|
+
* horizontally on mobile).
|
|
49
|
+
*/
|
|
39
50
|
vertical?: boolean;
|
|
40
51
|
/** Side placement when `vertical` is true. */
|
|
41
52
|
side?: 'left' | 'right';
|
|
@@ -66,11 +77,18 @@ export declare const TabList: React.FC<TabListProps>;
|
|
|
66
77
|
type IconLibrary = 'fa' | 'mdi' | 'ion' | 'material-icons' | 'material-symbols';
|
|
67
78
|
/**
|
|
68
79
|
* Props for the Tab component.
|
|
80
|
+
* @extraProp {string} [id] - The tab's id, which its panel names in `aria-labelledby`. Generated inside a `Tabs` when omitted; a passed `id` is used and the panel follows it.
|
|
81
|
+
* @extraProp {React.KeyboardEventHandler<HTMLLIElement>} [onKeyDown] - Called before the tab handles the key; call `event.preventDefault()` to stop the tab handling it.
|
|
69
82
|
*/
|
|
70
83
|
export interface TabProps extends Omit<React.LiHTMLAttributes<HTMLLIElement>, 'onClick'> {
|
|
71
84
|
/** **Required.** Tab index for matching with content. */
|
|
72
85
|
index: number;
|
|
73
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* Disables the tab. A disabled tab is marked `aria-disabled`, cannot be
|
|
88
|
+
* activated, is skipped by the arrow keys, Home and End, and never holds
|
|
89
|
+
* the tab list's tab stop. The bestax extras styles also dim it and turn
|
|
90
|
+
* off its hover.
|
|
91
|
+
*/
|
|
74
92
|
disabled?: boolean;
|
|
75
93
|
/** Icon name for the tab. */
|
|
76
94
|
icon?: string;
|
|
@@ -90,6 +108,8 @@ export interface TabProps extends Omit<React.LiHTMLAttributes<HTMLLIElement>, 'o
|
|
|
90
108
|
/**
|
|
91
109
|
* Individual tab button. Consumes Tabs context for active state management.
|
|
92
110
|
* Renders `<a>` internally — consumers provide only the label text/children.
|
|
111
|
+
* Inside a `Tabs` it takes part in the tab list's keyboard support and links
|
|
112
|
+
* to the `Tabs.Content.Item` with the same `index`.
|
|
93
113
|
*
|
|
94
114
|
* @function
|
|
95
115
|
* @param {TabProps} props - Props for the Tab component.
|
|
@@ -129,6 +149,8 @@ export interface TabsContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
129
149
|
}
|
|
130
150
|
/**
|
|
131
151
|
* Props for the TabContentItem component.
|
|
152
|
+
* @extraProp {string} [id] - The panel's id, which its tab names in `aria-controls`. Generated inside a `Tabs` when omitted; a passed `id` is used and the tab follows it.
|
|
153
|
+
* @extraProp {number} [tabIndex] - The panel is not focusable by default. Pass `0` when it holds nothing focusable, so Tab moves from the tab list into it.
|
|
132
154
|
*/
|
|
133
155
|
export interface TabContentItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
134
156
|
/** **Required.** Tab index for matching with content. */
|
|
@@ -11,7 +11,10 @@ export interface DateInputBaseProps extends Omit<React.InputHTMLAttributes<HTMLI
|
|
|
11
11
|
value?: Date | null;
|
|
12
12
|
/** Initial date for uncontrolled usage. */
|
|
13
13
|
defaultValue?: Date | null;
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Fired when the value changes. A day picked in the calendar, by click or
|
|
16
|
+
* by key, arrives at local midnight.
|
|
17
|
+
*/
|
|
15
18
|
onChange?: (d: Date | null) => void;
|
|
16
19
|
/** Fired when the popover opens. */
|
|
17
20
|
onOpen?: () => void;
|
|
@@ -87,7 +90,7 @@ export interface DateInputBaseProps extends Omit<React.InputHTMLAttributes<HTMLI
|
|
|
87
90
|
* Open the popover when the input is focused. Focus that a closing popover
|
|
88
91
|
* hands back to the input leaves it closed. Dismissing it commits nothing:
|
|
89
92
|
* an empty field stays empty, and leaving afterwards commits only what was
|
|
90
|
-
* typed since.
|
|
93
|
+
* typed since. With it off, the launcher or Alt+ArrowDown opens it.
|
|
91
94
|
*/
|
|
92
95
|
openOnFocus?: boolean;
|
|
93
96
|
/** Close the popover after a date is selected. */
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FieldProps } from './Field.js';
|
|
3
|
+
import { ControlBaseProps } from './Control.js';
|
|
4
|
+
import { DateRangeInputBaseProps } from './DateRangeInputBase.js';
|
|
5
|
+
/**
|
|
6
|
+
* Props for the DateRangeInput convenience wrapper. Extends
|
|
7
|
+
* `DateRangeInputBaseProps` with Field-level (label, horizontal) and
|
|
8
|
+
* Control-level (icons, loading) props. Inside an existing `Control` it
|
|
9
|
+
* renders no `Control` of its own, so its Control-level props do nothing
|
|
10
|
+
* there and warn in development; set them on that `Control` instead. In
|
|
11
|
+
* `inline` mode it renders no `Control` anywhere, so they do nothing inside a
|
|
12
|
+
* `Control` or out, and warn in development there too. Inside an outer
|
|
13
|
+
* `Field`, or a `Control` with no `Field` around it, it renders no `Field` of
|
|
14
|
+
* its own either. The exception is
|
|
15
|
+
* `label`, `message`, `horizontal` or `fieldClassName` in that bare
|
|
16
|
+
* `Control`: it keeps a `Field` for them, nested in the `.control`, and warns
|
|
17
|
+
* in development. Wrap the `Control` in a `Field` instead.
|
|
18
|
+
* @extraProp {string} [className] - Additional CSS classes for the root, the `role="group"` that holds the two inputs.
|
|
19
|
+
* @extraProp {React.Ref<HTMLInputElement>} [ref] - Forwarded to the start `<input>`.
|
|
20
|
+
*/
|
|
21
|
+
export interface DateRangeInputProps extends DateRangeInputBaseProps {
|
|
22
|
+
/** Field label naming the whole range. Associated through `aria-labelledby` on the `role="group"` root, since it names two inputs rather than one; uses your `labelProps.id` when provided, otherwise a generated one. Each input keeps its own name, "Start date" or "End date" (`labels.rangeStart` / `labels.rangeEnd`). Dropped inside an outer `Field`. */
|
|
23
|
+
label?: React.ReactNode;
|
|
24
|
+
/** Size for the label. */
|
|
25
|
+
labelSize?: FieldProps['labelSize'];
|
|
26
|
+
/** Props for the label element. An `htmlFor` here is dropped, since the label names the group rather than one input. */
|
|
27
|
+
labelProps?: FieldProps['labelProps'];
|
|
28
|
+
/** Render the field with horizontal layout. */
|
|
29
|
+
horizontal?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Icon props for the left icon.
|
|
32
|
+
* Bulma gives control icons `pointer-events: none`, so a clickable node here
|
|
33
|
+
* never receives a click. Put a button beside the field in its own addon `Control` instead.
|
|
34
|
+
*/
|
|
35
|
+
iconLeft?: ControlBaseProps['iconLeft'];
|
|
36
|
+
/**
|
|
37
|
+
* Icon props for the right icon.
|
|
38
|
+
* Bulma gives control icons `pointer-events: none`, so a clickable node here
|
|
39
|
+
* never receives a click. Put a button beside the field in its own addon `Control` instead.
|
|
40
|
+
*/
|
|
41
|
+
iconRight?: ControlBaseProps['iconRight'];
|
|
42
|
+
/** Shortcut for the right icon name. */
|
|
43
|
+
iconRightName?: string;
|
|
44
|
+
/** Shortcut for left icon size. */
|
|
45
|
+
iconLeftSize?: ControlBaseProps['iconLeftSize'];
|
|
46
|
+
/** Shortcut for right icon size. */
|
|
47
|
+
iconRightSize?: ControlBaseProps['iconRightSize'];
|
|
48
|
+
/** Force the left icon container. */
|
|
49
|
+
hasIconsLeft?: boolean;
|
|
50
|
+
/** Force the right icon container. */
|
|
51
|
+
hasIconsRight?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Shows a loading spinner on the `Control` it renders, and hides the
|
|
54
|
+
* launcher (`triggerIcon`) while it does. Inside your own `Control` it
|
|
55
|
+
* renders none, so this draws nothing and warns in development; set
|
|
56
|
+
* `isLoading` on that `Control`.
|
|
57
|
+
*/
|
|
58
|
+
isLoading?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Show a clickable launcher button on the right that toggles the popover.
|
|
61
|
+
* Hidden by default while a spinner shows at the same right edge: this
|
|
62
|
+
* component's `isLoading` when it renders its own `Control`, or the
|
|
63
|
+
* enclosing `Control`'s `isLoading` inside one.
|
|
64
|
+
* @defaultValue true
|
|
65
|
+
*/
|
|
66
|
+
triggerIcon?: boolean;
|
|
67
|
+
/** Expand the control to fill its container. */
|
|
68
|
+
isExpanded?: boolean;
|
|
69
|
+
/** Size of the wrapping Control. */
|
|
70
|
+
controlSize?: ControlBaseProps['size'];
|
|
71
|
+
/** Help/validation text below the field. */
|
|
72
|
+
message?: React.ReactNode;
|
|
73
|
+
/** Color modifier for the help message. */
|
|
74
|
+
messageColor?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger';
|
|
75
|
+
/** Additional CSS classes for the Field wrapper. */
|
|
76
|
+
fieldClassName?: string;
|
|
77
|
+
/** Additional CSS classes for the Control wrapper. */
|
|
78
|
+
controlClassName?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The `DateRangeInput` component is a form input for a start and end date, picked from one popover calendar or typed into two segmented inputs.
|
|
82
|
+
*
|
|
83
|
+
* @function
|
|
84
|
+
* @param {DateRangeInputProps} props - Props for the DateRangeInput.
|
|
85
|
+
* @returns {JSX.Element}
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* <DateRangeInput label="Stay" name="stay" min={new Date()} />
|
|
89
|
+
*/
|
|
90
|
+
export declare const DateRangeInput: React.ForwardRefExoticComponent<DateRangeInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
91
|
+
export default DateRangeInput;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BulmaClassesProps } from '../helpers/useBulmaClasses.js';
|
|
3
|
+
import { DateRangeValue, DayOfWeek, PickerLabels, PickerPosition } from './_pickerInternals/pickerTypes.js';
|
|
4
|
+
import { DateFormatOption } from './_pickerInternals/formatters.js';
|
|
5
|
+
export type { DateRangeValue };
|
|
6
|
+
/**
|
|
7
|
+
* Props for the raw DateRangeInput base. Use the higher-level
|
|
8
|
+
* `DateRangeInput` for Field/Control composition; `DateRangeInputBase` is the
|
|
9
|
+
* two inputs and the popover only.
|
|
10
|
+
*/
|
|
11
|
+
export interface DateRangeInputBaseProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'onChange' | 'color' | 'placeholder' | 'popover'>, Omit<BulmaClassesProps, 'color'> {
|
|
12
|
+
/**
|
|
13
|
+
* Controlled range, start first. Either end may be `null`, and
|
|
14
|
+
* `[null, null]` is empty.
|
|
15
|
+
*/
|
|
16
|
+
value?: DateRangeValue;
|
|
17
|
+
/** Initial range for uncontrolled usage. */
|
|
18
|
+
defaultValue?: DateRangeValue;
|
|
19
|
+
/**
|
|
20
|
+
* Fired when the range changes, with the start first. Typing commits one
|
|
21
|
+
* end at a time, so a range half typed arrives as `[start, null]`. The
|
|
22
|
+
* calendar commits only a finished range: its first pick marks the start
|
|
23
|
+
* inside the calendar and its second commits both ends in one call. The
|
|
24
|
+
* range stays ordered, so the end is never before the start.
|
|
25
|
+
*/
|
|
26
|
+
onChange?: (range: DateRangeValue) => void;
|
|
27
|
+
/** Fired when the popover opens. */
|
|
28
|
+
onOpen?: () => void;
|
|
29
|
+
/** Fired when the popover closes. */
|
|
30
|
+
onClose?: () => void;
|
|
31
|
+
/**
|
|
32
|
+
* Earliest selectable date, for either end. A `min` before year 1 is raised
|
|
33
|
+
* to 1 January of year 1, where the range starts without one too.
|
|
34
|
+
*/
|
|
35
|
+
min?: Date;
|
|
36
|
+
/** Latest selectable date, for either end. */
|
|
37
|
+
max?: Date;
|
|
38
|
+
/** Disable both inputs and the launcher. */
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
/** Make both inputs read-only and keep the popover closed. */
|
|
41
|
+
readOnly?: boolean;
|
|
42
|
+
/** Placeholder text, shown in both inputs while they are empty. */
|
|
43
|
+
placeholder?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Token format string or `Intl.DateTimeFormat` options, used by both
|
|
46
|
+
* inputs.
|
|
47
|
+
* @defaultValue 'YYYY-MM-DD'
|
|
48
|
+
*/
|
|
49
|
+
format?: DateFormatOption;
|
|
50
|
+
/**
|
|
51
|
+
* Custom parser (use when `format` is `Intl.DateTimeFormatOptions`).
|
|
52
|
+
* Enter and leaving an input call it only if the user changed its text.
|
|
53
|
+
*/
|
|
54
|
+
parse?: (s: string) => Date | null;
|
|
55
|
+
/** BCP-47 locale tag for day/month names and Intl formatting. */
|
|
56
|
+
locale?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Render the calendar inline, with no inputs and no popover. The hidden
|
|
59
|
+
* form inputs still carry the range.
|
|
60
|
+
*/
|
|
61
|
+
inline?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Use two native `<input type="date">`s on coarse-pointer, small-viewport
|
|
64
|
+
* devices (`'auto'`), always (`true`) or never (`false`). The end input's
|
|
65
|
+
* `min` follows the start, and a change goes through the same rules as
|
|
66
|
+
* typing.
|
|
67
|
+
*/
|
|
68
|
+
mobileNative?: boolean | 'auto';
|
|
69
|
+
/** Allow segmented keyboard typing in both inputs. `false` makes the field picker-only. */
|
|
70
|
+
editable?: boolean;
|
|
71
|
+
/** Whether the calendar popover exists. `false` makes the field input-only. */
|
|
72
|
+
popover?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Open the popover when focus arrives in the field. Moving focus between
|
|
75
|
+
* the two inputs, or back from the launcher, leaves it closed, and so does
|
|
76
|
+
* the focus a closing popover hands back. A click on either input opens it.
|
|
77
|
+
* With it off, the launcher or Alt+ArrowDown opens it.
|
|
78
|
+
*/
|
|
79
|
+
openOnFocus?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Close the popover once the range is picked. The first pick, which only
|
|
82
|
+
* marks the start, never closes it.
|
|
83
|
+
*/
|
|
84
|
+
closeOnSelect?: boolean;
|
|
85
|
+
/** Popover anchor position relative to the field. */
|
|
86
|
+
position?: PickerPosition;
|
|
87
|
+
/** Render the popover into `document.body` via portal. */
|
|
88
|
+
appendToBody?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Bulma color modifier for the field, also carried by the calendar, where it
|
|
91
|
+
* colors the range's ends and the band between them.
|
|
92
|
+
*/
|
|
93
|
+
color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger';
|
|
94
|
+
/** Size variant. */
|
|
95
|
+
size?: 'small' | 'medium' | 'large';
|
|
96
|
+
/** Render the field with rounded corners. */
|
|
97
|
+
isRounded?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Predicate to disable specific dates (e.g. weekends). A disabled day can
|
|
100
|
+
* be neither end, typing rejects it, and a range can't include one unless
|
|
101
|
+
* `allowDisabledInRange` is set.
|
|
102
|
+
*/
|
|
103
|
+
shouldDisableDate?: (d: Date) => boolean;
|
|
104
|
+
/** Convenience array of disabled dates; merged with `shouldDisableDate`. Matched by calendar day. */
|
|
105
|
+
unselectableDates?: Date[];
|
|
106
|
+
/**
|
|
107
|
+
* Let a range include days that `shouldDisableDate` or `unselectableDates`
|
|
108
|
+
* disable, such as a stay over a night with no check-ins. Its ends still
|
|
109
|
+
* can't be such days. Off, a pick in the calendar past a disabled day
|
|
110
|
+
* starts a new range there, typing refuses an end past one, and a start
|
|
111
|
+
* typed with one before the end clears the end. Finding one walks the days
|
|
112
|
+
* between, so off, a span too long to walk is refused as well.
|
|
113
|
+
*/
|
|
114
|
+
allowDisabledInRange?: boolean;
|
|
115
|
+
/** Day the week starts on (0 = Sunday). */
|
|
116
|
+
firstDayOfWeek?: DayOfWeek;
|
|
117
|
+
/** Override the 7 day-name labels (in calendar order, post-rotation). */
|
|
118
|
+
dayNames?: string[];
|
|
119
|
+
/** Override the 12 month-name labels. */
|
|
120
|
+
monthNames?: string[];
|
|
121
|
+
/** Show dimmed dates from adjacent months in the grid. */
|
|
122
|
+
nearbyMonthDays?: boolean;
|
|
123
|
+
/** Decorative left icon glyph for the wrapping `Control` (shown by default). Set `''` to hide. */
|
|
124
|
+
iconLeftName?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Show a clickable launcher button on the right that toggles the popover.
|
|
127
|
+
* Hidden by default while a `Control` it sits in shows its `isLoading`
|
|
128
|
+
* spinner, which shares that right edge.
|
|
129
|
+
* @defaultValue true
|
|
130
|
+
*/
|
|
131
|
+
triggerIcon?: boolean;
|
|
132
|
+
/** Glyph for the right launcher button. */
|
|
133
|
+
triggerIconName?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Optional translatable string overrides. `rangeStart` and `rangeEnd` name
|
|
136
|
+
* the two inputs and the range's ends in the calendar, `rangePreviewEnd`
|
|
137
|
+
* describes the day a pending range would end on, `rangeSeparator` sits
|
|
138
|
+
* between the inputs, and `chooseDateRange` names the launcher and the
|
|
139
|
+
* popover.
|
|
140
|
+
*/
|
|
141
|
+
labels?: PickerLabels;
|
|
142
|
+
/**
|
|
143
|
+
* Form field name. Two hidden inputs submit the range as `YYYY-MM-DD`,
|
|
144
|
+
* named `name[start]` and `name[end]`, in every mode. The visible inputs
|
|
145
|
+
* carry no name.
|
|
146
|
+
*/
|
|
147
|
+
name?: string;
|
|
148
|
+
/** Name of the hidden input carrying the start, in place of `name[start]`. */
|
|
149
|
+
startName?: string;
|
|
150
|
+
/** Name of the hidden input carrying the end, in place of `name[end]`. */
|
|
151
|
+
endName?: string;
|
|
152
|
+
/** Form id the hidden inputs belong to. */
|
|
153
|
+
form?: string;
|
|
154
|
+
/**
|
|
155
|
+
* Mark both visible inputs required, so a form won't submit with either
|
|
156
|
+
* end empty. An `inline` calendar has no visible input, so it is not
|
|
157
|
+
* checked there.
|
|
158
|
+
*/
|
|
159
|
+
required?: boolean;
|
|
160
|
+
/** Id of the start input. The end input takes `${id}-end`. */
|
|
161
|
+
id?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Raw DateRangeInput: the two inputs and the popover calendar without
|
|
165
|
+
* Field/Control wrapping. Use `DateRangeInput` for the convenience wrapper.
|
|
166
|
+
*
|
|
167
|
+
* @function
|
|
168
|
+
* @param {DateRangeInputBaseProps} props
|
|
169
|
+
* @returns {JSX.Element}
|
|
170
|
+
*/
|
|
171
|
+
export declare const DateRangeInputBase: React.ForwardRefExoticComponent<DateRangeInputBaseProps & React.RefAttributes<HTMLInputElement>>;
|
|
172
|
+
export default DateRangeInputBase;
|
|
@@ -12,7 +12,12 @@ export interface DateTimeInputBaseProps extends Omit<React.InputHTMLAttributes<H
|
|
|
12
12
|
value?: Date | null;
|
|
13
13
|
/** Initial value for uncontrolled usage. */
|
|
14
14
|
defaultValue?: Date | null;
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Fired when either the date or time portion changes. Picking a day keeps
|
|
17
|
+
* the value's whole time of day, down to seconds and milliseconds the field
|
|
18
|
+
* doesn't show, and `min` and `max` judge the picked day at that time. An
|
|
19
|
+
* empty field's day is picked at midnight.
|
|
20
|
+
*/
|
|
16
21
|
onChange?: (d: Date | null) => void;
|
|
17
22
|
/** Fired when the popover opens. */
|
|
18
23
|
onOpen?: () => void;
|
|
@@ -58,7 +63,7 @@ export interface DateTimeInputBaseProps extends Omit<React.InputHTMLAttributes<H
|
|
|
58
63
|
* Open the popover on focus. Default `true`. Focus that a closing popover
|
|
59
64
|
* hands back to the input leaves it closed. Dismissing it commits nothing:
|
|
60
65
|
* an empty field stays empty, and leaving afterwards commits only what was
|
|
61
|
-
* typed since.
|
|
66
|
+
* typed since. With it off, the launcher or Alt+ArrowDown opens it.
|
|
62
67
|
*/
|
|
63
68
|
openOnFocus?: boolean;
|
|
64
69
|
/** Off by default — users typically tweak both halves before committing. */
|
|
@@ -31,7 +31,12 @@ export interface FileProps extends Omit<React.InputHTMLAttributes<HTMLInputEleme
|
|
|
31
31
|
isRight?: boolean;
|
|
32
32
|
/** Center the file input within its container. */
|
|
33
33
|
isCentered?: boolean;
|
|
34
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Show a file name area. Without `fileName` it shows what the user picked: the file's name, or
|
|
36
|
+
* a count when `multiple` lets them pick several (see `pickedFilesLabel`). Before a pick there is
|
|
37
|
+
* no name area. A reset of the input's form clears the name, but clearing the input from code
|
|
38
|
+
* fires no change event and leaves it showing, so pass `fileName` to control the text then.
|
|
39
|
+
*/
|
|
35
40
|
hasName?: boolean;
|
|
36
41
|
/** Text on the file CTA button (defaults to "Choose a file…"). */
|
|
37
42
|
buttonLabel?: React.ReactNode;
|
|
@@ -50,8 +55,16 @@ export interface FileProps extends Omit<React.InputHTMLAttributes<HTMLInputEleme
|
|
|
50
55
|
className?: string;
|
|
51
56
|
/** Additional CSS classes for the `<input>`. */
|
|
52
57
|
inputClassName?: string;
|
|
53
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* Text for the file name area (with `hasName`), for a file chosen earlier or your own wording.
|
|
60
|
+
* Setting it takes over from the picked file's name; an empty string shows no name area.
|
|
61
|
+
*/
|
|
54
62
|
fileName?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Builds the text `hasName` shows when several files are picked, from their count, for
|
|
65
|
+
* localization. Default: `` `${count} files` ``. A single pick shows its file's name.
|
|
66
|
+
*/
|
|
67
|
+
pickedFilesLabel?: (count: number) => string;
|
|
55
68
|
}
|
|
56
69
|
/**
|
|
57
70
|
* The `File` component provides a Bulma-styled file input, supporting color, size, boxed/fullwidth/align styles, icons, "has name", and filename display.
|
|
@@ -76,6 +76,13 @@ interface OwnControlOptions extends ControlLevelProps {
|
|
|
76
76
|
insideControl: boolean;
|
|
77
77
|
/** A picker's `inline`, which renders no `Control` inside one or out. */
|
|
78
78
|
inline?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* The left glyph the wrapper's own `Control` shows when the caller sets no
|
|
81
|
+
* `iconLeftName`; read only then. `bare-control.test.tsx` reads that glyph
|
|
82
|
+
* from what each wrapper hands its own `Control`, so a wrapper that gains
|
|
83
|
+
* one fails there until it passes it here.
|
|
84
|
+
*/
|
|
85
|
+
defaultIconLeftName?: string;
|
|
79
86
|
}
|
|
80
87
|
/**
|
|
81
88
|
* Whether a convenience form wrapper renders a `Control` of its own (#921):
|
|
@@ -87,6 +94,10 @@ interface OwnControlOptions extends ControlLevelProps {
|
|
|
87
94
|
* only the props it hands its own `Control`, as the caller gave them, so a
|
|
88
95
|
* default the wrapper fills in itself never warns. A prop counts when it is
|
|
89
96
|
* truthy, since a falsy one would change nothing on a `Control` either.
|
|
97
|
+
* `iconLeftSize` and `hasIconsLeft` show nothing on a `Control` without a
|
|
98
|
+
* glyph, so when they move and the caller chose no left icon, the advice
|
|
99
|
+
* names the wrapper's default glyph too, and following it draws what the
|
|
100
|
+
* wrapper's own `Control` did.
|
|
90
101
|
* Internal; not part of the public API.
|
|
91
102
|
*/
|
|
92
103
|
export declare const rendersOwnControl: (component: string, options: OwnControlOptions) => boolean;
|
|
@@ -45,7 +45,14 @@ export interface NumberinputProps extends Omit<React.InputHTMLAttributes<HTMLInp
|
|
|
45
45
|
controlsRounded?: boolean;
|
|
46
46
|
/** Uses compact button spacing. */
|
|
47
47
|
compact?: boolean;
|
|
48
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Renders the plusminus controls without a `.field` row of their own, so
|
|
50
|
+
* they join the row of a `Field` with `hasAddons` or `grouped` they sit
|
|
51
|
+
* in. On by default inside a `Field`, unless a `Control` is anywhere above
|
|
52
|
+
* it: a `Control` stacks its children, so there the controls keep their
|
|
53
|
+
* own row.
|
|
54
|
+
* @defaultValue auto
|
|
55
|
+
*/
|
|
49
56
|
bare?: boolean;
|
|
50
57
|
/** Style variant for the control buttons. */
|
|
51
58
|
variant?: NumberinputVariant;
|
|
@@ -56,7 +56,7 @@ export interface TimeInputBaseProps extends Omit<React.InputHTMLAttributes<HTMLI
|
|
|
56
56
|
* Open the popover when the input is focused. Focus that a closing popover
|
|
57
57
|
* hands back to the input leaves it closed. Dismissing it commits nothing:
|
|
58
58
|
* an empty field stays empty, and leaving afterwards commits only what was
|
|
59
|
-
* typed since.
|
|
59
|
+
* typed since. With it off, the launcher or Alt+ArrowDown opens it.
|
|
60
60
|
*/
|
|
61
61
|
openOnFocus?: boolean;
|
|
62
62
|
/** Close the popover after a time is selected (off by default). */
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { DateGranularity, DayOfWeek, PickerLabels } from './pickerTypes.js';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { DateGranularity, DateRangeValue, DayOfWeek, PickerLabels } from './pickerTypes.js';
|
|
3
|
+
/** What every calendar takes, whichever way it picks. */
|
|
4
|
+
interface CalendarBaseProps {
|
|
5
5
|
focusedDate: Date;
|
|
6
|
-
onSelect: (d: Date) => void;
|
|
7
6
|
onFocusedDateChange: (d: Date) => void;
|
|
8
7
|
/**
|
|
9
8
|
* Earliest selectable date. One before year 1, or none, counts as the start
|
|
@@ -47,6 +46,48 @@ export interface CalendarProps {
|
|
|
47
46
|
*/
|
|
48
47
|
granularity?: DateGranularity;
|
|
49
48
|
}
|
|
49
|
+
/** A calendar that picks one day, month or year. */
|
|
50
|
+
interface CalendarSingleProps {
|
|
51
|
+
/** The selected date. */
|
|
52
|
+
value: Date | null;
|
|
53
|
+
/** Called with a picked date, or the first day of a picked period. */
|
|
54
|
+
onSelect: (d: Date) => void;
|
|
55
|
+
range?: never;
|
|
56
|
+
onRangeSelect?: never;
|
|
57
|
+
allowDisabledInRange?: never;
|
|
58
|
+
}
|
|
59
|
+
/** A calendar that picks a range of days. */
|
|
60
|
+
interface CalendarRangeProps {
|
|
61
|
+
/**
|
|
62
|
+
* The committed range, start first, which turns on range mode. The day grid
|
|
63
|
+
* then picks two days: the first pick marks a start inside the calendar and
|
|
64
|
+
* commits nothing, and the second calls `onRangeSelect` with both ends. A
|
|
65
|
+
* pick that cannot end the range starts a new one instead: one before the
|
|
66
|
+
* start, or one past a disabled day unless `allowDisabledInRange` is set.
|
|
67
|
+
* While a start is pending the grid previews the range to the hovered day,
|
|
68
|
+
* or to the focused day, and hides the committed one. A range with a start
|
|
69
|
+
* and no end opens with that start pending. Escape takes back a pending pick
|
|
70
|
+
* and stops there, so a popover around the calendar stays open; a pending
|
|
71
|
+
* start that came from `range` is not a pick, and Escape goes on.
|
|
72
|
+
*/
|
|
73
|
+
range: DateRangeValue;
|
|
74
|
+
/** Called with both ends once the second day is picked. */
|
|
75
|
+
onRangeSelect: (start: Date, end: Date) => void;
|
|
76
|
+
/**
|
|
77
|
+
* Let a range include days that `shouldDisableDate` or `unselectableDates`
|
|
78
|
+
* disable. Its ends can still not be such days.
|
|
79
|
+
*/
|
|
80
|
+
allowDisabledInRange?: boolean;
|
|
81
|
+
/** Only the day grid picks a range. */
|
|
82
|
+
granularity?: 'day';
|
|
83
|
+
value?: never;
|
|
84
|
+
onSelect?: never;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The calendar picks one date through `value` and `onSelect`, or a range
|
|
88
|
+
* through `range` and `onRangeSelect`, and its props take exactly one pair.
|
|
89
|
+
*/
|
|
90
|
+
export type CalendarProps = CalendarBaseProps & (CalendarSingleProps | CalendarRangeProps);
|
|
50
91
|
/**
|
|
51
92
|
* Selects the calendar's focused cell, the one tab stop of whichever grid or
|
|
52
93
|
* year list is on show, for a popover to put focus on as it opens. It runs
|
|
@@ -60,16 +60,40 @@ export declare function isDayUnselectable(d: Date, c: DayConstraints): boolean;
|
|
|
60
60
|
* of 3pm on a month's last day leaves that day, and so its month, selectable.
|
|
61
61
|
*/
|
|
62
62
|
export declare function isPeriodUnselectable(d: Date, granularity: DateGranularity, c: DayConstraints): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* The most days {@link canCloseRange} walks between a range's ends, about
|
|
65
|
+
* eleven years. A span it would have to walk further is refused, so the check
|
|
66
|
+
* stays cheap enough to run on every pointer move over the calendar.
|
|
67
|
+
*/
|
|
68
|
+
export declare const RANGE_WALK_LIMIT = 4000;
|
|
69
|
+
/**
|
|
70
|
+
* Whether `end` can close a range that opens on `start`: it falls on `start`'s
|
|
71
|
+
* day or later, and, unless `allowDisabled`, no day between the two is one
|
|
72
|
+
* that `shouldDisableDate` or `unselectableDates` disables. Checking that
|
|
73
|
+
* walks the days between, so with either rule set and `allowDisabled` off,
|
|
74
|
+
* an `end` more than {@link RANGE_WALK_LIMIT} days after `start` is refused.
|
|
75
|
+
* The ends' own constraints, `min` and `max` among them, are the caller's to
|
|
76
|
+
* check. Bounds can't fall between two days inside them, so they are not
|
|
77
|
+
* walked.
|
|
78
|
+
*/
|
|
79
|
+
export declare function canCloseRange(start: Date, end: Date, c: DayConstraints, allowDisabled?: boolean): boolean;
|
|
63
80
|
export declare function addDays(d: Date, n: number): Date;
|
|
64
81
|
export declare function addMonths(d: Date, n: number): Date;
|
|
65
82
|
export declare function addYears(d: Date, n: number): Date;
|
|
66
83
|
export declare function addHours(d: Date, n: number): Date;
|
|
67
84
|
export declare function addMinutes(d: Date, n: number): Date;
|
|
68
85
|
export declare function addSeconds(d: Date, n: number): Date;
|
|
86
|
+
/**
|
|
87
|
+
* A copy of `d` with the given parts of its time of day set and the rest
|
|
88
|
+
* left as they are. A time started from the clock rather than from a value
|
|
89
|
+
* should pass the seconds its picker does not show, and the milliseconds,
|
|
90
|
+
* as `0`, or it keeps the ones the clock had.
|
|
91
|
+
*/
|
|
69
92
|
export declare function setTimeOfDay(d: Date, parts: {
|
|
70
93
|
hours?: number;
|
|
71
94
|
minutes?: number;
|
|
72
95
|
seconds?: number;
|
|
96
|
+
milliseconds?: number;
|
|
73
97
|
}): Date;
|
|
74
98
|
export declare function getTimeOfDay(d: Date): {
|
|
75
99
|
hours: number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DateGranularity } from './pickerTypes.js';
|
|
1
2
|
export type DateFormatOption = Intl.DateTimeFormatOptions | string;
|
|
2
3
|
export declare const DEFAULT_DATE_FORMAT = "YYYY-MM-DD";
|
|
3
4
|
export declare const DEFAULT_MONTH_FORMAT = "YYYY-MM";
|
|
@@ -8,6 +9,19 @@ export declare const DEFAULT_DATETIME_FORMAT = "YYYY-MM-DD HH:mm";
|
|
|
8
9
|
export declare function formatDate(d: Date, fmt: DateFormatOption | undefined, locale?: string): string;
|
|
9
10
|
export declare function formatTime(d: Date, fmt: DateFormatOption | undefined, locale?: string): string;
|
|
10
11
|
export declare function formatDateTime(d: Date, fmt: DateFormatOption | undefined, locale?: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* The value as a native input and a hidden form input carry it:
|
|
14
|
+
* `YYYY-MM-DD`, `YYYY-MM` or `YYYY`, the shapes `<input type="date">` and
|
|
15
|
+
* `<input type="month">` use. The year is padded to four digits, as those
|
|
16
|
+
* inputs require and as the `YYYY` token displays it. HTML has no such shape
|
|
17
|
+
* for a year before 1, so a date then is empty, as those inputs would make it.
|
|
18
|
+
*/
|
|
19
|
+
export declare function toIsoValue(d: Date, granularity: DateGranularity): string;
|
|
20
|
+
/**
|
|
21
|
+
* Read a native `type="date"` or `type="month"` value back into a Date. HTML
|
|
22
|
+
* allows a year of four or more digits, as `toIsoValue` writes one past 9999.
|
|
23
|
+
*/
|
|
24
|
+
export declare function fromIsoValue(s: string, granularity: DateGranularity): Date | null;
|
|
11
25
|
/**
|
|
12
26
|
* Derive the hour cycle (`'12'` or `'24'`) a display format will render, from
|
|
13
27
|
* its first hour token: `h`/`hh` → 12-hour with meridiem, `H`/`HH` → 24-hour.
|