@carbon/react 1.113.0 → 1.114.0-rc.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/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +901 -901
- package/es/components/DatePicker/DatePicker.d.ts +10 -0
- package/es/components/DatePicker/DatePicker.js +6 -5
- package/es/components/DatePicker/next/components/Calendar.d.ts +40 -0
- package/es/components/DatePicker/next/components/Calendar.js +181 -0
- package/es/components/DatePicker/next/components/DatePicker.d.ts +86 -0
- package/es/components/DatePicker/next/components/DatePicker.js +147 -0
- package/es/components/DatePicker/next/components/DatePickerInput.d.ts +143 -0
- package/es/components/DatePicker/next/components/DatePickerInput.js +124 -0
- package/es/components/DatePicker/next/components/DatePickerSkeleton.d.ts +22 -0
- package/es/components/DatePicker/next/components/DatePickerSkeleton.js +32 -0
- package/es/components/DatePicker/next/hooks/useDatePicker.d.ts +144 -0
- package/es/components/DatePicker/next/hooks/useDatePicker.js +286 -0
- package/es/components/DatePicker/next/index.d.ts +12 -0
- package/es/components/DatePicker/next/index.js +19 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/es/internal/checkForOverflow.d.ts +5 -0
- package/es/internal/useFocus.d.ts +23 -0
- package/es/internal/usePrefersReducedMotion.d.ts +11 -0
- package/es/internal/useSidePanelPresence.d.ts +21 -0
- package/lib/components/DatePicker/DatePicker.d.ts +10 -0
- package/lib/components/DatePicker/DatePicker.js +6 -5
- package/lib/components/DatePicker/next/components/Calendar.d.ts +40 -0
- package/lib/components/DatePicker/next/components/Calendar.js +184 -0
- package/lib/components/DatePicker/next/components/DatePicker.d.ts +86 -0
- package/lib/components/DatePicker/next/components/DatePicker.js +150 -0
- package/lib/components/DatePicker/next/components/DatePickerInput.d.ts +143 -0
- package/lib/components/DatePicker/next/components/DatePickerInput.js +127 -0
- package/lib/components/DatePicker/next/components/DatePickerSkeleton.d.ts +22 -0
- package/lib/components/DatePicker/next/components/DatePickerSkeleton.js +41 -0
- package/lib/components/DatePicker/next/hooks/useDatePicker.d.ts +144 -0
- package/lib/components/DatePicker/next/hooks/useDatePicker.js +286 -0
- package/lib/components/DatePicker/next/index.d.ts +12 -0
- package/lib/components/DatePicker/next/index.js +27 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +29 -22
- package/lib/internal/checkForOverflow.d.ts +5 -0
- package/lib/internal/useFocus.d.ts +23 -0
- package/lib/internal/usePrefersReducedMotion.d.ts +11 -0
- package/lib/internal/useSidePanelPresence.d.ts +21 -0
- package/package.json +11 -11
- package/scss/components/action-set/_action-set.scss +9 -0
- package/scss/components/action-set/_index.scss +9 -0
- package/scss/components/resizer/_index.scss +9 -0
- package/scss/components/resizer/_resizer.scss +9 -0
- package/scss/components/side-panel/_index.scss +9 -0
- package/scss/components/side-panel/_side-panel.scss +9 -0
- package/scss/components/truncated-text/_index.scss +9 -0
- package/scss/components/truncated-text/_truncated-text.scss +9 -0
- package/telemetry.yml +41 -1
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
/**
|
|
9
|
+
* DatePickerInput component props
|
|
10
|
+
* Maintains 100% backwards compatibility with Carbon React v11 API
|
|
11
|
+
*/
|
|
12
|
+
export interface DatePickerInputProps {
|
|
13
|
+
/**
|
|
14
|
+
* The unique identifier for the input (required)
|
|
15
|
+
*/
|
|
16
|
+
id: string;
|
|
17
|
+
/**
|
|
18
|
+
* The label text
|
|
19
|
+
*/
|
|
20
|
+
labelText?: React.ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* The placeholder text
|
|
23
|
+
*/
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The input size
|
|
27
|
+
*/
|
|
28
|
+
size?: 'sm' | 'md' | 'lg';
|
|
29
|
+
/**
|
|
30
|
+
* Whether the input is disabled
|
|
31
|
+
*/
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the input is invalid
|
|
35
|
+
*/
|
|
36
|
+
invalid?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The invalid text to display
|
|
39
|
+
*/
|
|
40
|
+
invalidText?: React.ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the input has a warning
|
|
43
|
+
*/
|
|
44
|
+
warn?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The warning text to display
|
|
47
|
+
*/
|
|
48
|
+
warnText?: React.ReactNode;
|
|
49
|
+
/**
|
|
50
|
+
* Helper text to display below the input
|
|
51
|
+
*/
|
|
52
|
+
helperText?: React.ReactNode;
|
|
53
|
+
/**
|
|
54
|
+
* Whether to hide the label visually (still accessible)
|
|
55
|
+
*/
|
|
56
|
+
hideLabel?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Additional CSS class names
|
|
59
|
+
*/
|
|
60
|
+
className?: string;
|
|
61
|
+
/**
|
|
62
|
+
* The input value
|
|
63
|
+
*/
|
|
64
|
+
value?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Default value for uncontrolled component
|
|
67
|
+
*/
|
|
68
|
+
defaultValue?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Change handler
|
|
71
|
+
*/
|
|
72
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
73
|
+
/**
|
|
74
|
+
* Focus handler
|
|
75
|
+
*/
|
|
76
|
+
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
77
|
+
/**
|
|
78
|
+
* Blur handler
|
|
79
|
+
*/
|
|
80
|
+
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Keydown handler
|
|
83
|
+
*/
|
|
84
|
+
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Click handler
|
|
87
|
+
*/
|
|
88
|
+
onClick?: (event: React.MouseEvent<HTMLInputElement>) => void;
|
|
89
|
+
/**
|
|
90
|
+
* Icon description for accessibility
|
|
91
|
+
*/
|
|
92
|
+
iconDescription?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Calendar icon click handler
|
|
95
|
+
*/
|
|
96
|
+
onIconClick?: () => void;
|
|
97
|
+
/**
|
|
98
|
+
* Whether to show the calendar icon
|
|
99
|
+
*/
|
|
100
|
+
hideIcon?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Pattern for input validation
|
|
103
|
+
*/
|
|
104
|
+
pattern?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Type of input
|
|
107
|
+
*/
|
|
108
|
+
type?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Whether the input is read-only
|
|
111
|
+
*/
|
|
112
|
+
readOnly?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Autocomplete attribute
|
|
115
|
+
*/
|
|
116
|
+
autoComplete?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Name attribute
|
|
119
|
+
*/
|
|
120
|
+
name?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Whether the field is required
|
|
123
|
+
*/
|
|
124
|
+
required?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Callback when calendar opens (for internal use)
|
|
127
|
+
*/
|
|
128
|
+
onOpen?: () => void;
|
|
129
|
+
/**
|
|
130
|
+
* Decorator component (e.g., AI Label)
|
|
131
|
+
*/
|
|
132
|
+
decorator?: React.ReactNode;
|
|
133
|
+
/**
|
|
134
|
+
* @deprecated Use `decorator` instead. Will be removed in next major version.
|
|
135
|
+
*/
|
|
136
|
+
slug?: React.ReactNode;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* DatePickerInput component
|
|
140
|
+
* Input field for date picker with Carbon Design System styling
|
|
141
|
+
* Maintains 100% backwards compatibility with Carbon React v11
|
|
142
|
+
*/
|
|
143
|
+
export declare const DatePickerInput: React.ForwardRefExoticComponent<DatePickerInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
|
|
9
|
+
const require_usePrefix = require("../../../../internal/usePrefix.js");
|
|
10
|
+
let react = require("react");
|
|
11
|
+
react = require_runtime.__toESM(react);
|
|
12
|
+
let classnames = require("classnames");
|
|
13
|
+
classnames = require_runtime.__toESM(classnames);
|
|
14
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
15
|
+
//#region src/components/DatePicker/next/components/DatePickerInput.tsx
|
|
16
|
+
/**
|
|
17
|
+
* Copyright IBM Corp. 2026
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
20
|
+
* LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* DatePickerInput component
|
|
24
|
+
* Input field for date picker with Carbon Design System styling
|
|
25
|
+
* Maintains 100% backwards compatibility with Carbon React v11
|
|
26
|
+
*/
|
|
27
|
+
const DatePickerInput = (0, react.forwardRef)(function DatePickerInput({ id, labelText, placeholder = "mm/dd/yyyy", size = "md", disabled = false, invalid = false, invalidText, warn = false, warnText, helperText, hideLabel = false, className, value, defaultValue, onChange, onFocus, onBlur, onKeyDown, onClick, iconDescription = "Open calendar", onIconClick, hideIcon = false, pattern, type = "text", readOnly = false, autoComplete = "off", name, required = false, onOpen: _onOpen, decorator, slug, ...rest }, ref) {
|
|
28
|
+
const prefix = require_usePrefix.usePrefix();
|
|
29
|
+
const candidate = decorator || slug;
|
|
30
|
+
const normalizedDecorator = candidate && (0, react.isValidElement)(candidate) && candidate.type?.displayName === "AILabel" && (0, react.isValidElement)(candidate) ? (0, react.cloneElement)(candidate, { size: "mini" }) : candidate;
|
|
31
|
+
const wrapperClasses = (0, classnames.default)(`${prefix}--date-picker-input__wrapper`, className, {
|
|
32
|
+
[`${prefix}--date-picker-input__wrapper--slug`]: slug,
|
|
33
|
+
[`${prefix}--date-picker-input__wrapper--decorator`]: decorator
|
|
34
|
+
});
|
|
35
|
+
const inputClasses = (0, classnames.default)(`${prefix}--date-picker__input`, {
|
|
36
|
+
[`${prefix}--date-picker__input--sm`]: size === "sm",
|
|
37
|
+
[`${prefix}--date-picker__input--lg`]: size === "lg",
|
|
38
|
+
[`${prefix}--date-picker__input--invalid`]: invalid,
|
|
39
|
+
[`${prefix}--date-picker__input--warn`]: warn && !invalid
|
|
40
|
+
});
|
|
41
|
+
const labelClasses = (0, classnames.default)(`${prefix}--label`, {
|
|
42
|
+
[`${prefix}--visually-hidden`]: hideLabel,
|
|
43
|
+
[`${prefix}--label--disabled`]: disabled
|
|
44
|
+
});
|
|
45
|
+
const showInvalidText = invalid && invalidText;
|
|
46
|
+
const showWarnText = !invalid && warn && warnText;
|
|
47
|
+
const showHelperText = !invalid && !warn && helperText;
|
|
48
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
49
|
+
labelText && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
50
|
+
htmlFor: id,
|
|
51
|
+
className: labelClasses,
|
|
52
|
+
children: [labelText, required && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
53
|
+
className: `${prefix}--label__required`,
|
|
54
|
+
children: "*"
|
|
55
|
+
})]
|
|
56
|
+
}),
|
|
57
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
58
|
+
className: wrapperClasses,
|
|
59
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
60
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
61
|
+
...rest,
|
|
62
|
+
ref,
|
|
63
|
+
id,
|
|
64
|
+
name,
|
|
65
|
+
type,
|
|
66
|
+
className: inputClasses,
|
|
67
|
+
placeholder,
|
|
68
|
+
value,
|
|
69
|
+
defaultValue,
|
|
70
|
+
disabled,
|
|
71
|
+
readOnly,
|
|
72
|
+
pattern,
|
|
73
|
+
autoComplete,
|
|
74
|
+
required,
|
|
75
|
+
onChange,
|
|
76
|
+
onFocus,
|
|
77
|
+
onBlur,
|
|
78
|
+
onKeyDown,
|
|
79
|
+
onClick,
|
|
80
|
+
"aria-invalid": invalid || void 0,
|
|
81
|
+
"aria-describedby": showInvalidText ? `${id}-error` : showWarnText ? `${id}-warn` : showHelperText ? `${id}-helper` : void 0
|
|
82
|
+
}),
|
|
83
|
+
slug ? normalizedDecorator : decorator ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
84
|
+
className: `${prefix}--date-picker-input-inner-wrapper--decorator`,
|
|
85
|
+
children: normalizedDecorator
|
|
86
|
+
}) : null,
|
|
87
|
+
!hideIcon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
88
|
+
type: "button",
|
|
89
|
+
className: `${prefix}--date-picker__icon`,
|
|
90
|
+
onClick: onIconClick,
|
|
91
|
+
disabled: disabled || readOnly,
|
|
92
|
+
"aria-label": iconDescription,
|
|
93
|
+
tabIndex: -1,
|
|
94
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
95
|
+
focusable: "false",
|
|
96
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
97
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
98
|
+
fill: "currentColor",
|
|
99
|
+
width: "16",
|
|
100
|
+
height: "16",
|
|
101
|
+
viewBox: "0 0 32 32",
|
|
102
|
+
"aria-hidden": "true",
|
|
103
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M26,4h-4V2h-2v2h-8V2h-2v2H6C4.9,4,4,4.9,4,6v20c0,1.1,0.9,2,2,2h20c1.1,0,2-0.9,2-2V6C28,4.9,27.1,4,26,4z M26,26H6V12h20 V26z M26,10H6V6h4v2h2V6h8v2h2V6h4V10z" })
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
] })
|
|
107
|
+
}),
|
|
108
|
+
showInvalidText && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
109
|
+
id: `${id}-error`,
|
|
110
|
+
className: `${prefix}--form-requirement`,
|
|
111
|
+
children: invalidText
|
|
112
|
+
}),
|
|
113
|
+
showWarnText && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
114
|
+
id: `${id}-warn`,
|
|
115
|
+
className: `${prefix}--form-requirement`,
|
|
116
|
+
children: warnText
|
|
117
|
+
}),
|
|
118
|
+
showHelperText && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
119
|
+
id: `${id}-helper`,
|
|
120
|
+
className: `${prefix}--form__helper-text`,
|
|
121
|
+
children: helperText
|
|
122
|
+
})
|
|
123
|
+
] });
|
|
124
|
+
});
|
|
125
|
+
DatePickerInput.displayName = "DatePickerInput";
|
|
126
|
+
//#endregion
|
|
127
|
+
exports.DatePickerInput = DatePickerInput;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
export interface DatePickerSkeletonProps {
|
|
9
|
+
/**
|
|
10
|
+
* Specify whether the skeleton should be a range date picker
|
|
11
|
+
*/
|
|
12
|
+
range?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Additional CSS class names
|
|
15
|
+
*/
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* DatePickerSkeleton component for loading states
|
|
20
|
+
*/
|
|
21
|
+
export declare const DatePickerSkeleton: React.FC<DatePickerSkeletonProps>;
|
|
22
|
+
export default DatePickerSkeleton;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
|
|
9
|
+
const require_usePrefix = require("../../../../internal/usePrefix.js");
|
|
10
|
+
let react = require("react");
|
|
11
|
+
react = require_runtime.__toESM(react);
|
|
12
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
13
|
+
//#region src/components/DatePicker/next/components/DatePickerSkeleton.tsx
|
|
14
|
+
/**
|
|
15
|
+
* Copyright IBM Corp. 2026
|
|
16
|
+
*
|
|
17
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
18
|
+
* LICENSE file in the root directory of this source tree.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* DatePickerSkeleton component for loading states
|
|
22
|
+
*/
|
|
23
|
+
const DatePickerSkeleton = ({ range = false, className }) => {
|
|
24
|
+
const prefix = require_usePrefix.usePrefix();
|
|
25
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
26
|
+
className: `${prefix}--form-item`,
|
|
27
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
28
|
+
className: `${prefix}--date-picker ${prefix}--date-picker--next ${prefix}--date-picker--${range ? "range" : "single"} ${prefix}--skeleton ${className || ""}`,
|
|
29
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
30
|
+
className: `${prefix}--date-picker-container`,
|
|
31
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: `${prefix}--label ${prefix}--skeleton` }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: `${prefix}--date-picker__input ${prefix}--skeleton` })]
|
|
32
|
+
}), range && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
33
|
+
className: `${prefix}--date-picker-container`,
|
|
34
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: `${prefix}--label ${prefix}--skeleton` }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: `${prefix}--date-picker__input ${prefix}--skeleton` })]
|
|
35
|
+
})]
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
40
|
+
exports.DatePickerSkeleton = DatePickerSkeleton;
|
|
41
|
+
exports.default = DatePickerSkeleton;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { type RefObject } from 'react';
|
|
8
|
+
import { DatePickerState, type DatePickerContext } from '@carbon/utilities/date-picker';
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for the useDatePicker hook
|
|
11
|
+
* Maintains 100% backwards compatibility with Carbon React v11 API
|
|
12
|
+
*/
|
|
13
|
+
export interface UseDatePickerConfig {
|
|
14
|
+
/**
|
|
15
|
+
* The type of date picker (Carbon API uses datePickerType, not mode)
|
|
16
|
+
*/
|
|
17
|
+
datePickerType?: 'simple' | 'single' | 'range';
|
|
18
|
+
/**
|
|
19
|
+
* Initial value as ISO date string
|
|
20
|
+
*/
|
|
21
|
+
value?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Minimum selectable date (mm/dd/yyyy format - Carbon API)
|
|
24
|
+
*/
|
|
25
|
+
minDate?: string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Maximum selectable date (mm/dd/yyyy format - Carbon API)
|
|
28
|
+
*/
|
|
29
|
+
maxDate?: string | null;
|
|
30
|
+
/**
|
|
31
|
+
* Date format string (Flatpickr-compatible format)
|
|
32
|
+
*/
|
|
33
|
+
dateFormat?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Whether to allow manual input
|
|
36
|
+
*/
|
|
37
|
+
allowInput?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Whether to close calendar on date selection
|
|
40
|
+
*/
|
|
41
|
+
closeOnSelect?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the picker is disabled
|
|
44
|
+
*/
|
|
45
|
+
disabled?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the picker is read-only (Carbon uses readOnly, not readonly)
|
|
48
|
+
*/
|
|
49
|
+
readOnly?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Locale for date formatting
|
|
52
|
+
*/
|
|
53
|
+
locale?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Change handler - receives array of Date objects (Carbon API)
|
|
56
|
+
*/
|
|
57
|
+
onChange?: (dates: Date[]) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Open handler
|
|
60
|
+
*/
|
|
61
|
+
onOpen?: () => void;
|
|
62
|
+
/**
|
|
63
|
+
* Close handler
|
|
64
|
+
*/
|
|
65
|
+
onClose?: () => void;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Return type for the useDatePicker hook
|
|
69
|
+
*/
|
|
70
|
+
export interface UseDatePickerReturn {
|
|
71
|
+
/**
|
|
72
|
+
* Current state machine context
|
|
73
|
+
*/
|
|
74
|
+
context: DatePickerContext;
|
|
75
|
+
/**
|
|
76
|
+
* Ref to attach to the exit sentinel element in the render tree.
|
|
77
|
+
* The sentinel is a visually-hidden, aria-hidden span placed just after the
|
|
78
|
+
* calendar container. It has tabindex="-1" by default and is briefly set to
|
|
79
|
+
* tabindex="0" when Tab is pressed from the calendar so the browser delivers
|
|
80
|
+
* focus there naturally — no DOM scan needed.
|
|
81
|
+
*/
|
|
82
|
+
exitSentinelRef: RefObject<HTMLSpanElement | null>;
|
|
83
|
+
/**
|
|
84
|
+
* onFocus handler to attach to the exit sentinel element.
|
|
85
|
+
* Restores tabindex="-1" on the sentinel and closes the calendar if still open.
|
|
86
|
+
*/
|
|
87
|
+
handleExitSentinelFocus: () => void;
|
|
88
|
+
/**
|
|
89
|
+
* Current state
|
|
90
|
+
*/
|
|
91
|
+
state: DatePickerState;
|
|
92
|
+
/**
|
|
93
|
+
* Whether the calendar is open
|
|
94
|
+
*/
|
|
95
|
+
isOpen: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Send an event to the state machine
|
|
98
|
+
*/
|
|
99
|
+
send: (eventType: string, payload?: unknown) => void;
|
|
100
|
+
/**
|
|
101
|
+
* Open the calendar
|
|
102
|
+
*/
|
|
103
|
+
openCalendar: () => void;
|
|
104
|
+
/**
|
|
105
|
+
* Close the calendar
|
|
106
|
+
*/
|
|
107
|
+
closeCalendar: () => void;
|
|
108
|
+
/**
|
|
109
|
+
* Select a date
|
|
110
|
+
*/
|
|
111
|
+
selectDate: (date: Temporal.PlainDate) => void;
|
|
112
|
+
/**
|
|
113
|
+
* Handle input focus
|
|
114
|
+
*/
|
|
115
|
+
handleInputFocus: (inputType?: 'from' | 'to') => void;
|
|
116
|
+
/**
|
|
117
|
+
* Handle input blur
|
|
118
|
+
*/
|
|
119
|
+
handleInputBlur: () => void;
|
|
120
|
+
/**
|
|
121
|
+
* Handle input value change
|
|
122
|
+
*/
|
|
123
|
+
handleInputChange: (value: string, inputType?: 'from' | 'to') => void;
|
|
124
|
+
/**
|
|
125
|
+
* Ref for the start input
|
|
126
|
+
*/
|
|
127
|
+
startInputRef: React.RefObject<HTMLInputElement | null>;
|
|
128
|
+
/**
|
|
129
|
+
* Ref for the end input (range mode)
|
|
130
|
+
*/
|
|
131
|
+
endInputRef: React.RefObject<HTMLInputElement | null>;
|
|
132
|
+
/**
|
|
133
|
+
* Ref for the calendar container
|
|
134
|
+
*/
|
|
135
|
+
calendarRef: React.RefObject<HTMLDivElement | null>;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* React hook for managing date picker state using the shared state machine
|
|
139
|
+
* Maintains 100% backwards compatibility with Carbon React v11 API
|
|
140
|
+
*
|
|
141
|
+
* @param {UseDatePickerConfig} config - Configuration options
|
|
142
|
+
* @returns {UseDatePickerReturn} Hook return object with state and handlers
|
|
143
|
+
*/
|
|
144
|
+
export declare function useDatePicker(config?: UseDatePickerConfig): UseDatePickerReturn;
|