@lumx/react 3.6.5 → 3.6.6-alpha.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/index.d.ts +7 -6
- package/index.js +211 -181
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/chip/ChipGroup.stories.tsx +49 -0
- package/src/components/chip/ChipGroup.test.tsx +0 -7
- package/src/components/chip/ChipGroup.tsx +6 -6
- package/src/components/date-picker/DatePickerControlled.test.tsx +1 -1
- package/src/components/date-picker/DatePickerControlled.tsx +26 -4
- package/src/components/date-picker/DatePickerField.tsx +40 -48
- package/src/components/popover-dialog/PopoverDialog.test.tsx +11 -0
- package/src/components/popover-dialog/PopoverDialog.tsx +9 -1
- package/src/components/text-field/TextField.tsx +16 -1
- package/src/components/thumbnail/Thumbnail.tsx +4 -4
- package/src/hooks/usePreviousValue.ts +13 -0
- package/src/utils/date/getMonthCalendar.test.ts +14 -14
- package/src/utils/date/getWeekDays.test.ts +21 -21
- package/src/utils/date/getWeekDays.ts +4 -2
package/index.d.ts
CHANGED
|
@@ -470,7 +470,10 @@ declare type useChipGroupNavigationType<C = any> = (chips: C[], onChipDeleted: (
|
|
|
470
470
|
* Defines the props of the component.
|
|
471
471
|
*/
|
|
472
472
|
interface ChipGroupProps extends GenericProps {
|
|
473
|
-
/**
|
|
473
|
+
/**
|
|
474
|
+
* Chip horizontal alignment.
|
|
475
|
+
* @deprecated
|
|
476
|
+
*/
|
|
474
477
|
align?: HorizontalAlignment;
|
|
475
478
|
/** List of Chip. */
|
|
476
479
|
children: ReactNode;
|
|
@@ -596,19 +599,15 @@ declare const DatePickerControlled: Comp<DatePickerControlledProps, HTMLDivEleme
|
|
|
596
599
|
/**
|
|
597
600
|
* Defines the props of the component.
|
|
598
601
|
*/
|
|
599
|
-
interface DatePickerFieldProps extends GenericProps {
|
|
602
|
+
interface DatePickerFieldProps extends Omit<TextFieldProps, 'value' | 'onChange'>, GenericProps {
|
|
600
603
|
/** Default month. */
|
|
601
604
|
defaultMonth?: Date;
|
|
602
|
-
/** Whether the component is disabled or not. */
|
|
603
|
-
isDisabled?: boolean;
|
|
604
605
|
/** Locale (language or region) to use. */
|
|
605
606
|
locale?: string;
|
|
606
607
|
/** Date after which dates can't be selected. */
|
|
607
608
|
maxDate?: Date;
|
|
608
609
|
/** Date before which dates can't be selected. */
|
|
609
610
|
minDate?: Date;
|
|
610
|
-
/** Native input name property. */
|
|
611
|
-
name?: string;
|
|
612
611
|
/** Props to pass to the next month button (minus those already set by the DatePickerControlled props). */
|
|
613
612
|
nextButtonProps: Pick<IconButtonProps, 'label'> & Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis'>;
|
|
614
613
|
/** Props to pass to the previous month button (minus those already set by the DatePickerControlled props). */
|
|
@@ -2717,6 +2716,8 @@ interface TextFieldProps extends GenericProps, HasTheme {
|
|
|
2717
2716
|
isValid?: boolean;
|
|
2718
2717
|
/** Label text. */
|
|
2719
2718
|
label?: string;
|
|
2719
|
+
/** Additional label props. */
|
|
2720
|
+
labelProps?: InputLabelProps;
|
|
2720
2721
|
/** Max string length the input accepts (constrains the input and displays a character counter). */
|
|
2721
2722
|
maxLength?: number;
|
|
2722
2723
|
/** Minimum number of rows displayed in multiline mode (requires `multiline` to be enabled). */
|
package/index.js
CHANGED
|
@@ -6,8 +6,8 @@ import noop from 'lodash/noop';
|
|
|
6
6
|
import get from 'lodash/get';
|
|
7
7
|
import isFunction from 'lodash/isFunction';
|
|
8
8
|
import last from 'lodash/last';
|
|
9
|
-
import pull from 'lodash/pull';
|
|
10
9
|
import { createPortal } from 'react-dom';
|
|
10
|
+
import pull from 'lodash/pull';
|
|
11
11
|
import concat from 'lodash/concat';
|
|
12
12
|
import dropRight from 'lodash/dropRight';
|
|
13
13
|
import partition from 'lodash/partition';
|
|
@@ -1895,9 +1895,7 @@ const _excluded$d = ["align", "children", "className"];
|
|
|
1895
1895
|
/**
|
|
1896
1896
|
* Component default props.
|
|
1897
1897
|
*/
|
|
1898
|
-
const DEFAULT_PROPS$a = {
|
|
1899
|
-
align: Alignment.left
|
|
1900
|
-
};
|
|
1898
|
+
const DEFAULT_PROPS$a = {};
|
|
1901
1899
|
|
|
1902
1900
|
/**
|
|
1903
1901
|
* Component display name.
|
|
@@ -1924,7 +1922,6 @@ const InternalChipGroup = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1924
1922
|
} = props,
|
|
1925
1923
|
forwardedProps = _objectWithoutProperties(props, _excluded$d);
|
|
1926
1924
|
const chipGroupClassName = handleBasicClasses({
|
|
1927
|
-
align,
|
|
1928
1925
|
prefix: CLASSNAME$a
|
|
1929
1926
|
});
|
|
1930
1927
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
@@ -2159,11 +2156,16 @@ const getWeekDays = locale => {
|
|
|
2159
2156
|
const letter = iterDate.toLocaleDateString(locale.code, {
|
|
2160
2157
|
weekday: 'narrow'
|
|
2161
2158
|
});
|
|
2159
|
+
// Weed day long notation
|
|
2160
|
+
const long = iterDate.toLocaleDateString(locale.code, {
|
|
2161
|
+
weekday: 'long'
|
|
2162
|
+
});
|
|
2162
2163
|
// Day number (1-based index starting on Monday)
|
|
2163
2164
|
const number = iterDate.getDay();
|
|
2164
2165
|
weekDays.push({
|
|
2165
2166
|
letter,
|
|
2166
|
-
number
|
|
2167
|
+
number,
|
|
2168
|
+
long
|
|
2167
2169
|
});
|
|
2168
2170
|
iterDate.setDate(iterDate.getDate() + 1);
|
|
2169
2171
|
}
|
|
@@ -2248,6 +2250,18 @@ function parseLocale(locale) {
|
|
|
2248
2250
|
};
|
|
2249
2251
|
}
|
|
2250
2252
|
|
|
2253
|
+
/**
|
|
2254
|
+
* Returns the value from the previous render.
|
|
2255
|
+
*/
|
|
2256
|
+
function usePreviousValue(value) {
|
|
2257
|
+
const prevValueRef = React.useRef();
|
|
2258
|
+
const prevValue = prevValueRef.current;
|
|
2259
|
+
React.useEffect(() => {
|
|
2260
|
+
prevValueRef.current = value;
|
|
2261
|
+
}, [value]);
|
|
2262
|
+
return prevValue;
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2251
2265
|
/**
|
|
2252
2266
|
* Defines the props of the component.
|
|
2253
2267
|
*/
|
|
@@ -2285,6 +2299,14 @@ const DatePickerControlled = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2285
2299
|
const localeObj = parseLocale(locale);
|
|
2286
2300
|
return getMonthCalendar(localeObj, selectedMonth, minDate, maxDate);
|
|
2287
2301
|
}, [locale, minDate, maxDate, selectedMonth]);
|
|
2302
|
+
const prevSelectedMonth = usePreviousValue(selectedMonth);
|
|
2303
|
+
const monthHasChanged = prevSelectedMonth && !isSameDay(selectedMonth, prevSelectedMonth);
|
|
2304
|
+
|
|
2305
|
+
// Only set the aria-live after the month has changed otherwise it can get announced on mount when used in the popover dialog
|
|
2306
|
+
const [labelAriaLive, setLabelAriaLive] = React.useState();
|
|
2307
|
+
React.useEffect(() => {
|
|
2308
|
+
if (monthHasChanged) setLabelAriaLive('polite');
|
|
2309
|
+
}, [monthHasChanged]);
|
|
2288
2310
|
return /*#__PURE__*/React.createElement("div", {
|
|
2289
2311
|
ref: ref,
|
|
2290
2312
|
className: `${CLASSNAME$c}`
|
|
@@ -2301,7 +2323,8 @@ const DatePickerControlled = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2301
2323
|
onClick: onPrevMonthChange
|
|
2302
2324
|
})),
|
|
2303
2325
|
label: /*#__PURE__*/React.createElement("span", {
|
|
2304
|
-
className: `${CLASSNAME$c}__month
|
|
2326
|
+
className: `${CLASSNAME$c}__month`,
|
|
2327
|
+
"aria-live": labelAriaLive
|
|
2305
2328
|
}, selectedMonth.toLocaleDateString(locale, {
|
|
2306
2329
|
year: 'numeric',
|
|
2307
2330
|
month: 'long'
|
|
@@ -2313,14 +2336,18 @@ const DatePickerControlled = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2313
2336
|
}, weekDays.map(_ref => {
|
|
2314
2337
|
let {
|
|
2315
2338
|
letter,
|
|
2316
|
-
number
|
|
2339
|
+
number,
|
|
2340
|
+
long
|
|
2317
2341
|
} = _ref;
|
|
2318
2342
|
return /*#__PURE__*/React.createElement("div", {
|
|
2319
2343
|
key: number,
|
|
2320
2344
|
className: `${CLASSNAME$c}__day-wrapper`
|
|
2321
2345
|
}, /*#__PURE__*/React.createElement("span", {
|
|
2322
|
-
className: `${CLASSNAME$c}__week-day
|
|
2323
|
-
|
|
2346
|
+
className: `${CLASSNAME$c}__week-day`,
|
|
2347
|
+
"aria-hidden": true
|
|
2348
|
+
}, letter.toLocaleUpperCase()), /*#__PURE__*/React.createElement("span", {
|
|
2349
|
+
className: "visually-hidden"
|
|
2350
|
+
}, long));
|
|
2324
2351
|
})), /*#__PURE__*/React.createElement("div", {
|
|
2325
2352
|
className: `${CLASSNAME$c}__month-days ${CLASSNAME$c}__days-wrapper`
|
|
2326
2353
|
}, weeks.flatMap((week, weekIndex) => {
|
|
@@ -2344,8 +2371,16 @@ const DatePickerControlled = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2344
2371
|
disabled: isOutOfRange,
|
|
2345
2372
|
type: "button",
|
|
2346
2373
|
onClick: () => onChange(date)
|
|
2347
|
-
}, /*#__PURE__*/React.createElement("span",
|
|
2374
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
2375
|
+
"aria-hidden": true
|
|
2376
|
+
}, date.toLocaleDateString(locale, {
|
|
2348
2377
|
day: 'numeric'
|
|
2378
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
2379
|
+
className: "visually-hidden"
|
|
2380
|
+
}, date.toLocaleDateString(locale, {
|
|
2381
|
+
day: 'numeric',
|
|
2382
|
+
month: 'long',
|
|
2383
|
+
year: 'numeric'
|
|
2349
2384
|
}))));
|
|
2350
2385
|
});
|
|
2351
2386
|
}))));
|
|
@@ -2398,38 +2433,108 @@ const DatePicker = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2398
2433
|
DatePicker.displayName = COMPONENT_NAME$d;
|
|
2399
2434
|
DatePicker.className = CLASSNAME$c;
|
|
2400
2435
|
|
|
2401
|
-
|
|
2402
|
-
const
|
|
2436
|
+
const useBooleanState = defaultValue => {
|
|
2437
|
+
const [booleanValue, setBoolean] = useState(defaultValue);
|
|
2438
|
+
const setToFalse = useCallback(() => setBoolean(false), []);
|
|
2439
|
+
const setToTrue = useCallback(() => setBoolean(true), []);
|
|
2440
|
+
const toggleBoolean = useCallback(() => setBoolean(previousValue => !previousValue), []);
|
|
2441
|
+
return [booleanValue, setToFalse, setToTrue, toggleBoolean];
|
|
2442
|
+
};
|
|
2403
2443
|
|
|
2404
|
-
|
|
2405
|
-
const DISABLED_SELECTOR = `[hidden], [tabindex="-1"], [disabled]:not([disabled="false"]), [aria-disabled]:not([aria-disabled="false"])`;
|
|
2444
|
+
const _excluded$g = ["defaultMonth", "disabled", "isDisabled", "locale", "maxDate", "minDate", "name", "nextButtonProps", "onChange", "previousButtonProps", "value"];
|
|
2406
2445
|
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
}
|
|
2446
|
+
/**
|
|
2447
|
+
* Defines the props of the component.
|
|
2448
|
+
*/
|
|
2411
2449
|
|
|
2412
2450
|
/**
|
|
2413
|
-
*
|
|
2451
|
+
* Component display name.
|
|
2452
|
+
*/
|
|
2453
|
+
const COMPONENT_NAME$f = 'DatePickerField';
|
|
2454
|
+
|
|
2455
|
+
/**
|
|
2456
|
+
* DatePickerField component.
|
|
2414
2457
|
*
|
|
2415
|
-
* @param
|
|
2416
|
-
* @
|
|
2458
|
+
* @param props Component props.
|
|
2459
|
+
* @param ref Component ref.
|
|
2460
|
+
* @return React element.
|
|
2417
2461
|
*/
|
|
2418
|
-
|
|
2419
|
-
const
|
|
2462
|
+
const DatePickerField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
2463
|
+
const {
|
|
2464
|
+
defaultMonth,
|
|
2465
|
+
disabled,
|
|
2466
|
+
isDisabled = disabled,
|
|
2467
|
+
locale = getCurrentLocale(),
|
|
2468
|
+
maxDate,
|
|
2469
|
+
minDate,
|
|
2470
|
+
name,
|
|
2471
|
+
nextButtonProps,
|
|
2472
|
+
onChange,
|
|
2473
|
+
previousButtonProps,
|
|
2474
|
+
value
|
|
2475
|
+
} = props,
|
|
2476
|
+
forwardedProps = _objectWithoutProperties(props, _excluded$g);
|
|
2477
|
+
const anchorRef = useRef(null);
|
|
2478
|
+
const [isOpen, close,, toggleOpen] = useBooleanState(false);
|
|
2479
|
+
const handleKeyboardNav = useCallback(evt => {
|
|
2480
|
+
if (evt.key === 'Enter' || evt.key === ' ') {
|
|
2481
|
+
toggleOpen();
|
|
2482
|
+
}
|
|
2483
|
+
}, [toggleOpen]);
|
|
2484
|
+
const onTextFieldChange = useCallback((textFieldValue, textFieldName, event) => {
|
|
2485
|
+
if (!textFieldValue) {
|
|
2486
|
+
onChange(undefined, textFieldName, event);
|
|
2487
|
+
}
|
|
2488
|
+
}, [onChange]);
|
|
2489
|
+
const onDatePickerChange = useCallback(newDate => {
|
|
2490
|
+
onChange(newDate, name);
|
|
2491
|
+
close();
|
|
2492
|
+
}, [name, onChange, close]);
|
|
2420
2493
|
|
|
2421
|
-
//
|
|
2422
|
-
const
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
}
|
|
2431
|
-
|
|
2432
|
-
|
|
2494
|
+
// Format date for text field
|
|
2495
|
+
const textFieldValue = (value === null || value === void 0 ? void 0 : value.toLocaleDateString(locale, {
|
|
2496
|
+
year: 'numeric',
|
|
2497
|
+
month: 'long',
|
|
2498
|
+
day: 'numeric'
|
|
2499
|
+
})) || '';
|
|
2500
|
+
const todayOrSelectedDateRef = React.useRef(null);
|
|
2501
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TextField, _extends({
|
|
2502
|
+
ref: ref
|
|
2503
|
+
}, forwardedProps, {
|
|
2504
|
+
name: name,
|
|
2505
|
+
forceFocusStyle: isOpen,
|
|
2506
|
+
textFieldRef: anchorRef,
|
|
2507
|
+
value: textFieldValue,
|
|
2508
|
+
onClick: toggleOpen,
|
|
2509
|
+
onChange: onTextFieldChange,
|
|
2510
|
+
onKeyPress: handleKeyboardNav,
|
|
2511
|
+
isDisabled: isDisabled,
|
|
2512
|
+
readOnly: true,
|
|
2513
|
+
"aria-haspopup": "dialog"
|
|
2514
|
+
})), isOpen ? /*#__PURE__*/React.createElement(PopoverDialog
|
|
2515
|
+
// Can't use `aria-labelledby` targeting the text field label element (not correctly read on some screen readers)
|
|
2516
|
+
, {
|
|
2517
|
+
"aria-label": forwardedProps.label,
|
|
2518
|
+
anchorRef: anchorRef,
|
|
2519
|
+
placement: Placement.BOTTOM_START,
|
|
2520
|
+
isOpen: isOpen,
|
|
2521
|
+
onClose: close
|
|
2522
|
+
// On open, focus the selected day or today
|
|
2523
|
+
,
|
|
2524
|
+
focusElement: todayOrSelectedDateRef
|
|
2525
|
+
}, /*#__PURE__*/React.createElement(DatePicker, {
|
|
2526
|
+
locale: locale,
|
|
2527
|
+
maxDate: maxDate,
|
|
2528
|
+
minDate: minDate,
|
|
2529
|
+
value: value,
|
|
2530
|
+
todayOrSelectedDateRef: todayOrSelectedDateRef,
|
|
2531
|
+
onChange: onDatePickerChange,
|
|
2532
|
+
defaultMonth: defaultMonth,
|
|
2533
|
+
nextButtonProps: nextButtonProps,
|
|
2534
|
+
previousButtonProps: previousButtonProps
|
|
2535
|
+
})) : null);
|
|
2536
|
+
});
|
|
2537
|
+
DatePickerField.displayName = COMPONENT_NAME$f;
|
|
2433
2538
|
|
|
2434
2539
|
/**
|
|
2435
2540
|
* Keep track of listeners, only the last registered listener gets activated at any point (previously registered
|
|
@@ -2460,6 +2565,67 @@ function makeListenerTowerContext() {
|
|
|
2460
2565
|
};
|
|
2461
2566
|
}
|
|
2462
2567
|
|
|
2568
|
+
const LISTENERS = makeListenerTowerContext();
|
|
2569
|
+
|
|
2570
|
+
/**
|
|
2571
|
+
* Register a global listener on 'Escape' key pressed.
|
|
2572
|
+
*
|
|
2573
|
+
* If multiple listener are registered, only the last one is maintained. When a listener is unregistered, the previous
|
|
2574
|
+
* one gets activated again.
|
|
2575
|
+
*
|
|
2576
|
+
* @param callback Callback
|
|
2577
|
+
* @param closeOnEscape Disables the hook when false
|
|
2578
|
+
*/
|
|
2579
|
+
function useCallbackOnEscape(callback) {
|
|
2580
|
+
let closeOnEscape = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
2581
|
+
useEffect(() => {
|
|
2582
|
+
const rootElement = DOCUMENT === null || DOCUMENT === void 0 ? void 0 : DOCUMENT.body;
|
|
2583
|
+
if (!closeOnEscape || !callback || !rootElement) {
|
|
2584
|
+
return undefined;
|
|
2585
|
+
}
|
|
2586
|
+
const onKeyDown = onEscapePressed(callback);
|
|
2587
|
+
const listener = {
|
|
2588
|
+
enable: () => rootElement.addEventListener('keydown', onKeyDown),
|
|
2589
|
+
disable: () => rootElement.removeEventListener('keydown', onKeyDown)
|
|
2590
|
+
};
|
|
2591
|
+
LISTENERS.register(listener);
|
|
2592
|
+
return () => LISTENERS.unregister(listener);
|
|
2593
|
+
}, [callback, closeOnEscape]);
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
/** CSS selector listing all tabbable elements. */
|
|
2597
|
+
const TABBABLE_ELEMENTS_SELECTOR = `a[href], button, textarea, input:not([type="hidden"]):not([hidden]), [tabindex]`;
|
|
2598
|
+
|
|
2599
|
+
/** CSS selector matching element that are disabled (should not receive focus). */
|
|
2600
|
+
const DISABLED_SELECTOR = `[hidden], [tabindex="-1"], [disabled]:not([disabled="false"]), [aria-disabled]:not([aria-disabled="false"])`;
|
|
2601
|
+
|
|
2602
|
+
const isNotDisabled = element => !element.matches(DISABLED_SELECTOR);
|
|
2603
|
+
function getFocusableElements(element) {
|
|
2604
|
+
return Array.from(element.querySelectorAll(TABBABLE_ELEMENTS_SELECTOR)).filter(isNotDisabled);
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2607
|
+
/**
|
|
2608
|
+
* Get first and last elements focusable in an element.
|
|
2609
|
+
*
|
|
2610
|
+
* @param parentElement The element in which to search focusable elements.
|
|
2611
|
+
* @return first and last focusable elements
|
|
2612
|
+
*/
|
|
2613
|
+
function getFirstAndLastFocusable(parentElement) {
|
|
2614
|
+
const focusableElements = getFocusableElements(parentElement);
|
|
2615
|
+
|
|
2616
|
+
// First non disabled element.
|
|
2617
|
+
const first = focusableElements[0];
|
|
2618
|
+
// Last non disabled element.
|
|
2619
|
+
const last = focusableElements[focusableElements.length - 1];
|
|
2620
|
+
if (last && first) {
|
|
2621
|
+
return {
|
|
2622
|
+
first,
|
|
2623
|
+
last
|
|
2624
|
+
};
|
|
2625
|
+
}
|
|
2626
|
+
return {};
|
|
2627
|
+
}
|
|
2628
|
+
|
|
2463
2629
|
const FOCUS_TRAPS = makeListenerTowerContext();
|
|
2464
2630
|
|
|
2465
2631
|
/**
|
|
@@ -2540,136 +2706,6 @@ function useFocusTrap(focusZoneElement, focusElement) {
|
|
|
2540
2706
|
}, [focusElement, focusZoneElement]);
|
|
2541
2707
|
}
|
|
2542
2708
|
|
|
2543
|
-
const _excluded$g = ["defaultMonth", "disabled", "isDisabled", "locale", "maxDate", "minDate", "name", "nextButtonProps", "onChange", "previousButtonProps", "value"];
|
|
2544
|
-
|
|
2545
|
-
/**
|
|
2546
|
-
* Defines the props of the component.
|
|
2547
|
-
*/
|
|
2548
|
-
|
|
2549
|
-
/**
|
|
2550
|
-
* Component display name.
|
|
2551
|
-
*/
|
|
2552
|
-
const COMPONENT_NAME$f = 'DatePickerField';
|
|
2553
|
-
|
|
2554
|
-
/**
|
|
2555
|
-
* DatePickerField component.
|
|
2556
|
-
*
|
|
2557
|
-
* @param props Component props.
|
|
2558
|
-
* @param ref Component ref.
|
|
2559
|
-
* @return React element.
|
|
2560
|
-
*/
|
|
2561
|
-
const DatePickerField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
2562
|
-
const {
|
|
2563
|
-
defaultMonth,
|
|
2564
|
-
disabled,
|
|
2565
|
-
isDisabled = disabled,
|
|
2566
|
-
locale = getCurrentLocale(),
|
|
2567
|
-
maxDate,
|
|
2568
|
-
minDate,
|
|
2569
|
-
name,
|
|
2570
|
-
nextButtonProps,
|
|
2571
|
-
onChange,
|
|
2572
|
-
previousButtonProps,
|
|
2573
|
-
value
|
|
2574
|
-
} = props,
|
|
2575
|
-
forwardedProps = _objectWithoutProperties(props, _excluded$g);
|
|
2576
|
-
const [wrapperElement, setWrapperElement] = useState(null);
|
|
2577
|
-
const anchorRef = useRef(null);
|
|
2578
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
2579
|
-
const toggleSimpleMenu = () => {
|
|
2580
|
-
setIsOpen(!isOpen);
|
|
2581
|
-
};
|
|
2582
|
-
const onClose = useCallback(() => {
|
|
2583
|
-
setIsOpen(false);
|
|
2584
|
-
}, []);
|
|
2585
|
-
useFocus(anchorRef.current, isOpen);
|
|
2586
|
-
const handleKeyboardNav = evt => {
|
|
2587
|
-
if ((evt.key === 'Enter' || evt.key === ' ') && toggleSimpleMenu) {
|
|
2588
|
-
toggleSimpleMenu();
|
|
2589
|
-
}
|
|
2590
|
-
};
|
|
2591
|
-
|
|
2592
|
-
// Handle focus trap.
|
|
2593
|
-
const [todayOrSelectedDate, setTodayOrSelectedDate] = useState(null);
|
|
2594
|
-
useFocusTrap(isOpen && wrapperElement, todayOrSelectedDate);
|
|
2595
|
-
const onTextFieldChange = (textFieldValue, textFieldName, event) => {
|
|
2596
|
-
if (!textFieldValue) {
|
|
2597
|
-
onChange(undefined, textFieldName, event);
|
|
2598
|
-
}
|
|
2599
|
-
};
|
|
2600
|
-
const onDatePickerChange = newDate => {
|
|
2601
|
-
onChange(newDate, name);
|
|
2602
|
-
onClose();
|
|
2603
|
-
};
|
|
2604
|
-
|
|
2605
|
-
// Format date for text field
|
|
2606
|
-
const textFieldValue = (value === null || value === void 0 ? void 0 : value.toLocaleDateString(locale, {
|
|
2607
|
-
year: 'numeric',
|
|
2608
|
-
month: 'long',
|
|
2609
|
-
day: 'numeric'
|
|
2610
|
-
})) || '';
|
|
2611
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TextField, _extends({
|
|
2612
|
-
ref: ref
|
|
2613
|
-
}, forwardedProps, {
|
|
2614
|
-
name: name,
|
|
2615
|
-
forceFocusStyle: isOpen,
|
|
2616
|
-
textFieldRef: anchorRef,
|
|
2617
|
-
value: textFieldValue,
|
|
2618
|
-
onClick: toggleSimpleMenu,
|
|
2619
|
-
onChange: onTextFieldChange,
|
|
2620
|
-
onKeyPress: handleKeyboardNav,
|
|
2621
|
-
isDisabled: isDisabled,
|
|
2622
|
-
readOnly: true
|
|
2623
|
-
})), isOpen ? /*#__PURE__*/React.createElement(Popover, {
|
|
2624
|
-
anchorRef: anchorRef,
|
|
2625
|
-
placement: Placement.BOTTOM_START,
|
|
2626
|
-
isOpen: isOpen,
|
|
2627
|
-
onClose: onClose,
|
|
2628
|
-
closeOnClickAway: true,
|
|
2629
|
-
closeOnEscape: true
|
|
2630
|
-
}, /*#__PURE__*/React.createElement(DatePicker, {
|
|
2631
|
-
ref: setWrapperElement,
|
|
2632
|
-
locale: locale,
|
|
2633
|
-
maxDate: maxDate,
|
|
2634
|
-
minDate: minDate,
|
|
2635
|
-
value: value,
|
|
2636
|
-
onChange: onDatePickerChange,
|
|
2637
|
-
todayOrSelectedDateRef: setTodayOrSelectedDate,
|
|
2638
|
-
defaultMonth: defaultMonth,
|
|
2639
|
-
nextButtonProps: nextButtonProps,
|
|
2640
|
-
previousButtonProps: previousButtonProps
|
|
2641
|
-
})) : null);
|
|
2642
|
-
});
|
|
2643
|
-
DatePickerField.displayName = COMPONENT_NAME$f;
|
|
2644
|
-
|
|
2645
|
-
const LISTENERS = makeListenerTowerContext();
|
|
2646
|
-
|
|
2647
|
-
/**
|
|
2648
|
-
* Register a global listener on 'Escape' key pressed.
|
|
2649
|
-
*
|
|
2650
|
-
* If multiple listener are registered, only the last one is maintained. When a listener is unregistered, the previous
|
|
2651
|
-
* one gets activated again.
|
|
2652
|
-
*
|
|
2653
|
-
* @param callback Callback
|
|
2654
|
-
* @param closeOnEscape Disables the hook when false
|
|
2655
|
-
*/
|
|
2656
|
-
function useCallbackOnEscape(callback) {
|
|
2657
|
-
let closeOnEscape = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
2658
|
-
useEffect(() => {
|
|
2659
|
-
const rootElement = DOCUMENT === null || DOCUMENT === void 0 ? void 0 : DOCUMENT.body;
|
|
2660
|
-
if (!closeOnEscape || !callback || !rootElement) {
|
|
2661
|
-
return undefined;
|
|
2662
|
-
}
|
|
2663
|
-
const onKeyDown = onEscapePressed(callback);
|
|
2664
|
-
const listener = {
|
|
2665
|
-
enable: () => rootElement.addEventListener('keydown', onKeyDown),
|
|
2666
|
-
disable: () => rootElement.removeEventListener('keydown', onKeyDown)
|
|
2667
|
-
};
|
|
2668
|
-
LISTENERS.register(listener);
|
|
2669
|
-
return () => LISTENERS.unregister(listener);
|
|
2670
|
-
}, [callback, closeOnEscape]);
|
|
2671
|
-
}
|
|
2672
|
-
|
|
2673
2709
|
/**
|
|
2674
2710
|
* Convenient hook to create interaction observers.
|
|
2675
2711
|
*
|
|
@@ -8692,7 +8728,7 @@ Notification.displayName = COMPONENT_NAME$L;
|
|
|
8692
8728
|
Notification.className = CLASSNAME$I;
|
|
8693
8729
|
Notification.defaultProps = DEFAULT_PROPS$w;
|
|
8694
8730
|
|
|
8695
|
-
const _excluded$N = ["children", "isOpen", "focusElement", "label", "className"];
|
|
8731
|
+
const _excluded$N = ["children", "isOpen", "focusElement", "aria-label", "label", "className"];
|
|
8696
8732
|
|
|
8697
8733
|
/**
|
|
8698
8734
|
* PopoverDialog props.
|
|
@@ -8726,7 +8762,8 @@ const PopoverDialog = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
8726
8762
|
children,
|
|
8727
8763
|
isOpen,
|
|
8728
8764
|
focusElement,
|
|
8729
|
-
label,
|
|
8765
|
+
'aria-label': ariaLabel,
|
|
8766
|
+
label = ariaLabel,
|
|
8730
8767
|
className
|
|
8731
8768
|
} = props,
|
|
8732
8769
|
forwardedProps = _objectWithoutProperties(props, _excluded$N);
|
|
@@ -12180,7 +12217,7 @@ TabPanel.className = CLASSNAME$1c;
|
|
|
12180
12217
|
TabPanel.defaultProps = DEFAULT_PROPS$Z;
|
|
12181
12218
|
|
|
12182
12219
|
const _excluded$1l = ["id", "isDisabled", "isRequired", "placeholder", "multiline", "value", "setFocus", "onChange", "onFocus", "onBlur", "inputRef", "rows", "recomputeNumberOfRows", "type", "name", "hasError", "describedById"],
|
|
12183
|
-
_excluded2$3 = ["chips", "className", "clearButtonProps", "disabled", "error", "forceFocusStyle", "hasError", "helper", "icon", "id", "inputRef", "isDisabled", "isRequired", "isValid", "label", "maxLength", "minimumRows", "multiline", "name", "onBlur", "onChange", "onClear", "onFocus", "placeholder", "textFieldRef", "theme", "type", "value", "afterElement"];
|
|
12220
|
+
_excluded2$3 = ["chips", "className", "clearButtonProps", "disabled", "error", "forceFocusStyle", "hasError", "helper", "icon", "id", "inputRef", "isDisabled", "isRequired", "isValid", "label", "labelProps", "maxLength", "minimumRows", "multiline", "name", "onBlur", "onChange", "onClear", "onFocus", "placeholder", "textFieldRef", "theme", "type", "value", "afterElement"];
|
|
12184
12221
|
|
|
12185
12222
|
/**
|
|
12186
12223
|
* Defines the props of the component.
|
|
@@ -12334,6 +12371,7 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
12334
12371
|
isRequired,
|
|
12335
12372
|
isValid,
|
|
12336
12373
|
label,
|
|
12374
|
+
labelProps,
|
|
12337
12375
|
maxLength,
|
|
12338
12376
|
minimumRows,
|
|
12339
12377
|
multiline,
|
|
@@ -12414,12 +12452,12 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
12414
12452
|
}))
|
|
12415
12453
|
}, (label || maxLength) && /*#__PURE__*/React.createElement("div", {
|
|
12416
12454
|
className: `${CLASSNAME$1d}__header`
|
|
12417
|
-
}, label && /*#__PURE__*/React.createElement(InputLabel, {
|
|
12455
|
+
}, label && /*#__PURE__*/React.createElement(InputLabel, _extends({}, labelProps, {
|
|
12418
12456
|
htmlFor: textFieldId,
|
|
12419
12457
|
className: `${CLASSNAME$1d}__label`,
|
|
12420
12458
|
isRequired: isRequired,
|
|
12421
12459
|
theme: theme
|
|
12422
|
-
}, label), maxLength && /*#__PURE__*/React.createElement("div", {
|
|
12460
|
+
}), label), maxLength && /*#__PURE__*/React.createElement("div", {
|
|
12423
12461
|
className: `${CLASSNAME$1d}__char-counter`
|
|
12424
12462
|
}, /*#__PURE__*/React.createElement("span", null, maxLength - valueLength), maxLength - valueLength === 0 && /*#__PURE__*/React.createElement(Icon, {
|
|
12425
12463
|
icon: mdiAlertCircle,
|
|
@@ -12752,7 +12790,7 @@ const Thumbnail = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
12752
12790
|
isLoading,
|
|
12753
12791
|
hasBadge: !!badge
|
|
12754
12792
|
}), fillHeight && `${CLASSNAME$1e}--fill-height`)
|
|
12755
|
-
}), /*#__PURE__*/React.createElement("
|
|
12793
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
12756
12794
|
className: `${CLASSNAME$1e}__background`
|
|
12757
12795
|
}, /*#__PURE__*/React.createElement("img", _extends({}, imgProps, {
|
|
12758
12796
|
style: _objectSpread2(_objectSpread2(_objectSpread2({}, imgProps === null || imgProps === void 0 ? void 0 : imgProps.style), imageErrorStyle), focusPointStyle),
|
|
@@ -12766,7 +12804,7 @@ const Thumbnail = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
12766
12804
|
src: image,
|
|
12767
12805
|
alt: alt,
|
|
12768
12806
|
loading: loading
|
|
12769
|
-
})), !isLoading && hasError && /*#__PURE__*/React.createElement("
|
|
12807
|
+
})), !isLoading && hasError && /*#__PURE__*/React.createElement("span", {
|
|
12770
12808
|
className: `${CLASSNAME$1e}__fallback`
|
|
12771
12809
|
}, hasIconErrorFallback ? /*#__PURE__*/React.createElement(Icon, {
|
|
12772
12810
|
icon: fallback,
|
|
@@ -13137,14 +13175,6 @@ Tooltip.displayName = COMPONENT_NAME$1j;
|
|
|
13137
13175
|
Tooltip.className = CLASSNAME$1g;
|
|
13138
13176
|
Tooltip.defaultProps = DEFAULT_PROPS$11;
|
|
13139
13177
|
|
|
13140
|
-
const useBooleanState = defaultValue => {
|
|
13141
|
-
const [booleanValue, setBoolean] = useState(defaultValue);
|
|
13142
|
-
const setToFalse = useCallback(() => setBoolean(false), []);
|
|
13143
|
-
const setToTrue = useCallback(() => setBoolean(true), []);
|
|
13144
|
-
const toggleBoolean = useCallback(() => setBoolean(previousValue => !previousValue), []);
|
|
13145
|
-
return [booleanValue, setToFalse, setToTrue, toggleBoolean];
|
|
13146
|
-
};
|
|
13147
|
-
|
|
13148
13178
|
const _excluded$1p = ["aspectRatio", "className", "label", "icon", "size", "theme", "variant", "fileInputProps"];
|
|
13149
13179
|
|
|
13150
13180
|
/**
|