@availity/mui-datepicker 1.2.2 → 2.0.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/CHANGELOG.md +21 -0
- package/dist/index.d.mts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +266 -6
- package/dist/index.mjs +254 -4
- package/package.json +9 -9
- package/src/lib/DateCalendar.tsx +2 -2
- package/src/lib/Datepicker.stories.tsx +2 -2
- package/src/lib/Datepicker.test.tsx +0 -9
- package/src/lib/Datepicker.tsx +35 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [2.0.0](https://github.com/Availity/element/compare/@availity/mui-datepicker@1.2.2...@availity/mui-datepicker@2.0.0) (2025-11-17)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `mui-icon` updated to version `1.2.2`
|
|
10
|
+
* `mui-textfield` updated to version `1.2.2`
|
|
11
|
+
* `mui-layout` updated to version `1.2.2`
|
|
12
|
+
* `mui-paper` updated to version `1.2.2`
|
|
13
|
+
* `theme-provider` updated to version `1.2.2`
|
|
14
|
+
* `mui-form-utils` updated to version `1.2.2`
|
|
15
|
+
|
|
16
|
+
### ⚠ BREAKING CHANGES
|
|
17
|
+
|
|
18
|
+
* @mui/material upgraded to v7
|
|
19
|
+
* @mui/x-* upgraded to v8
|
|
20
|
+
* react upgraded to v19
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* upgrade material and react dependencies ([51602a4](https://github.com/Availity/element/commit/51602a48c5304db6f61e2c7e772c9a3a4aa3f65c))
|
|
25
|
+
|
|
5
26
|
## [1.2.2](https://github.com/Availity/element/compare/@availity/mui-datepicker@1.2.1...@availity/mui-datepicker@1.2.2) (2025-10-31)
|
|
6
27
|
|
|
7
28
|
### Dependency Updates
|
package/dist/index.d.mts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { TextFieldProps } from '@availity/mui-textfield';
|
|
2
2
|
import { DatePickerProps } from '@mui/x-date-pickers/DatePicker';
|
|
3
3
|
import { Dayjs } from 'dayjs';
|
|
4
|
+
import { PickerFieldUISlotProps } from '@mui/x-date-pickers/internals';
|
|
4
5
|
|
|
6
|
+
type AvTextFieldAdditionalProps = Pick<TextFieldProps, 'error' | 'helpTopicId' | 'helperText' | 'inputProps' | 'label' | 'required'>;
|
|
5
7
|
type DatepickerProps = {
|
|
6
8
|
value?: Dayjs | null | undefined;
|
|
7
|
-
/** Props applied to the `
|
|
8
|
-
FieldProps?:
|
|
9
|
+
/** Props applied to the `PickersTextField` component */
|
|
10
|
+
FieldProps?: PickerFieldUISlotProps['textField'] & AvTextFieldAdditionalProps;
|
|
9
11
|
/** Determines where the Calendar will be placed when opened.
|
|
10
12
|
* @default bottom-start
|
|
11
13
|
*/
|
|
12
14
|
placement?: 'bottom-start' | 'bottom' | 'bottom-end';
|
|
13
15
|
/** Determines if the clear button appears in the action bar */
|
|
14
16
|
clearable?: boolean;
|
|
15
|
-
} & Omit<DatePickerProps<
|
|
16
|
-
declare const Datepicker: ({ FieldProps, placement, clearable, ...props }: DatepickerProps) => JSX.Element;
|
|
17
|
+
} & Omit<DatePickerProps<false>, 'components' | 'componentsProps' | 'desktopModeMediaQuery' | 'DialogProps' | 'OpenPickerButtonProps' | 'openTo' | 'orientation' | 'PaperProps' | 'PopperProps' | 'reduceAnimations' | 'renderInput' | 'rifmFormatter' | 'showToolbar' | 'slots' | 'slotProps' | 'ToolbarComponent' | 'toolbarFormat' | 'toolbarPlaceholder' | 'toolbarTitle' | 'TransitionComponent' | 'value'>;
|
|
18
|
+
declare const Datepicker: ({ FieldProps, placement, clearable, ...props }: DatepickerProps) => React.JSX.Element;
|
|
17
19
|
|
|
18
20
|
export { Datepicker, type DatepickerProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { TextFieldProps } from '@availity/mui-textfield';
|
|
2
2
|
import { DatePickerProps } from '@mui/x-date-pickers/DatePicker';
|
|
3
3
|
import { Dayjs } from 'dayjs';
|
|
4
|
+
import { PickerFieldUISlotProps } from '@mui/x-date-pickers/internals';
|
|
4
5
|
|
|
6
|
+
type AvTextFieldAdditionalProps = Pick<TextFieldProps, 'error' | 'helpTopicId' | 'helperText' | 'inputProps' | 'label' | 'required'>;
|
|
5
7
|
type DatepickerProps = {
|
|
6
8
|
value?: Dayjs | null | undefined;
|
|
7
|
-
/** Props applied to the `
|
|
8
|
-
FieldProps?:
|
|
9
|
+
/** Props applied to the `PickersTextField` component */
|
|
10
|
+
FieldProps?: PickerFieldUISlotProps['textField'] & AvTextFieldAdditionalProps;
|
|
9
11
|
/** Determines where the Calendar will be placed when opened.
|
|
10
12
|
* @default bottom-start
|
|
11
13
|
*/
|
|
12
14
|
placement?: 'bottom-start' | 'bottom' | 'bottom-end';
|
|
13
15
|
/** Determines if the clear button appears in the action bar */
|
|
14
16
|
clearable?: boolean;
|
|
15
|
-
} & Omit<DatePickerProps<
|
|
16
|
-
declare const Datepicker: ({ FieldProps, placement, clearable, ...props }: DatepickerProps) => JSX.Element;
|
|
17
|
+
} & Omit<DatePickerProps<false>, 'components' | 'componentsProps' | 'desktopModeMediaQuery' | 'DialogProps' | 'OpenPickerButtonProps' | 'openTo' | 'orientation' | 'PaperProps' | 'PopperProps' | 'reduceAnimations' | 'renderInput' | 'rifmFormatter' | 'showToolbar' | 'slots' | 'slotProps' | 'ToolbarComponent' | 'toolbarFormat' | 'toolbarPlaceholder' | 'toolbarTitle' | 'TransitionComponent' | 'value'>;
|
|
18
|
+
declare const Datepicker: ({ FieldProps, placement, clearable, ...props }: DatepickerProps) => React.JSX.Element;
|
|
17
19
|
|
|
18
20
|
export { Datepicker, type DatepickerProps };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __defProps = Object.defineProperties;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
8
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
11
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
12
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -44,6 +46,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
44
46
|
}
|
|
45
47
|
return to;
|
|
46
48
|
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
50
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
51
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
52
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
53
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
54
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
55
|
+
mod
|
|
56
|
+
));
|
|
47
57
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
48
58
|
|
|
49
59
|
// src/index.ts
|
|
@@ -54,12 +64,262 @@ __export(index_exports, {
|
|
|
54
64
|
module.exports = __toCommonJS(index_exports);
|
|
55
65
|
|
|
56
66
|
// src/lib/Datepicker.tsx
|
|
57
|
-
var
|
|
58
|
-
var import_mui_icon = require("@availity/mui-icon");
|
|
67
|
+
var import_mui_icon3 = require("@availity/mui-icon");
|
|
59
68
|
var import_DatePicker = require("@mui/x-date-pickers/DatePicker");
|
|
69
|
+
var import_PickersTextField = require("@mui/x-date-pickers/PickersTextField");
|
|
70
|
+
|
|
71
|
+
// ../../node_modules/@availity/message-core/dist/index.mjs
|
|
72
|
+
var __defProp2 = Object.defineProperty;
|
|
73
|
+
var __typeError = (msg) => {
|
|
74
|
+
throw TypeError(msg);
|
|
75
|
+
};
|
|
76
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
77
|
+
var __publicField = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
78
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
79
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
80
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
81
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
82
|
+
var _lastId;
|
|
83
|
+
var AvMessage = class {
|
|
84
|
+
constructor() {
|
|
85
|
+
__publicField(this, "subscribers", {});
|
|
86
|
+
__publicField(this, "getEventData", (event) => {
|
|
87
|
+
const isSameWindow = event.source === window;
|
|
88
|
+
if (!this.isEnabled || // do nothing if not enabled
|
|
89
|
+
!event || !event.data || !event.origin || !event.source || // check event exists and has necessary properties
|
|
90
|
+
!this.isDomain(event.origin)) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
let { data } = event;
|
|
94
|
+
if (typeof data === "string") {
|
|
95
|
+
try {
|
|
96
|
+
data = JSON.parse(data);
|
|
97
|
+
} catch (e) {
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (typeof data === "string") {
|
|
101
|
+
event = data;
|
|
102
|
+
data = void 0;
|
|
103
|
+
} else {
|
|
104
|
+
event = data && data.event || this.DEFAULT_EVENT;
|
|
105
|
+
}
|
|
106
|
+
const metadata = { isSameWindow };
|
|
107
|
+
this.onMessage(event, data, metadata);
|
|
108
|
+
});
|
|
109
|
+
__privateAdd(this, _lastId, 0);
|
|
110
|
+
this.isEnabled = true;
|
|
111
|
+
this.DEFAULT_EVENT = "avMessage";
|
|
112
|
+
this.DOMAIN = /https?:\/\/([\w-]+\.)?availity\.(com|net)/;
|
|
113
|
+
window.addEventListener("message", this.getEventData);
|
|
114
|
+
}
|
|
115
|
+
enabled(value) {
|
|
116
|
+
if (arguments.length > 0) {
|
|
117
|
+
this.isEnabled = !!value;
|
|
118
|
+
}
|
|
119
|
+
return this.isEnabled;
|
|
120
|
+
}
|
|
121
|
+
subscribe(event, callback, options) {
|
|
122
|
+
var _a;
|
|
123
|
+
if (!this.subscribers[event]) {
|
|
124
|
+
this.subscribers[event] = [];
|
|
125
|
+
}
|
|
126
|
+
__privateSet(this, _lastId, __privateGet(this, _lastId) + 1);
|
|
127
|
+
const id = __privateGet(this, _lastId);
|
|
128
|
+
const ignoreSameWindow = (_a = options == null ? void 0 : options.ignoreSameWindow) != null ? _a : true;
|
|
129
|
+
const subscriber = { id, callback, options: { ignoreSameWindow } };
|
|
130
|
+
this.subscribers[event].push(subscriber);
|
|
131
|
+
return () => {
|
|
132
|
+
this.subscribers[event] = this.subscribers[event].filter((subscriber2) => subscriber2.id !== id);
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
// remove all subscribers for this event
|
|
136
|
+
unsubscribe(event) {
|
|
137
|
+
delete this.subscribers[event];
|
|
138
|
+
}
|
|
139
|
+
unsubscribeAll() {
|
|
140
|
+
this.subscribers = {};
|
|
141
|
+
}
|
|
142
|
+
onMessage(event, data, metadata) {
|
|
143
|
+
const { isSameWindow } = metadata;
|
|
144
|
+
if (this.subscribers[event]) {
|
|
145
|
+
for (const subscriber of this.subscribers[event]) {
|
|
146
|
+
const { ignoreSameWindow } = subscriber.options;
|
|
147
|
+
const skip = isSameWindow && ignoreSameWindow;
|
|
148
|
+
if (!skip) {
|
|
149
|
+
subscriber.callback(data);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// if current domain doesn't match regex DOMAIN, return true.
|
|
155
|
+
isDomain(url) {
|
|
156
|
+
return !this.DOMAIN.test(this.domain()) || this.DOMAIN.test(url);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Attempts to get origin from top window
|
|
160
|
+
* @private
|
|
161
|
+
* @returns {string|null}
|
|
162
|
+
*/
|
|
163
|
+
getOriginFromTop() {
|
|
164
|
+
try {
|
|
165
|
+
return window.top.location.origin;
|
|
166
|
+
} catch (e) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Swaps between 'apps' and 'essentials' in the domain
|
|
172
|
+
* @private
|
|
173
|
+
* @param {string} url
|
|
174
|
+
* @returns {string}
|
|
175
|
+
*/
|
|
176
|
+
swapDomain(url) {
|
|
177
|
+
if (url.includes("essentials")) {
|
|
178
|
+
return url.replace("essentials", "apps");
|
|
179
|
+
}
|
|
180
|
+
return url.replace("apps", "essentials");
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Gets the domain
|
|
184
|
+
* @private
|
|
185
|
+
* @returns {string}
|
|
186
|
+
*/
|
|
187
|
+
domain() {
|
|
188
|
+
const topOrigin = this.getOriginFromTop();
|
|
189
|
+
if (topOrigin) {
|
|
190
|
+
return window.location.origin;
|
|
191
|
+
}
|
|
192
|
+
if (window.location.origin) {
|
|
193
|
+
const url = window.location.origin;
|
|
194
|
+
return this.swapDomain(url);
|
|
195
|
+
}
|
|
196
|
+
if (window.location.hostname) {
|
|
197
|
+
const url = `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ""}`;
|
|
198
|
+
return this.swapDomain(url);
|
|
199
|
+
}
|
|
200
|
+
return "*";
|
|
201
|
+
}
|
|
202
|
+
send(payload, target = window.top) {
|
|
203
|
+
if (!this.isEnabled || !payload) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
try {
|
|
207
|
+
const message = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
208
|
+
target.postMessage(message, this.domain());
|
|
209
|
+
} catch (error) {
|
|
210
|
+
console.warn("AvMessage.send()", error);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
_lastId = /* @__PURE__ */ new WeakMap();
|
|
215
|
+
var AvMessage_default = AvMessage;
|
|
216
|
+
var index_default = new AvMessage_default();
|
|
217
|
+
|
|
218
|
+
// ../form-utils/src/lib/FieldHelpIcon.tsx
|
|
219
|
+
var import_mui_icon = require("@availity/mui-icon");
|
|
220
|
+
|
|
221
|
+
// ../button/src/lib/IconButton.tsx
|
|
222
|
+
var import_react = require("react");
|
|
223
|
+
var import_IconButton = __toESM(require("@mui/material/IconButton"));
|
|
224
|
+
var import_Tooltip = __toESM(require("@mui/material/Tooltip"));
|
|
60
225
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
226
|
+
var outlinedStyles = {
|
|
227
|
+
borderRadius: ".25rem",
|
|
228
|
+
border: 1
|
|
229
|
+
};
|
|
230
|
+
var IconButton = (0, import_react.forwardRef)((props, ref) => {
|
|
231
|
+
const _a = props, { title, variant = "text", sx, size = "medium" } = _a, rest = __objRest(_a, ["title", "variant", "sx", "size"]);
|
|
232
|
+
const styles = __spreadValues(__spreadValues({}, sx), variant === "outlined" && outlinedStyles);
|
|
233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Tooltip.default, { title, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_IconButton.default, __spreadProps(__spreadValues({ "aria-label": title, sx: __spreadValues({}, styles) }, rest), { ref, size })) });
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// ../form-utils/src/lib/FieldHelpIcon.tsx
|
|
237
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
238
|
+
var triggerFieldHelp = (id) => {
|
|
239
|
+
index_default.send({
|
|
240
|
+
event: "nav:help:field",
|
|
241
|
+
id
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
var FieldHelpIcon = (_a) => {
|
|
245
|
+
var _b = _a, { helpTopicId, labelId, sx } = _b, rest = __objRest(_b, ["helpTopicId", "labelId", "sx"]);
|
|
246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
247
|
+
IconButton,
|
|
248
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
249
|
+
color: "primary",
|
|
250
|
+
title: "Help",
|
|
251
|
+
role: "link",
|
|
252
|
+
onClick: () => triggerFieldHelp(helpTopicId),
|
|
253
|
+
"aria-describedby": labelId,
|
|
254
|
+
size: "small",
|
|
255
|
+
sx: __spreadProps(__spreadValues({}, sx), { fontSize: "inherit", marginTop: "-2px", opacity: 1 }),
|
|
256
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_mui_icon.HelpCircleIcon, { "aria-hidden": true, titleAccess: void 0 })
|
|
257
|
+
})
|
|
258
|
+
);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
// ../form-utils/src/lib/FormHelperText.tsx
|
|
262
|
+
var import_FormHelperText = __toESM(require("@mui/material/FormHelperText"));
|
|
263
|
+
var import_mui_icon2 = require("@availity/mui-icon");
|
|
264
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
265
|
+
var FormHelperText = (_a) => {
|
|
266
|
+
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
267
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_FormHelperText.default, __spreadProps(__spreadValues({}, props), { children: [
|
|
268
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_icon2.WarningTriangleIcon, { sx: { marginRight: "4px" }, titleAccess: "Error", "aria-hidden": false }),
|
|
269
|
+
children
|
|
270
|
+
] }));
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// ../form-utils/src/lib/FormLabel.tsx
|
|
274
|
+
var import_react2 = require("react");
|
|
275
|
+
var import_FormLabel = __toESM(require("@mui/material/FormLabel"));
|
|
276
|
+
var import_styles = require("@mui/material/styles");
|
|
277
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
278
|
+
var Wrapper = (0, import_styles.styled)("div", {
|
|
279
|
+
name: "MuiFormLabel",
|
|
280
|
+
slot: "AvWrapper",
|
|
281
|
+
overridesResolver: (props, styles) => styles.avWrapper
|
|
282
|
+
})({});
|
|
283
|
+
var StyleOverrides = {
|
|
284
|
+
position: "relative !important",
|
|
285
|
+
transform: "none !important",
|
|
286
|
+
transition: "none !important",
|
|
287
|
+
animation: "none !important"
|
|
288
|
+
};
|
|
289
|
+
var FormLabel = (0, import_react2.forwardRef)((props, ref) => {
|
|
290
|
+
const _a = props, { helpTopicId, id, sx } = _a, rest = __objRest(_a, ["helpTopicId", "id", "sx"]);
|
|
291
|
+
const labelId = id || (rest.htmlFor ? `${rest.htmlFor}-label` : void 0);
|
|
292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Wrapper, { className: "MuiFormLabel-avWrapper", sx, children: [
|
|
293
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_FormLabel.default, __spreadProps(__spreadValues({ id: labelId, sx: __spreadValues({}, StyleOverrides) }, rest), { ref })),
|
|
294
|
+
helpTopicId ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldHelpIcon, { helpTopicId, labelId, sx: { px: 0.5 } }) : null
|
|
295
|
+
] });
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
// src/lib/Datepicker.tsx
|
|
299
|
+
var import_react3 = require("react");
|
|
300
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
61
301
|
var paperProps = { elevation: 8, variant: "elevation", sx: { marginTop: "4px" } };
|
|
62
|
-
var
|
|
302
|
+
var PickersTextField = (0, import_react3.forwardRef)((props, ref) => {
|
|
303
|
+
const _a = props, { helperText = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, {}), helpTopicId, InputLabelProps: InputLabelPropsIN, inputProps: inputPropsIN, FormHelperTextProps: FormHelperTextPropsIN, required } = _a, params = __objRest(_a, ["helperText", "helpTopicId", "InputLabelProps", "inputProps", "FormHelperTextProps", "required"]);
|
|
304
|
+
const PickersLabel = (props2) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FormLabel, __spreadValues({ helpTopicId, required }, props2));
|
|
305
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
306
|
+
import_PickersTextField.PickersTextField,
|
|
307
|
+
__spreadProps(__spreadValues({}, params), {
|
|
308
|
+
helperText,
|
|
309
|
+
InputLabelProps: __spreadValues({
|
|
310
|
+
component: PickersLabel
|
|
311
|
+
}, InputLabelPropsIN),
|
|
312
|
+
inputProps: __spreadValues({
|
|
313
|
+
"aria-required": required
|
|
314
|
+
}, inputPropsIN),
|
|
315
|
+
FormHelperTextProps: __spreadValues({
|
|
316
|
+
component: FormHelperText,
|
|
317
|
+
error: params.error
|
|
318
|
+
}, FormHelperTextPropsIN),
|
|
319
|
+
ref
|
|
320
|
+
})
|
|
321
|
+
);
|
|
322
|
+
});
|
|
63
323
|
var Datepicker = (_a) => {
|
|
64
324
|
var _b = _a, {
|
|
65
325
|
FieldProps,
|
|
@@ -71,7 +331,7 @@ var Datepicker = (_a) => {
|
|
|
71
331
|
"clearable"
|
|
72
332
|
]);
|
|
73
333
|
var _a2, _b2, _c, _d, _e, _f;
|
|
74
|
-
return /* @__PURE__ */ (0,
|
|
334
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
75
335
|
import_DatePicker.DatePicker,
|
|
76
336
|
__spreadProps(__spreadValues({}, props), {
|
|
77
337
|
dayOfWeekFormatter: (weekday) => weekday.format("dd"),
|
|
@@ -95,8 +355,8 @@ var Datepicker = (_a) => {
|
|
|
95
355
|
}
|
|
96
356
|
},
|
|
97
357
|
slots: {
|
|
98
|
-
openPickerIcon:
|
|
99
|
-
textField:
|
|
358
|
+
openPickerIcon: import_mui_icon3.CalendarDaysIcon,
|
|
359
|
+
textField: PickersTextField
|
|
100
360
|
}
|
|
101
361
|
})
|
|
102
362
|
);
|
package/dist/index.mjs
CHANGED
|
@@ -31,12 +31,262 @@ var __objRest = (source, exclude) => {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
// src/lib/Datepicker.tsx
|
|
34
|
-
import { TextField } from "@availity/mui-textfield";
|
|
35
34
|
import { CalendarDaysIcon } from "@availity/mui-icon";
|
|
36
35
|
import { DatePicker as MuiDatePicker } from "@mui/x-date-pickers/DatePicker";
|
|
36
|
+
import { PickersTextField as MuiPickersTextField } from "@mui/x-date-pickers/PickersTextField";
|
|
37
|
+
|
|
38
|
+
// ../../node_modules/@availity/message-core/dist/index.mjs
|
|
39
|
+
var __defProp2 = Object.defineProperty;
|
|
40
|
+
var __typeError = (msg) => {
|
|
41
|
+
throw TypeError(msg);
|
|
42
|
+
};
|
|
43
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
44
|
+
var __publicField = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
45
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
46
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
47
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
48
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
49
|
+
var _lastId;
|
|
50
|
+
var AvMessage = class {
|
|
51
|
+
constructor() {
|
|
52
|
+
__publicField(this, "subscribers", {});
|
|
53
|
+
__publicField(this, "getEventData", (event) => {
|
|
54
|
+
const isSameWindow = event.source === window;
|
|
55
|
+
if (!this.isEnabled || // do nothing if not enabled
|
|
56
|
+
!event || !event.data || !event.origin || !event.source || // check event exists and has necessary properties
|
|
57
|
+
!this.isDomain(event.origin)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
let { data } = event;
|
|
61
|
+
if (typeof data === "string") {
|
|
62
|
+
try {
|
|
63
|
+
data = JSON.parse(data);
|
|
64
|
+
} catch (e) {
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (typeof data === "string") {
|
|
68
|
+
event = data;
|
|
69
|
+
data = void 0;
|
|
70
|
+
} else {
|
|
71
|
+
event = data && data.event || this.DEFAULT_EVENT;
|
|
72
|
+
}
|
|
73
|
+
const metadata = { isSameWindow };
|
|
74
|
+
this.onMessage(event, data, metadata);
|
|
75
|
+
});
|
|
76
|
+
__privateAdd(this, _lastId, 0);
|
|
77
|
+
this.isEnabled = true;
|
|
78
|
+
this.DEFAULT_EVENT = "avMessage";
|
|
79
|
+
this.DOMAIN = /https?:\/\/([\w-]+\.)?availity\.(com|net)/;
|
|
80
|
+
window.addEventListener("message", this.getEventData);
|
|
81
|
+
}
|
|
82
|
+
enabled(value) {
|
|
83
|
+
if (arguments.length > 0) {
|
|
84
|
+
this.isEnabled = !!value;
|
|
85
|
+
}
|
|
86
|
+
return this.isEnabled;
|
|
87
|
+
}
|
|
88
|
+
subscribe(event, callback, options) {
|
|
89
|
+
var _a;
|
|
90
|
+
if (!this.subscribers[event]) {
|
|
91
|
+
this.subscribers[event] = [];
|
|
92
|
+
}
|
|
93
|
+
__privateSet(this, _lastId, __privateGet(this, _lastId) + 1);
|
|
94
|
+
const id = __privateGet(this, _lastId);
|
|
95
|
+
const ignoreSameWindow = (_a = options == null ? void 0 : options.ignoreSameWindow) != null ? _a : true;
|
|
96
|
+
const subscriber = { id, callback, options: { ignoreSameWindow } };
|
|
97
|
+
this.subscribers[event].push(subscriber);
|
|
98
|
+
return () => {
|
|
99
|
+
this.subscribers[event] = this.subscribers[event].filter((subscriber2) => subscriber2.id !== id);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
// remove all subscribers for this event
|
|
103
|
+
unsubscribe(event) {
|
|
104
|
+
delete this.subscribers[event];
|
|
105
|
+
}
|
|
106
|
+
unsubscribeAll() {
|
|
107
|
+
this.subscribers = {};
|
|
108
|
+
}
|
|
109
|
+
onMessage(event, data, metadata) {
|
|
110
|
+
const { isSameWindow } = metadata;
|
|
111
|
+
if (this.subscribers[event]) {
|
|
112
|
+
for (const subscriber of this.subscribers[event]) {
|
|
113
|
+
const { ignoreSameWindow } = subscriber.options;
|
|
114
|
+
const skip = isSameWindow && ignoreSameWindow;
|
|
115
|
+
if (!skip) {
|
|
116
|
+
subscriber.callback(data);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// if current domain doesn't match regex DOMAIN, return true.
|
|
122
|
+
isDomain(url) {
|
|
123
|
+
return !this.DOMAIN.test(this.domain()) || this.DOMAIN.test(url);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Attempts to get origin from top window
|
|
127
|
+
* @private
|
|
128
|
+
* @returns {string|null}
|
|
129
|
+
*/
|
|
130
|
+
getOriginFromTop() {
|
|
131
|
+
try {
|
|
132
|
+
return window.top.location.origin;
|
|
133
|
+
} catch (e) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Swaps between 'apps' and 'essentials' in the domain
|
|
139
|
+
* @private
|
|
140
|
+
* @param {string} url
|
|
141
|
+
* @returns {string}
|
|
142
|
+
*/
|
|
143
|
+
swapDomain(url) {
|
|
144
|
+
if (url.includes("essentials")) {
|
|
145
|
+
return url.replace("essentials", "apps");
|
|
146
|
+
}
|
|
147
|
+
return url.replace("apps", "essentials");
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Gets the domain
|
|
151
|
+
* @private
|
|
152
|
+
* @returns {string}
|
|
153
|
+
*/
|
|
154
|
+
domain() {
|
|
155
|
+
const topOrigin = this.getOriginFromTop();
|
|
156
|
+
if (topOrigin) {
|
|
157
|
+
return window.location.origin;
|
|
158
|
+
}
|
|
159
|
+
if (window.location.origin) {
|
|
160
|
+
const url = window.location.origin;
|
|
161
|
+
return this.swapDomain(url);
|
|
162
|
+
}
|
|
163
|
+
if (window.location.hostname) {
|
|
164
|
+
const url = `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ""}`;
|
|
165
|
+
return this.swapDomain(url);
|
|
166
|
+
}
|
|
167
|
+
return "*";
|
|
168
|
+
}
|
|
169
|
+
send(payload, target = window.top) {
|
|
170
|
+
if (!this.isEnabled || !payload) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
const message = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
175
|
+
target.postMessage(message, this.domain());
|
|
176
|
+
} catch (error) {
|
|
177
|
+
console.warn("AvMessage.send()", error);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
_lastId = /* @__PURE__ */ new WeakMap();
|
|
182
|
+
var AvMessage_default = AvMessage;
|
|
183
|
+
var index_default = new AvMessage_default();
|
|
184
|
+
|
|
185
|
+
// ../form-utils/src/lib/FieldHelpIcon.tsx
|
|
186
|
+
import { HelpCircleIcon } from "@availity/mui-icon";
|
|
187
|
+
|
|
188
|
+
// ../button/src/lib/IconButton.tsx
|
|
189
|
+
import { forwardRef } from "react";
|
|
190
|
+
import { default as MuiIconButton } from "@mui/material/IconButton";
|
|
191
|
+
import Tooltip from "@mui/material/Tooltip";
|
|
37
192
|
import { jsx } from "react/jsx-runtime";
|
|
193
|
+
var outlinedStyles = {
|
|
194
|
+
borderRadius: ".25rem",
|
|
195
|
+
border: 1
|
|
196
|
+
};
|
|
197
|
+
var IconButton = forwardRef((props, ref) => {
|
|
198
|
+
const _a = props, { title, variant = "text", sx, size = "medium" } = _a, rest = __objRest(_a, ["title", "variant", "sx", "size"]);
|
|
199
|
+
const styles = __spreadValues(__spreadValues({}, sx), variant === "outlined" && outlinedStyles);
|
|
200
|
+
return /* @__PURE__ */ jsx(Tooltip, { title, children: /* @__PURE__ */ jsx(MuiIconButton, __spreadProps(__spreadValues({ "aria-label": title, sx: __spreadValues({}, styles) }, rest), { ref, size })) });
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// ../form-utils/src/lib/FieldHelpIcon.tsx
|
|
204
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
205
|
+
var triggerFieldHelp = (id) => {
|
|
206
|
+
index_default.send({
|
|
207
|
+
event: "nav:help:field",
|
|
208
|
+
id
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
var FieldHelpIcon = (_a) => {
|
|
212
|
+
var _b = _a, { helpTopicId, labelId, sx } = _b, rest = __objRest(_b, ["helpTopicId", "labelId", "sx"]);
|
|
213
|
+
return /* @__PURE__ */ jsx2(
|
|
214
|
+
IconButton,
|
|
215
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
216
|
+
color: "primary",
|
|
217
|
+
title: "Help",
|
|
218
|
+
role: "link",
|
|
219
|
+
onClick: () => triggerFieldHelp(helpTopicId),
|
|
220
|
+
"aria-describedby": labelId,
|
|
221
|
+
size: "small",
|
|
222
|
+
sx: __spreadProps(__spreadValues({}, sx), { fontSize: "inherit", marginTop: "-2px", opacity: 1 }),
|
|
223
|
+
children: /* @__PURE__ */ jsx2(HelpCircleIcon, { "aria-hidden": true, titleAccess: void 0 })
|
|
224
|
+
})
|
|
225
|
+
);
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// ../form-utils/src/lib/FormHelperText.tsx
|
|
229
|
+
import MuiFormHelperText from "@mui/material/FormHelperText";
|
|
230
|
+
import { WarningTriangleIcon } from "@availity/mui-icon";
|
|
231
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
232
|
+
var FormHelperText = (_a) => {
|
|
233
|
+
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
234
|
+
return /* @__PURE__ */ jsxs(MuiFormHelperText, __spreadProps(__spreadValues({}, props), { children: [
|
|
235
|
+
/* @__PURE__ */ jsx3(WarningTriangleIcon, { sx: { marginRight: "4px" }, titleAccess: "Error", "aria-hidden": false }),
|
|
236
|
+
children
|
|
237
|
+
] }));
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
// ../form-utils/src/lib/FormLabel.tsx
|
|
241
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
242
|
+
import { default as MuiFormLabel } from "@mui/material/FormLabel";
|
|
243
|
+
import { styled } from "@mui/material/styles";
|
|
244
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
245
|
+
var Wrapper = styled("div", {
|
|
246
|
+
name: "MuiFormLabel",
|
|
247
|
+
slot: "AvWrapper",
|
|
248
|
+
overridesResolver: (props, styles) => styles.avWrapper
|
|
249
|
+
})({});
|
|
250
|
+
var StyleOverrides = {
|
|
251
|
+
position: "relative !important",
|
|
252
|
+
transform: "none !important",
|
|
253
|
+
transition: "none !important",
|
|
254
|
+
animation: "none !important"
|
|
255
|
+
};
|
|
256
|
+
var FormLabel = forwardRef2((props, ref) => {
|
|
257
|
+
const _a = props, { helpTopicId, id, sx } = _a, rest = __objRest(_a, ["helpTopicId", "id", "sx"]);
|
|
258
|
+
const labelId = id || (rest.htmlFor ? `${rest.htmlFor}-label` : void 0);
|
|
259
|
+
return /* @__PURE__ */ jsxs2(Wrapper, { className: "MuiFormLabel-avWrapper", sx, children: [
|
|
260
|
+
/* @__PURE__ */ jsx4(MuiFormLabel, __spreadProps(__spreadValues({ id: labelId, sx: __spreadValues({}, StyleOverrides) }, rest), { ref })),
|
|
261
|
+
helpTopicId ? /* @__PURE__ */ jsx4(FieldHelpIcon, { helpTopicId, labelId, sx: { px: 0.5 } }) : null
|
|
262
|
+
] });
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// src/lib/Datepicker.tsx
|
|
266
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
267
|
+
import { Fragment, jsx as jsx5 } from "react/jsx-runtime";
|
|
38
268
|
var paperProps = { elevation: 8, variant: "elevation", sx: { marginTop: "4px" } };
|
|
39
|
-
var
|
|
269
|
+
var PickersTextField = forwardRef3((props, ref) => {
|
|
270
|
+
const _a = props, { helperText = /* @__PURE__ */ jsx5(Fragment, {}), helpTopicId, InputLabelProps: InputLabelPropsIN, inputProps: inputPropsIN, FormHelperTextProps: FormHelperTextPropsIN, required } = _a, params = __objRest(_a, ["helperText", "helpTopicId", "InputLabelProps", "inputProps", "FormHelperTextProps", "required"]);
|
|
271
|
+
const PickersLabel = (props2) => /* @__PURE__ */ jsx5(FormLabel, __spreadValues({ helpTopicId, required }, props2));
|
|
272
|
+
return /* @__PURE__ */ jsx5(
|
|
273
|
+
MuiPickersTextField,
|
|
274
|
+
__spreadProps(__spreadValues({}, params), {
|
|
275
|
+
helperText,
|
|
276
|
+
InputLabelProps: __spreadValues({
|
|
277
|
+
component: PickersLabel
|
|
278
|
+
}, InputLabelPropsIN),
|
|
279
|
+
inputProps: __spreadValues({
|
|
280
|
+
"aria-required": required
|
|
281
|
+
}, inputPropsIN),
|
|
282
|
+
FormHelperTextProps: __spreadValues({
|
|
283
|
+
component: FormHelperText,
|
|
284
|
+
error: params.error
|
|
285
|
+
}, FormHelperTextPropsIN),
|
|
286
|
+
ref
|
|
287
|
+
})
|
|
288
|
+
);
|
|
289
|
+
});
|
|
40
290
|
var Datepicker = (_a) => {
|
|
41
291
|
var _b = _a, {
|
|
42
292
|
FieldProps,
|
|
@@ -48,7 +298,7 @@ var Datepicker = (_a) => {
|
|
|
48
298
|
"clearable"
|
|
49
299
|
]);
|
|
50
300
|
var _a2, _b2, _c, _d, _e, _f;
|
|
51
|
-
return /* @__PURE__ */
|
|
301
|
+
return /* @__PURE__ */ jsx5(
|
|
52
302
|
MuiDatePicker,
|
|
53
303
|
__spreadProps(__spreadValues({}, props), {
|
|
54
304
|
dayOfWeekFormatter: (weekday) => weekday.format("dd"),
|
|
@@ -73,7 +323,7 @@ var Datepicker = (_a) => {
|
|
|
73
323
|
},
|
|
74
324
|
slots: {
|
|
75
325
|
openPickerIcon: CalendarDaysIcon,
|
|
76
|
-
textField:
|
|
326
|
+
textField: PickersTextField
|
|
77
327
|
}
|
|
78
328
|
})
|
|
79
329
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@availity/mui-datepicker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Availity MUI Datepicker Component - part of the @availity/element design system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -40,21 +40,21 @@
|
|
|
40
40
|
"publish:canary": "yarn npm publish --access public --tag canary"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@availity/mui-icon": "
|
|
44
|
-
"@availity/mui-textfield": "
|
|
45
|
-
"@mui/x-date-pickers": "^
|
|
43
|
+
"@availity/mui-icon": "2.0.0",
|
|
44
|
+
"@availity/mui-textfield": "2.0.0",
|
|
45
|
+
"@mui/x-date-pickers": "^8.16.0",
|
|
46
46
|
"dayjs": "^1.11.13"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@mui/material": "^
|
|
50
|
-
"react": "
|
|
51
|
-
"react-dom": "
|
|
49
|
+
"@mui/material": "^7.3.4",
|
|
50
|
+
"react": "19.2.0",
|
|
51
|
+
"react-dom": "19.2.0",
|
|
52
52
|
"tsup": "^8.4.0",
|
|
53
53
|
"typescript": "^5.4.5"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mui/material": "^
|
|
57
|
-
"react": ">=
|
|
56
|
+
"@mui/material": "^7.0.0",
|
|
57
|
+
"react": ">=17.0.0"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
package/src/lib/DateCalendar.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { DateCalendar as MuiDateCalendar, DateCalendarProps as MuiDateCalendarPr
|
|
|
2
2
|
import type { Dayjs } from 'dayjs';
|
|
3
3
|
import type {} from '@mui/x-date-pickers/AdapterDayjs';
|
|
4
4
|
|
|
5
|
-
export type DateCalendarProps = Omit<MuiDateCalendarProps
|
|
5
|
+
export type DateCalendarProps = Omit<MuiDateCalendarProps,
|
|
6
6
|
| 'components'
|
|
7
7
|
| 'componentsProps'
|
|
8
8
|
| 'slots'
|
|
@@ -15,7 +15,7 @@ export type DateCalendarProps = Omit<MuiDateCalendarProps<Dayjs>,
|
|
|
15
15
|
>;
|
|
16
16
|
|
|
17
17
|
// just being used for stories atm, if ux finds a use for it we can add it to index.
|
|
18
|
-
export const DateCalendar = (props: DateCalendarProps): JSX.Element => {
|
|
18
|
+
export const DateCalendar = (props: DateCalendarProps): React.JSX.Element => {
|
|
19
19
|
return (
|
|
20
20
|
<MuiDateCalendar
|
|
21
21
|
{...props}
|
|
@@ -37,7 +37,7 @@ export const _Datepicker: StoryObj<typeof Datepicker> = {
|
|
|
37
37
|
fullWidth: false,
|
|
38
38
|
helperText: 'Help text for the field',
|
|
39
39
|
helpTopicId: '1234',
|
|
40
|
-
label: 'Date'
|
|
40
|
+
label: 'Date'
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
43
|
};
|
|
@@ -84,7 +84,7 @@ type DateRangePickerProps = {
|
|
|
84
84
|
};
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
-
type DateRangePicker = (props: DateRangePickerProps) => JSX.Element;
|
|
87
|
+
type DateRangePicker = (props: DateRangePickerProps) => React.JSX.Element;
|
|
88
88
|
|
|
89
89
|
export const _DateRangePicker: StoryObj<DateRangePicker> = {
|
|
90
90
|
render: () => {
|
|
@@ -11,13 +11,4 @@ describe('Datepicker', () => {
|
|
|
11
11
|
);
|
|
12
12
|
expect(getAllByText('Test')).toBeTruthy();
|
|
13
13
|
});
|
|
14
|
-
|
|
15
|
-
test('should render placeholder successfully', () => {
|
|
16
|
-
const { container } = render(
|
|
17
|
-
<ThemeProvider>
|
|
18
|
-
<Datepicker FieldProps={{ InputProps: { placeholder: 'InputProps' } }} onChange={jest.fn()} value={null} />
|
|
19
|
-
</ThemeProvider>
|
|
20
|
-
);
|
|
21
|
-
expect(container.getElementsByClassName('MuiInputBase-input')[0].getAttribute('placeholder')).toBe('InputProps');
|
|
22
|
-
});
|
|
23
14
|
});
|
package/src/lib/Datepicker.tsx
CHANGED
|
@@ -3,11 +3,17 @@ import { CalendarDaysIcon } from '@availity/mui-icon';
|
|
|
3
3
|
import { DatePicker as MuiDatePicker, DatePickerProps as MuiDatePickerProps } from '@mui/x-date-pickers/DatePicker';
|
|
4
4
|
import type { Dayjs } from 'dayjs';
|
|
5
5
|
import type {} from '@mui/x-date-pickers/AdapterDayjs';
|
|
6
|
+
import { PickersTextField as MuiPickersTextField, PickersTextFieldProps as MuiPickersTextFieldProps } from '@mui/x-date-pickers/PickersTextField';
|
|
7
|
+
import { PickerFieldUISlotProps } from '@mui/x-date-pickers/internals';
|
|
8
|
+
import { FormHelperText, FormLabel, InputPropOverrides } from '@availity/mui-form-utils';
|
|
9
|
+
import { forwardRef } from 'react';
|
|
10
|
+
|
|
11
|
+
type AvTextFieldAdditionalProps = Pick<TextFieldProps, 'error' | 'helpTopicId' | 'helperText' | 'inputProps' | 'label' | 'required'>;
|
|
6
12
|
|
|
7
13
|
export type DatepickerProps = {
|
|
8
14
|
value?: Dayjs | null | undefined;
|
|
9
|
-
/** Props applied to the `
|
|
10
|
-
FieldProps?:
|
|
15
|
+
/** Props applied to the `PickersTextField` component */
|
|
16
|
+
FieldProps?: PickerFieldUISlotProps['textField'] & AvTextFieldAdditionalProps;
|
|
11
17
|
/** Determines where the Calendar will be placed when opened.
|
|
12
18
|
* @default bottom-start
|
|
13
19
|
*/
|
|
@@ -15,7 +21,7 @@ export type DatepickerProps = {
|
|
|
15
21
|
/** Determines if the clear button appears in the action bar */
|
|
16
22
|
clearable?: boolean;
|
|
17
23
|
} & Omit<
|
|
18
|
-
MuiDatePickerProps<
|
|
24
|
+
MuiDatePickerProps<false>,
|
|
19
25
|
| 'components'
|
|
20
26
|
| 'componentsProps'
|
|
21
27
|
| 'desktopModeMediaQuery'
|
|
@@ -41,14 +47,37 @@ export type DatepickerProps = {
|
|
|
41
47
|
|
|
42
48
|
const paperProps = { elevation: 8, variant: 'elevation', sx: { marginTop: '4px' } } as const;
|
|
43
49
|
|
|
44
|
-
const
|
|
50
|
+
const PickersTextField = forwardRef((props: MuiPickersTextFieldProps & AvTextFieldAdditionalProps, ref: React.Ref<HTMLDivElement>) => {
|
|
51
|
+
const {helperText=<></>, helpTopicId, InputLabelProps: InputLabelPropsIN, inputProps: inputPropsIN, FormHelperTextProps: FormHelperTextPropsIN, required, ...params} = props;
|
|
52
|
+
const PickersLabel = (props: MuiPickersTextFieldProps["InputLabelProps"] & Pick<TextFieldProps, 'helpTopicId'>) => <FormLabel helpTopicId={helpTopicId} required={required} {...props}/>;
|
|
53
|
+
return (
|
|
54
|
+
<MuiPickersTextField
|
|
55
|
+
{...params}
|
|
56
|
+
helperText={helperText}
|
|
57
|
+
InputLabelProps= {{
|
|
58
|
+
component: PickersLabel,
|
|
59
|
+
...InputLabelPropsIN,
|
|
60
|
+
}}
|
|
61
|
+
inputProps= {{
|
|
62
|
+
'aria-required': required,
|
|
63
|
+
...inputPropsIN
|
|
64
|
+
}}
|
|
65
|
+
FormHelperTextProps= {{
|
|
66
|
+
component: FormHelperText,
|
|
67
|
+
error: params.error,
|
|
68
|
+
...FormHelperTextPropsIN,
|
|
69
|
+
}}
|
|
70
|
+
ref={ref}
|
|
71
|
+
/>
|
|
72
|
+
)
|
|
73
|
+
});
|
|
45
74
|
|
|
46
75
|
export const Datepicker = ({
|
|
47
76
|
FieldProps,
|
|
48
77
|
placement = 'bottom-start',
|
|
49
78
|
clearable,
|
|
50
79
|
...props
|
|
51
|
-
}: DatepickerProps): JSX.Element => {
|
|
80
|
+
}: DatepickerProps): React.JSX.Element => {
|
|
52
81
|
return (
|
|
53
82
|
<MuiDatePicker
|
|
54
83
|
{...props}
|
|
@@ -75,7 +104,7 @@ export const Datepicker = ({
|
|
|
75
104
|
}}
|
|
76
105
|
slots={{
|
|
77
106
|
openPickerIcon: CalendarDaysIcon,
|
|
78
|
-
textField:
|
|
107
|
+
textField: PickersTextField
|
|
79
108
|
}}
|
|
80
109
|
/>
|
|
81
110
|
);
|