tp-react-elements-dev 1.10.6 → 1.10.7

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/index.js CHANGED
@@ -12032,175 +12032,6 @@ function generateUtilityClasses(componentName, slots) {
12032
12032
  return result;
12033
12033
  }
12034
12034
 
12035
- function mapEventPropToEvent(eventProp) {
12036
- return eventProp.substring(2).toLowerCase();
12037
- }
12038
- function clickedRootScrollbar$1(event, doc) {
12039
- return doc.documentElement.clientWidth < event.clientX || doc.documentElement.clientHeight < event.clientY;
12040
- }
12041
- /**
12042
- * Listen for click events that occur somewhere in the document, outside of the element itself.
12043
- * For instance, if you need to hide a menu when people click anywhere else on your page.
12044
- *
12045
- * Demos:
12046
- *
12047
- * - [Click-Away Listener](https://mui.com/base-ui/react-click-away-listener/)
12048
- *
12049
- * API:
12050
- *
12051
- * - [ClickAwayListener API](https://mui.com/base-ui/react-click-away-listener/components-api/#click-away-listener)
12052
- */
12053
- function ClickAwayListener(props) {
12054
- const {
12055
- children,
12056
- disableReactTree = false,
12057
- mouseEvent = 'onClick',
12058
- onClickAway,
12059
- touchEvent = 'onTouchEnd'
12060
- } = props;
12061
- const movedRef = React__namespace.useRef(false);
12062
- const nodeRef = React__namespace.useRef(null);
12063
- const activatedRef = React__namespace.useRef(false);
12064
- const syntheticEventRef = React__namespace.useRef(false);
12065
- React__namespace.useEffect(() => {
12066
- // Ensure that this component is not "activated" synchronously.
12067
- // https://github.com/facebook/react/issues/20074
12068
- setTimeout(() => {
12069
- activatedRef.current = true;
12070
- }, 0);
12071
- return () => {
12072
- activatedRef.current = false;
12073
- };
12074
- }, []);
12075
- const handleRef = useForkRef(
12076
- // @ts-expect-error TODO upstream fix
12077
- children.ref, nodeRef);
12078
-
12079
- // The handler doesn't take event.defaultPrevented into account:
12080
- //
12081
- // event.preventDefault() is meant to stop default behaviors like
12082
- // clicking a checkbox to check it, hitting a button to submit a form,
12083
- // and hitting left arrow to move the cursor in a text input etc.
12084
- // Only special HTML elements have these default behaviors.
12085
- const handleClickAway = useEventCallback(event => {
12086
- // Given developers can stop the propagation of the synthetic event,
12087
- // we can only be confident with a positive value.
12088
- const insideReactTree = syntheticEventRef.current;
12089
- syntheticEventRef.current = false;
12090
- const doc = ownerDocument(nodeRef.current);
12091
-
12092
- // 1. IE11 support, which trigger the handleClickAway even after the unbind
12093
- // 2. The child might render null.
12094
- // 3. Behave like a blur listener.
12095
- if (!activatedRef.current || !nodeRef.current || 'clientX' in event && clickedRootScrollbar$1(event, doc)) {
12096
- return;
12097
- }
12098
-
12099
- // Do not act if user performed touchmove
12100
- if (movedRef.current) {
12101
- movedRef.current = false;
12102
- return;
12103
- }
12104
- let insideDOM;
12105
-
12106
- // If not enough, can use https://github.com/DieterHolvoet/event-propagation-path/blob/master/propagationPath.js
12107
- if (event.composedPath) {
12108
- insideDOM = event.composedPath().indexOf(nodeRef.current) > -1;
12109
- } else {
12110
- insideDOM = !doc.documentElement.contains(
12111
- // @ts-expect-error returns `false` as intended when not dispatched from a Node
12112
- event.target) || nodeRef.current.contains(
12113
- // @ts-expect-error returns `false` as intended when not dispatched from a Node
12114
- event.target);
12115
- }
12116
- if (!insideDOM && (disableReactTree || !insideReactTree)) {
12117
- onClickAway(event);
12118
- }
12119
- });
12120
-
12121
- // Keep track of mouse/touch events that bubbled up through the portal.
12122
- const createHandleSynthetic = handlerName => event => {
12123
- syntheticEventRef.current = true;
12124
- const childrenPropsHandler = children.props[handlerName];
12125
- if (childrenPropsHandler) {
12126
- childrenPropsHandler(event);
12127
- }
12128
- };
12129
- const childrenProps = {
12130
- ref: handleRef
12131
- };
12132
- if (touchEvent !== false) {
12133
- childrenProps[touchEvent] = createHandleSynthetic(touchEvent);
12134
- }
12135
- React__namespace.useEffect(() => {
12136
- if (touchEvent !== false) {
12137
- const mappedTouchEvent = mapEventPropToEvent(touchEvent);
12138
- const doc = ownerDocument(nodeRef.current);
12139
- const handleTouchMove = () => {
12140
- movedRef.current = true;
12141
- };
12142
- doc.addEventListener(mappedTouchEvent, handleClickAway);
12143
- doc.addEventListener('touchmove', handleTouchMove);
12144
- return () => {
12145
- doc.removeEventListener(mappedTouchEvent, handleClickAway);
12146
- doc.removeEventListener('touchmove', handleTouchMove);
12147
- };
12148
- }
12149
- return undefined;
12150
- }, [handleClickAway, touchEvent]);
12151
- if (mouseEvent !== false) {
12152
- childrenProps[mouseEvent] = createHandleSynthetic(mouseEvent);
12153
- }
12154
- React__namespace.useEffect(() => {
12155
- if (mouseEvent !== false) {
12156
- const mappedMouseEvent = mapEventPropToEvent(mouseEvent);
12157
- const doc = ownerDocument(nodeRef.current);
12158
- doc.addEventListener(mappedMouseEvent, handleClickAway);
12159
- return () => {
12160
- doc.removeEventListener(mappedMouseEvent, handleClickAway);
12161
- };
12162
- }
12163
- return undefined;
12164
- }, [handleClickAway, mouseEvent]);
12165
- return /*#__PURE__*/jsxRuntimeExports.jsx(React__namespace.Fragment, {
12166
- children: /*#__PURE__*/React__namespace.cloneElement(children, childrenProps)
12167
- });
12168
- }
12169
- process.env.NODE_ENV !== "production" ? ClickAwayListener.propTypes /* remove-proptypes */ = {
12170
- // ┌────────────────────────────── Warning ──────────────────────────────┐
12171
- // │ These PropTypes are generated from the TypeScript type definitions. │
12172
- // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
12173
- // └─────────────────────────────────────────────────────────────────────┘
12174
- /**
12175
- * The wrapped element.
12176
- */
12177
- children: elementAcceptingRef.isRequired,
12178
- /**
12179
- * If `true`, the React tree is ignored and only the DOM tree is considered.
12180
- * This prop changes how portaled elements are handled.
12181
- * @default false
12182
- */
12183
- disableReactTree: PropTypes.bool,
12184
- /**
12185
- * The mouse event to listen to. You can disable the listener by providing `false`.
12186
- * @default 'onClick'
12187
- */
12188
- mouseEvent: PropTypes.oneOf(['onClick', 'onMouseDown', 'onMouseUp', 'onPointerDown', 'onPointerUp', false]),
12189
- /**
12190
- * Callback fired when a "click away" event is detected.
12191
- */
12192
- onClickAway: PropTypes.func.isRequired,
12193
- /**
12194
- * The touch event to listen to. You can disable the listener by providing `false`.
12195
- * @default 'onTouchEnd'
12196
- */
12197
- touchEvent: PropTypes.oneOf(['onTouchEnd', 'onTouchStart', false])
12198
- } : void 0;
12199
- if (process.env.NODE_ENV !== 'production') {
12200
- // eslint-disable-next-line
12201
- ClickAwayListener['propTypes' + ''] = exactProp(ClickAwayListener.propTypes);
12202
- }
12203
-
12204
12035
  // Inspired by https://github.com/focus-trap/tabbable
12205
12036
  const candidatesSelector = ['input', 'select', 'textarea', 'a[href]', 'button', '[tabindex]', 'audio[controls]', 'video[controls]', '[contenteditable]:not([contenteditable="false"])'].join(',');
12206
12037
  function getTabIndex(node) {
@@ -59391,55 +59222,63 @@ const PasswordField = ({ props, variant }) => {
59391
59222
 
59392
59223
  const Monthpickerrender = ({ props, variant }) => {
59393
59224
  const ref = React$1.useRef(null);
59394
- const [calenderOpen, setCalenderOpen] = React$1.useState(false);
59225
+ // const [calenderOpen, setCalenderOpen] = useState(false);
59226
+ const [open, setOpen] = React$1.useState(false);
59227
+ const handleToggle = () => {
59228
+ var _a;
59229
+ if (!open) {
59230
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.blur();
59231
+ }
59232
+ setOpen(!open);
59233
+ };
59395
59234
  return (jsxRuntimeExports.jsx(Controller, { control: props.control, name: props.item.name, render: ({ field }) => {
59396
59235
  var _a, _b;
59397
- return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsxs(LocalizationProvider, Object.assign({ dateAdapter: AdapterDayjs }, { children: [renderLabel(variant, props), jsxRuntimeExports.jsx(ClickAwayListener, Object.assign({ onClickAway: () => setCalenderOpen(false) }, { children: jsxRuntimeExports.jsx(DatePicker, { ref: ref, label: variant !== "standard" && `${props.item.label}${props.item.required ? ' *' : ''}`, views: ["month", "year"], disabled: props.item.disable, value: field.value
59398
- ? dayjs(formatDateMonthAndYear(field.value || null))
59399
- : null, slotProps: {
59400
- textField: {
59401
- onClick: () => setCalenderOpen(true),
59402
- // onBlur: () => setCalenderOpen(false),
59403
- },
59404
- }, disableOpenPicker: props.item.disable,
59405
- // onMonthChange={() => setCalenderOpen(false)}
59406
- // onYearChange={() => setCalenderOpen(false)}
59407
- open: calenderOpen, defaultValue: field.value, onChange: (date) => {
59408
- field.onChange(dayjs(date).format("MM/YYYY"));
59409
- props.setValue(dayjs(date).format("MM/YYYY"));
59410
- }, sx: {
59411
- "& .css-1holvmy,.css-kichxs-MuiFormLabel-root-MuiInputLabel-root": {
59412
- top: "-10px",
59413
- },
59414
- "& input": {
59415
- paddingRight: "0px !important",
59416
- },
59417
- "& button": {
59418
- paddingLeft: "0px !important",
59419
- paddingRight: "0px !important",
59420
- },
59421
- },
59422
- // renderInput={(params:any) => (
59423
- // <TextField
59424
- // {...params}
59425
- // fullWidth
59426
- // disabled={props.item.disable || false}
59427
- // InputLabelProps={{
59428
- // shrink: true,
59429
- // }}
59430
- // inputProps={{
59431
- // min: props.item.minDate,
59432
- // }}
59433
- // />
59434
- // )}
59435
- // ToolbarComponent={({ date, decreaseMonth, increaseMonth }:any) => (
59436
- // <div>
59437
- // <button onClick={decreaseMonth}>&lt;</button>
59438
- // <span>{date.getMonth() + 1}</span>
59439
- // <button onClick={increaseMonth}>&gt;</button>
59440
- // </div>
59441
- // )}
59442
- minDate: props.item.minDate ? dayjs(props.item.minDate, 'MM/YYYY') : null, maxDate: props.item.maxDate ? dayjs(props.item.maxDate, 'MM/YYYY') : null }) }))] })), ((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.helperText) && (jsxRuntimeExports.jsxs("span", Object.assign({ style: {
59236
+ return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsxs(LocalizationProvider, Object.assign({ dateAdapter: AdapterDayjs }, { children: [renderLabel(variant, props), jsxRuntimeExports.jsx(DatePicker, { ref: ref, label: variant !== "standard" && `${props.item.label}${props.item.required ? ' *' : ''}`, views: ["month", "year"], disabled: props.item.disable, value: field.value
59237
+ ? dayjs(formatDateMonthAndYear(field.value || null))
59238
+ : null, slotProps: {
59239
+ textField: {
59240
+ onClick: () => handleToggle(),
59241
+ inputRef: ref,
59242
+ },
59243
+ }, disableOpenPicker: props.item.disable,
59244
+ // onMonthChange={() => setCalenderOpen(false)}
59245
+ // onYearChange={() => setCalenderOpen(false)}
59246
+ open: open, onOpen: handleToggle, onClose: handleToggle, defaultValue: field.value, onChange: (date) => {
59247
+ field.onChange(dayjs(date).format("MM/YYYY"));
59248
+ props.setValue(dayjs(date).format("MM/YYYY"));
59249
+ }, sx: {
59250
+ "& .css-1holvmy,.css-kichxs-MuiFormLabel-root-MuiInputLabel-root": {
59251
+ top: "-10px",
59252
+ },
59253
+ "& input": {
59254
+ paddingRight: "0px !important",
59255
+ },
59256
+ "& button": {
59257
+ paddingLeft: "0px !important",
59258
+ paddingRight: "0px !important",
59259
+ },
59260
+ },
59261
+ // renderInput={(params:any) => (
59262
+ // <TextField
59263
+ // {...params}
59264
+ // fullWidth
59265
+ // disabled={props.item.disable || false}
59266
+ // InputLabelProps={{
59267
+ // shrink: true,
59268
+ // }}
59269
+ // inputProps={{
59270
+ // min: props.item.minDate,
59271
+ // }}
59272
+ // />
59273
+ // )}
59274
+ // ToolbarComponent={({ date, decreaseMonth, increaseMonth }:any) => (
59275
+ // <div>
59276
+ // <button onClick={decreaseMonth}>&lt;</button>
59277
+ // <span>{date.getMonth() + 1}</span>
59278
+ // <button onClick={increaseMonth}>&gt;</button>
59279
+ // </div>
59280
+ // )}
59281
+ minDate: props.item.minDate ? dayjs(props.item.minDate, 'MM/YYYY') : null, maxDate: props.item.maxDate ? dayjs(props.item.maxDate, 'MM/YYYY') : null })] })), ((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.helperText) && (jsxRuntimeExports.jsxs("span", Object.assign({ style: {
59443
59282
  fontSize: "11px",
59444
59283
  color: "#3651d3",
59445
59284
  } }, { children: ["(", (_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.helperText, ")"] }))), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] }));