@lumx/react 3.9.2-alpha.8 → 3.9.2
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/index.d.ts +2 -0
- package/index.js +58 -32
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/date-picker/DatePickerControlled.tsx +52 -30
- package/src/components/popover/Popover.tsx +2 -2
- package/src/components/popover/constants.ts +5 -0
- package/src/components/text-field/TextField.tsx +3 -1
- package/src/components/tooltip/Tooltip.tsx +15 -4
- package/src/components/tooltip/constants.ts +7 -0
- package/src/stories/generated/TextField/Demos.stories.tsx +1 -0
package/index.d.ts
CHANGED
|
@@ -2820,6 +2820,8 @@ interface TextFieldProps extends GenericProps, HasTheme {
|
|
|
2820
2820
|
placeholder?: string;
|
|
2821
2821
|
/** Reference to the wrapper. */
|
|
2822
2822
|
textFieldRef?: Ref<HTMLDivElement>;
|
|
2823
|
+
/** Native input type (only when `multiline` is disabled). */
|
|
2824
|
+
type?: React.ComponentProps<'input'>['type'];
|
|
2823
2825
|
/** Value. */
|
|
2824
2826
|
value?: string;
|
|
2825
2827
|
/** On blur callback. */
|
package/index.js
CHANGED
|
@@ -2353,37 +2353,49 @@ const DatePickerControlled = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2353
2353
|
const localeObj = parseLocale(locale);
|
|
2354
2354
|
return getMonthCalendar(localeObj, selectedMonth, minDate, maxDate);
|
|
2355
2355
|
}, [locale, minDate, maxDate, selectedMonth]);
|
|
2356
|
-
const selectedYear = selectedMonth.
|
|
2356
|
+
const selectedYear = selectedMonth.getFullYear();
|
|
2357
|
+
const formattedYear = selectedMonth.toLocaleDateString(locale, {
|
|
2357
2358
|
year: 'numeric'
|
|
2358
2359
|
}).slice(0, 4);
|
|
2359
|
-
const [
|
|
2360
|
-
const isYearValid = Number(textFieldYearValue) > 0 && Number(textFieldYearValue) <= 9999;
|
|
2360
|
+
const [currentYear, setCurrentYear] = React__default.useState(String(selectedYear));
|
|
2361
2361
|
|
|
2362
2362
|
// Updates month offset when validating year. Adds or removes 12 months per year when updating year value.
|
|
2363
|
-
const updateMonthOffset = React__default.useCallback(
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
if (onMonthChange) {
|
|
2368
|
-
onMonthChange(addMonthResetDay(selectedMonth, offset));
|
|
2369
|
-
}
|
|
2363
|
+
const updateMonthOffset = React__default.useCallback(newYearValue => {
|
|
2364
|
+
const yearNumber = Number(newYearValue);
|
|
2365
|
+
if (yearNumber < 0 && yearNumber >= 9999) {
|
|
2366
|
+
return;
|
|
2370
2367
|
}
|
|
2371
|
-
|
|
2368
|
+
const previousYearNumber = selectedMonth.getFullYear();
|
|
2369
|
+
const offset = (yearNumber - previousYearNumber) * 12;
|
|
2370
|
+
onMonthChange === null || onMonthChange === void 0 ? void 0 : onMonthChange(addMonthResetDay(selectedMonth, offset));
|
|
2371
|
+
}, [selectedMonth, onMonthChange]);
|
|
2372
|
+
const onYearChange = React__default.useCallback((newYearValue, _, event) => {
|
|
2373
|
+
var _event$nativeEvent;
|
|
2374
|
+
setCurrentYear(newYearValue);
|
|
2375
|
+
|
|
2376
|
+
// Detect if change is coming from the spin up/down arrows
|
|
2377
|
+
const inputType = event === null || event === void 0 ? void 0 : (_event$nativeEvent = event.nativeEvent) === null || _event$nativeEvent === void 0 ? void 0 : _event$nativeEvent.inputType;
|
|
2378
|
+
if (
|
|
2379
|
+
// Chrome/Safari
|
|
2380
|
+
!inputType ||
|
|
2381
|
+
// Firefox
|
|
2382
|
+
inputType === 'insertReplacementText') {
|
|
2383
|
+
updateMonthOffset(newYearValue);
|
|
2384
|
+
}
|
|
2385
|
+
}, [updateMonthOffset]);
|
|
2386
|
+
const updateYear = React__default.useCallback(() => {
|
|
2387
|
+
updateMonthOffset(currentYear);
|
|
2388
|
+
}, [updateMonthOffset, currentYear]);
|
|
2389
|
+
const updateYearOnEnterPressed = React__default.useMemo(() => onEnterPressed(updateYear), [updateYear]);
|
|
2372
2390
|
const monthYear = selectedMonth.toLocaleDateString(locale, {
|
|
2373
2391
|
year: 'numeric',
|
|
2374
2392
|
month: 'long'
|
|
2375
2393
|
});
|
|
2376
2394
|
|
|
2377
|
-
//
|
|
2378
|
-
const handleKeyPress = React__default.useMemo(() => onEnterPressed(updateMonthOffset), [updateMonthOffset]);
|
|
2379
|
-
|
|
2380
|
-
// Required to update year in the TextField when the user changes year by using prev next month arrows
|
|
2395
|
+
// Update current year when selected year changes
|
|
2381
2396
|
React__default.useEffect(() => {
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
}
|
|
2385
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2386
|
-
}, [selectedMonth]);
|
|
2397
|
+
setCurrentYear(String(selectedYear));
|
|
2398
|
+
}, [selectedYear]);
|
|
2387
2399
|
const prevSelectedMonth = usePreviousValue(selectedMonth);
|
|
2388
2400
|
const monthHasChanged = prevSelectedMonth && !isSameDay(selectedMonth, prevSelectedMonth);
|
|
2389
2401
|
|
|
@@ -2392,7 +2404,7 @@ const DatePickerControlled = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2392
2404
|
React__default.useEffect(() => {
|
|
2393
2405
|
if (monthHasChanged) setLabelAriaLive('polite');
|
|
2394
2406
|
}, [monthHasChanged]);
|
|
2395
|
-
const
|
|
2407
|
+
const yearLabel = getYearDisplayName(locale);
|
|
2396
2408
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
2397
2409
|
ref: ref,
|
|
2398
2410
|
className: `${CLASSNAME$17}`
|
|
@@ -2419,15 +2431,15 @@ const DatePickerControlled = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2419
2431
|
gap: "regular",
|
|
2420
2432
|
vAlign: "center",
|
|
2421
2433
|
dir: "auto"
|
|
2422
|
-
}, (_RegExp$exec = RegExp(`(.*)(${
|
|
2423
|
-
value:
|
|
2424
|
-
"aria-label":
|
|
2425
|
-
onChange:
|
|
2434
|
+
}, (_RegExp$exec = RegExp(`(.*)(${formattedYear})(.*)`).exec(monthYear)) === null || _RegExp$exec === void 0 ? void 0 : _RegExp$exec.slice(1).filter(part => part !== '').map(part => part === formattedYear ? /*#__PURE__*/React__default.createElement(TextField, {
|
|
2435
|
+
value: currentYear,
|
|
2436
|
+
"aria-label": yearLabel,
|
|
2437
|
+
onChange: onYearChange,
|
|
2426
2438
|
type: "number",
|
|
2427
2439
|
max: 9999,
|
|
2428
2440
|
min: 0,
|
|
2429
|
-
onBlur:
|
|
2430
|
-
onKeyPress:
|
|
2441
|
+
onBlur: updateYear,
|
|
2442
|
+
onKeyPress: updateYearOnEnterPressed,
|
|
2431
2443
|
key: "year",
|
|
2432
2444
|
className: `${CLASSNAME$17}__year`
|
|
2433
2445
|
}) : /*#__PURE__*/React__default.createElement(Text, {
|
|
@@ -6409,6 +6421,11 @@ const FitAnchorWidth = {
|
|
|
6409
6421
|
*/
|
|
6410
6422
|
const ARROW_SIZE$1 = 14;
|
|
6411
6423
|
|
|
6424
|
+
/**
|
|
6425
|
+
* Popover default z-index
|
|
6426
|
+
*/
|
|
6427
|
+
const POPOVER_ZINDEX = 9999;
|
|
6428
|
+
|
|
6412
6429
|
/**
|
|
6413
6430
|
* Popper js modifier to fit popover min width to the anchor width.
|
|
6414
6431
|
*/
|
|
@@ -6602,7 +6619,7 @@ const DEFAULT_PROPS$P = {
|
|
|
6602
6619
|
placement: Placement.AUTO,
|
|
6603
6620
|
focusAnchorOnClose: true,
|
|
6604
6621
|
usePortal: true,
|
|
6605
|
-
zIndex:
|
|
6622
|
+
zIndex: POPOVER_ZINDEX
|
|
6606
6623
|
};
|
|
6607
6624
|
|
|
6608
6625
|
/** Method to render the popover inside a portal if usePortal is true */
|
|
@@ -13909,6 +13926,11 @@ Toolbar.displayName = COMPONENT_NAME$3;
|
|
|
13909
13926
|
Toolbar.className = CLASSNAME$3;
|
|
13910
13927
|
Toolbar.defaultProps = DEFAULT_PROPS$3;
|
|
13911
13928
|
|
|
13929
|
+
/**
|
|
13930
|
+
* Make sure tooltip appear above popovers.
|
|
13931
|
+
*/
|
|
13932
|
+
const TOOLTIP_ZINDEX = POPOVER_ZINDEX + 1;
|
|
13933
|
+
|
|
13912
13934
|
/**
|
|
13913
13935
|
* Add ref and ARIA attribute(s) in tooltip children or wrapped children.
|
|
13914
13936
|
* Button, IconButton, Icon and React HTML elements don't need to be wrapped but any other kind of children (array, fragment, custom components)
|
|
@@ -14092,7 +14114,7 @@ function useTooltipOpen(delay, anchorElement) {
|
|
|
14092
14114
|
};
|
|
14093
14115
|
}
|
|
14094
14116
|
|
|
14095
|
-
const _excluded$2 = ["label", "children", "className", "delay", "placement", "forceOpen", "closeMode", "ariaLinkMode"];
|
|
14117
|
+
const _excluded$2 = ["label", "children", "className", "delay", "placement", "forceOpen", "closeMode", "ariaLinkMode", "zIndex"];
|
|
14096
14118
|
|
|
14097
14119
|
/** Position of the tooltip relative to the anchor element. */
|
|
14098
14120
|
|
|
@@ -14116,7 +14138,8 @@ const CLASSNAME$2 = getRootClassName(COMPONENT_NAME$2);
|
|
|
14116
14138
|
const DEFAULT_PROPS$2 = {
|
|
14117
14139
|
placement: Placement.BOTTOM,
|
|
14118
14140
|
closeMode: 'unmount',
|
|
14119
|
-
ariaLinkMode: 'aria-describedby'
|
|
14141
|
+
ariaLinkMode: 'aria-describedby',
|
|
14142
|
+
zIndex: TOOLTIP_ZINDEX
|
|
14120
14143
|
};
|
|
14121
14144
|
|
|
14122
14145
|
/**
|
|
@@ -14141,7 +14164,8 @@ const Tooltip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
14141
14164
|
placement,
|
|
14142
14165
|
forceOpen,
|
|
14143
14166
|
closeMode,
|
|
14144
|
-
ariaLinkMode
|
|
14167
|
+
ariaLinkMode,
|
|
14168
|
+
zIndex
|
|
14145
14169
|
} = props,
|
|
14146
14170
|
forwardedProps = _objectWithoutProperties(props, _excluded$2);
|
|
14147
14171
|
// Disable in SSR.
|
|
@@ -14197,7 +14221,9 @@ const Tooltip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
14197
14221
|
position,
|
|
14198
14222
|
hidden: !isOpen && closeMode === 'hide'
|
|
14199
14223
|
})),
|
|
14200
|
-
style: styles.popper
|
|
14224
|
+
style: _objectSpread2(_objectSpread2({}, styles.popper), {}, {
|
|
14225
|
+
zIndex
|
|
14226
|
+
})
|
|
14201
14227
|
}, attributes.popper), /*#__PURE__*/React__default.createElement("div", {
|
|
14202
14228
|
className: `${CLASSNAME$2}__arrow`
|
|
14203
14229
|
}), /*#__PURE__*/React__default.createElement("div", {
|