@neo4j-ndl/react 4.9.38 → 4.9.40
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/lib/cjs/time-picker/TimePicker.js +5 -2
- package/lib/cjs/time-picker/TimePicker.js.map +1 -1
- package/lib/cjs/timezone-picker/TimeZonePicker.js +7 -4
- package/lib/cjs/timezone-picker/TimeZonePicker.js.map +1 -1
- package/lib/cjs/tooltip/Tooltip.js +57 -5
- package/lib/cjs/tooltip/Tooltip.js.map +1 -1
- package/lib/cjs/tooltip/stories/index.js +6 -2
- package/lib/cjs/tooltip/stories/index.js.map +1 -1
- package/lib/cjs/tooltip/stories/tooltip-rich-actions.story.js +30 -0
- package/lib/cjs/tooltip/stories/tooltip-rich-actions.story.js.map +1 -0
- package/lib/cjs/tooltip/stories/tooltip-rich.story.js +1 -1
- package/lib/cjs/tooltip/stories/tooltip-rich.story.js.map +1 -1
- package/lib/cjs/tooltip/use-tooltip.js +18 -3
- package/lib/cjs/tooltip/use-tooltip.js.map +1 -1
- package/lib/esm/time-picker/TimePicker.js +5 -2
- package/lib/esm/time-picker/TimePicker.js.map +1 -1
- package/lib/esm/timezone-picker/TimeZonePicker.js +7 -4
- package/lib/esm/timezone-picker/TimeZonePicker.js.map +1 -1
- package/lib/esm/tooltip/Tooltip.js +24 -5
- package/lib/esm/tooltip/Tooltip.js.map +1 -1
- package/lib/esm/tooltip/stories/index.js +4 -1
- package/lib/esm/tooltip/stories/index.js.map +1 -1
- package/lib/esm/tooltip/stories/tooltip-rich-actions.story.js +28 -0
- package/lib/esm/tooltip/stories/tooltip-rich-actions.story.js.map +1 -0
- package/lib/esm/tooltip/stories/tooltip-rich.story.js +2 -2
- package/lib/esm/tooltip/stories/tooltip-rich.story.js.map +1 -1
- package/lib/esm/tooltip/use-tooltip.js +19 -4
- package/lib/esm/tooltip/use-tooltip.js.map +1 -1
- package/lib/types/time-picker/TimePicker.d.ts.map +1 -1
- package/lib/types/timezone-picker/TimeZonePicker.d.ts.map +1 -1
- package/lib/types/tooltip/Tooltip.d.ts +5 -2
- package/lib/types/tooltip/Tooltip.d.ts.map +1 -1
- package/lib/types/tooltip/stories/index.d.ts +3 -1
- package/lib/types/tooltip/stories/index.d.ts.map +1 -1
- package/lib/types/tooltip/stories/tooltip-rich-actions.story.d.ts +24 -0
- package/lib/types/tooltip/stories/tooltip-rich-actions.story.d.ts.map +1 -0
- package/lib/types/tooltip/stories/tooltip-rich.story.d.ts.map +1 -1
- package/lib/types/tooltip/use-tooltip.d.ts +5 -0
- package/lib/types/tooltip/use-tooltip.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -60,6 +60,7 @@ const TimePicker = (_a) => {
|
|
|
60
60
|
const [lastAction, setLastAction] = (0, react_2.useState)('type');
|
|
61
61
|
const [error, setError] = (0, react_2.useState)(undefined);
|
|
62
62
|
const errorTextId = (0, react_2.useId)();
|
|
63
|
+
const listboxId = (0, react_2.useId)();
|
|
63
64
|
const timeOptions = (0, react_2.useMemo)(() => (0, generate_time_options_1.generateTimeOptions)(is24Hour, timeInterval), [is24Hour, timeInterval]);
|
|
64
65
|
const { themeClassName } = (0, theme_1.useNeedleTheme)();
|
|
65
66
|
const { isPopoverOpen, setIsPopoverOpen } = (0, time_picker_hooks_1.useTimePickerPopover)(false);
|
|
@@ -243,7 +244,9 @@ const TimePicker = (_a) => {
|
|
|
243
244
|
const mergedRef = (0, react_1.useMergeRefs)([refs.setReference, containerRef]);
|
|
244
245
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: (0, classnames_1.default)('ndl-time-picker', className, Object.assign({}, classes)), ref: mergedRef }, getReferenceProps(), { style: {
|
|
245
246
|
width: isFluid === true ? '100%' : 'fit-content',
|
|
246
|
-
}, children: [(0, jsx_runtime_1.jsxs)("label", { className: "ndl-time-picker-label", children: [label !== undefined && ((0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: size === 'large' ? 'body-large' : 'body-medium', children: label })), (0, jsx_runtime_1.jsxs)("div", { className: "ndl-time-picker-input-wrapper", style: Object.assign({ width: inputWidth }, style), children: [(0, jsx_runtime_1.jsx)("input", Object.assign({ "
|
|
247
|
+
}, children: [(0, jsx_runtime_1.jsxs)("label", { className: "ndl-time-picker-label", children: [label !== undefined && ((0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: size === 'large' ? 'body-large' : 'body-medium', children: label })), (0, jsx_runtime_1.jsxs)("div", { className: "ndl-time-picker-input-wrapper", style: Object.assign({ width: inputWidth }, style), children: [(0, jsx_runtime_1.jsx)("input", Object.assign({ role: "combobox", "aria-expanded": isPopoverOpen, "aria-controls": listboxId, "aria-activedescendant": isPopoverOpen && focusedIndex >= 0
|
|
248
|
+
? `${listboxId}-option-${focusedIndex}`
|
|
249
|
+
: undefined, "aria-label": label, "aria-invalid": Boolean(errorToShow), "aria-describedby": errorToShow ? errorTextId : undefined, className: "ndl-time-picker-input", type: "text", ref: inputRef, value: inputValue, disabled: isDisabled, readOnly: isReadOnly, required: isRequired, onChange: newHandleInputChange, onKeyDown: handleKeyDown, onClick: () => {
|
|
247
250
|
if (isReadOnly === true || isDisabled === true) {
|
|
248
251
|
return;
|
|
249
252
|
}
|
|
@@ -274,7 +277,7 @@ const TimePicker = (_a) => {
|
|
|
274
277
|
}
|
|
275
278
|
}, placeholder: format, maxLength: is24Hour ? 5 : 8 }, restProps, htmlAttributes)), (0, jsx_runtime_1.jsx)(icons_1.ClockIconOutline, { className: "ndl-icon-svg ndl-time-picker-icon" })] })] }), errorToShow !== undefined && ((0, jsx_runtime_1.jsxs)("div", { className: "ndl-time-picker-error-wrapper", role: "status", children: [(0, jsx_runtime_1.jsx)(icons_1.ExclamationCircleIconSolid, { className: "ndl-time-picker-error-icon" }), (0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: size === 'large' ? 'body-medium' : 'body-small', className: "ndl-time-picker-error-text", htmlAttributes: { id: errorTextId }, children: errorToShow })] }))] })), context.open && ((0, jsx_runtime_1.jsx)(conditional_wrap_1.ConditionalWrap, { shouldWrap: isPortaled, wrap: (wrapChildren) => ((0, jsx_runtime_1.jsx)(react_1.FloatingPortal, { children: wrapChildren })), children: (0, jsx_runtime_1.jsx)(react_1.FloatingFocusManager, { context: context, modal: false, initialFocus: -1, children: (0, jsx_runtime_1.jsx)("div", Object.assign({ ref: refs.setFloating, className: (0, classnames_1.default)(themeClassName, 'ndl-time-picker-popover', Object.assign({}, classes)), style: Object.assign(Object.assign(Object.assign({}, transitionStyles), floatingStyles), { width: isFluid === true
|
|
276
279
|
? (_d = containerRef.current) === null || _d === void 0 ? void 0 : _d.clientWidth
|
|
277
|
-
: undefined }) }, getFloatingProps(), { children: (0, jsx_runtime_1.jsx)("ul", { ref: listRef, tabIndex: -1, children: timeOptions.map((time, i) => ((0, jsx_runtime_1.jsx)("li", { role: "option", "aria-selected": (value === null || value === void 0 ? void 0 : value.toString(is24Hour)) === time ||
|
|
280
|
+
: undefined }) }, getFloatingProps(), { children: (0, jsx_runtime_1.jsx)("ul", { ref: listRef, role: "listbox", id: listboxId, tabIndex: -1, children: timeOptions.map((time, i) => ((0, jsx_runtime_1.jsx)("li", { id: `${listboxId}-option-${i}`, role: "option", "aria-selected": (value === null || value === void 0 ? void 0 : value.toString(is24Hour)) === time ||
|
|
278
281
|
(editedInput === null || editedInput === void 0 ? void 0 : editedInput.toString(is24Hour)) === time, value: time, onClick: (e) => {
|
|
279
282
|
e.stopPropagation();
|
|
280
283
|
e.preventDefault();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimePicker.js","sourceRoot":"","sources":["../../../src/time-picker/TimePicker.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAY4B;AAC5B,0CAAyC;AACzC,4DAAoC;AAEpC,iCAQe;AAGf,0DAAsD;AACtD,6DAA6D;AAC7D,oCAAwE;AACxE,oCA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,QAAQ,CAAC,MAAK,IAAI,EAE1C,KAAK,EAAE,IAAI,EACX,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oCACb,CAAC,CAAC,eAAe,EAAE,CAAC;oCACpB,CAAC,CAAC,cAAc,EAAE,CAAC;oCACnB,aAAa,CAAC,IAAI,CAAC,CAAC;oCACpB,gBAAgB,CAAC,KAAK,CAAC,CAAC;gCAC1B,CAAC,EACD,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE;oCACjB,CAAC,CAAC,eAAe,EAAE,CAAC;oCACpB,CAAC,CAAC,cAAc,EAAE,CAAC;gCACrB,CAAC,EACD,QAAQ,EAAE,CAAC,CAAC,EACZ,SAAS,EAAE,IAAA,oBAAU,EACnB,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EACnC,8BAA8B,CAC/B,EACD,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;oCACf,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;wCACtB,CAAC,CAAC,eAAe,EAAE,CAAC;wCACpB,aAAa,CAAC,IAAI,CAAC,CAAC;oCACtB,CAAC;gCACH,CAAC,YAEA,IAAI,IA7BA,CAAC,CA8BH,CACN,CAAC,GACC,IACD,GACe,GACP,CACnB,IACA,CACJ,CAAC;AACJ,CAAC,CAAC;AArZW,QAAA,UAAU,cAqZrB","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n autoUpdate,\n flip,\n FloatingFocusManager,\n FloatingPortal,\n offset,\n shift,\n useDismiss,\n useFloating,\n useInteractions,\n useMergeRefs,\n useTransitionStyles,\n} from '@floating-ui/react';\nimport { tokens } from '@neo4j-ndl/base';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport {\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { ClockIconOutline, ExclamationCircleIconSolid } from '../icons';\nimport { useNeedleTheme } from '../theme';\nimport { Typography } from '../typography';\nimport { generateTimeOptions } from './generate-time-options';\nimport { NeedleTime } from './needle-time';\nimport {\n useKeyboardNavigation,\n useTimePickerPopover,\n} from './time-picker-hooks';\n\nexport type TimeFormat = 'hh:mm' | 'hh:mm aa';\n\nexport type TimePickerProps = {\n /** The value of the time picker */\n value?: NeedleTime;\n /** The format of the time picker */\n format?: TimeFormat;\n /** Whether the time picker is fluid */\n isFluid?: boolean;\n /** Whether the time picker is read only */\n isReadOnly?: boolean;\n /** Whether the time picker is required */\n isRequired?: boolean;\n /** Whether the time picker is disabled */\n isDisabled?: boolean;\n /** The time interval of the time picker, in minutes */\n timeInterval?: number;\n /** The label of the time picker */\n label?: string;\n /** The size of the time picker */\n size?: 'small' | 'medium' | 'large';\n /** Manually set the error text */\n errorText?: string;\n /** Callback function triggered when the time picker value changes */\n onChange?: (time: NeedleTime) => void;\n /** Callback function triggered when the time picker encounters an error */\n onError?: (error: string, time: NeedleTime) => void;\n /**\n * Strategy for the dropdown floating element.\n * By default it is absolute, but if the component is inside of a needle Dialog, it is set to fixed.\n * If this prop is set, no auto-detection of Dialog is done.\n */\n floatingStrategy?: 'absolute' | 'fixed';\n /** Whether the dropdown element is rendered in a portal. */\n isPortaled?: boolean;\n};\n\nexport const TimePicker = <T extends React.ElementType = 'div'>({\n format = 'hh:mm',\n isDisabled,\n isFluid,\n isReadOnly,\n isRequired,\n value,\n timeInterval = 15,\n label,\n onChange,\n className,\n onError,\n style,\n size = 'medium',\n errorText,\n htmlAttributes,\n floatingStrategy,\n isPortaled: isPortaledProp,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, TimePickerProps>) => {\n const [editedInput, setEditedInput] = useState<NeedleTime | undefined>(value);\n\n const is24Hour = format === 'hh:mm';\n const [inputValue, setInputValue] = useState<string>(\n value?.toString(is24Hour) ?? '',\n );\n const listRef = useRef<HTMLUListElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n useImperativeHandle(ref, () => inputRef.current as HTMLInputElement, []);\n const [lastAction, setLastAction] = useState<'type' | 'arrow'>('type');\n const [error, setError] = useState<string | undefined>(undefined);\n const errorTextId = useId();\n\n const timeOptions = useMemo(\n () => generateTimeOptions(is24Hour, timeInterval),\n [is24Hour, timeInterval],\n );\n\n const { themeClassName } = useNeedleTheme();\n const { isPopoverOpen, setIsPopoverOpen } = useTimePickerPopover(false);\n const { focusedIndex, setFocusedIndex, handleArrowNavigation } =\n useKeyboardNavigation(listRef, timeOptions.length);\n\n const errorToShow =\n errorText !== undefined && errorText !== '' ? errorText : error;\n\n const classes = {\n 'ndl-disabled': isDisabled,\n 'ndl-error': errorToShow !== undefined,\n 'ndl-fluid': isFluid,\n 'ndl-large': size === 'large',\n 'ndl-medium': size === 'medium',\n 'ndl-read-only': isReadOnly,\n 'ndl-small': size === 'small',\n };\n\n const inputWidth =\n isFluid === true ? '100%' : is24Hour === true ? '6rem' : '9rem';\n\n const isValidTime = useCallback((hours: number, minutes: number) => {\n if (hours > 23 || hours < 0) {\n return false;\n }\n\n if (minutes > 59 || minutes < 0) {\n return false;\n }\n\n return true;\n }, []);\n\n useEffect(() => {\n if (error !== undefined) {\n onError?.(error, NeedleTime.fromString(inputValue));\n }\n }, [error, inputValue, onError]);\n\n useEffect(() => {\n setEditedInput(value);\n setInputValue(value?.toString(is24Hour) ?? '');\n }, [is24Hour, value]);\n\n useEffect(() => {\n if (isPopoverOpen) {\n setTimeout(() => {\n listRef.current?.children[focusedIndex]?.scrollIntoView({\n block: 'center',\n inline: 'nearest',\n });\n }, 0);\n } else {\n setTimeout(() => {\n inputRef.current?.blur();\n const selectedIndex =\n timeOptions.indexOf(value?.toString(is24Hour) ?? '') ?? 0;\n setFocusedIndex(selectedIndex);\n }, 0);\n }\n }, [\n focusedIndex,\n is24Hour,\n isPopoverOpen,\n value,\n setFocusedIndex,\n timeOptions,\n ]);\n\n const handleOnClick = (timeText: string) => {\n if (onChange) {\n onChange(NeedleTime.fromString(timeText));\n }\n setError(undefined);\n setInputValue(timeText);\n setEditedInput(NeedleTime.fromString(timeText));\n setIsPopoverOpen(false);\n };\n const newHandleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n scrollToTime(e.target.value);\n setInputValue(e.target.value);\n setLastAction('type');\n\n const time = NeedleTime.fromString(e.target.value);\n if (!isValidTime(time.hour, time.minute)) {\n setError('Invalid time');\n } else {\n setError(undefined);\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (isReadOnly === true || isDisabled === true) {\n e.preventDefault();\n return;\n }\n\n if (e.key === 'Escape') {\n setIsPopoverOpen(false);\n }\n\n setIsPopoverOpen(true);\n\n if (e.key === 'Enter') {\n if (lastAction === 'type' && inputValue.length >= (is24Hour ? 5 : 6)) {\n const time = NeedleTime.fromString(inputValue);\n handleOnClick(time.toString(is24Hour));\n } else if (lastAction === 'type' && !inputValue.includes(':')) {\n const time = NeedleTime.fromString(inputValue);\n if (isValidTime(time.hour, time.minute)) {\n handleOnClick(time.toString(is24Hour));\n }\n setIsPopoverOpen(false);\n } else {\n handleOnClick(timeOptions[focusedIndex]);\n }\n } else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n e.preventDefault();\n setLastAction('arrow');\n handleArrowNavigation(e.key);\n }\n };\n\n const scrollToTime = (startOfTime: string) => {\n const parsedTime = startOfTime.toLowerCase().replace(/[^0-9amp]/g, '');\n let index = -1;\n\n // Handle AM/PM input\n const isPM = parsedTime.includes('p');\n const isAM = parsedTime.includes('a');\n const timeDigits = parsedTime.replace(/[amp]/g, '');\n\n if (timeDigits.length === 1) {\n // Single digit - assume it's an hour\n const hour = `0${timeDigits}`;\n const searchTime = is24Hour\n ? `${hour}:00`\n : `${hour}:00 ${isPM ? 'PM' : 'AM'}`;\n index = timeOptions.indexOf(searchTime);\n } else {\n // Find closest matching time\n const closestTime = timeOptions.find((time) => {\n const timeWithoutSpecialChars = time\n .toLowerCase()\n .replace(/[^0-9amp]/g, '');\n if (isPM || isAM) {\n // If AM/PM specified, match that specifically\n return timeWithoutSpecialChars.startsWith(parsedTime);\n } else {\n // Otherwise just match the numbers\n return timeWithoutSpecialChars\n .replace(/[amp]/g, '')\n .startsWith(timeDigits);\n }\n });\n index = closestTime !== undefined ? timeOptions.indexOf(closestTime) : -1;\n }\n\n if (index !== -1) {\n setFocusedIndex(index);\n }\n\n return index;\n };\n\n /** Custom floating ui solution */\n const isInsideDialog = useIsInsideDialog();\n const isPortaled = isPortaledProp ?? !isInsideDialog;\n const containerRef = useRef<HTMLDivElement>(null);\n const { refs, floatingStyles, context } = useFloating({\n elements: {\n reference: containerRef.current,\n },\n middleware: [\n offset(10),\n flip({\n fallbackPlacements: ['top'],\n fallbackStrategy: 'bestFit',\n }),\n shift({ padding: 5 }),\n ],\n onOpenChange: (open) => {\n setIsPopoverOpen(open);\n },\n open: isDisabled !== true && isReadOnly !== true && isPopoverOpen,\n placement: 'bottom',\n strategy: floatingStrategy ?? (isInsideDialog ? 'fixed' : 'absolute'),\n whileElementsMounted: autoUpdate,\n });\n const dismiss = useDismiss(context);\n const { getReferenceProps, getFloatingProps } = useInteractions([dismiss]);\n const { styles: transitionStyles } = useTransitionStyles(context, {\n duration: Number.parseInt(tokens.motion.duration.quick) ?? 0,\n });\n\n const mergedRef = useMergeRefs([refs.setReference, containerRef]);\n\n return (\n <>\n <div\n className={classNames('ndl-time-picker', className, {\n ...classes,\n })}\n ref={mergedRef}\n {...getReferenceProps()}\n style={{\n width: isFluid === true ? '100%' : 'fit-content',\n }}\n >\n <label className=\"ndl-time-picker-label\">\n {label !== undefined && (\n <Typography\n variant={size === 'large' ? 'body-large' : 'body-medium'}\n >\n {label}\n </Typography>\n )}\n <div\n className=\"ndl-time-picker-input-wrapper\"\n style={{\n width: inputWidth,\n ...style,\n }}\n >\n <input\n aria-label={label} // TODO: handle label natively\n aria-invalid={Boolean(errorToShow)}\n aria-describedby={errorToShow ? errorTextId : undefined}\n className=\"ndl-time-picker-input\"\n type=\"text\"\n ref={inputRef}\n value={inputValue}\n disabled={isDisabled}\n readOnly={isReadOnly}\n required={isRequired}\n onChange={newHandleInputChange}\n onKeyDown={handleKeyDown}\n onClick={() => {\n if (isReadOnly === true || isDisabled === true) {\n return;\n }\n setIsPopoverOpen(true);\n }}\n onBlur={(e) => {\n if (isReadOnly === true || isDisabled === true) {\n return;\n }\n\n if (\n e.relatedTarget?.classList.contains(\n 'ndl-time-picker-popover-item',\n ) === true\n ) {\n return;\n }\n\n if (inputValue.length < 4) {\n setError('Invalid time');\n return;\n }\n\n const time = NeedleTime.fromString(inputValue);\n\n if (time === undefined || time === null) {\n setError('Invalid time');\n return;\n }\n\n if (!isValidTime(time.hour, time.minute)) {\n setError('Invalid time');\n } else {\n setError(undefined);\n setInputValue(time.toString(is24Hour));\n }\n }}\n placeholder={format}\n maxLength={is24Hour ? 5 : 8}\n {...restProps}\n {...htmlAttributes}\n />\n <ClockIconOutline className=\"ndl-icon-svg ndl-time-picker-icon\" />\n </div>\n </label>\n {errorToShow !== undefined && (\n <div className=\"ndl-time-picker-error-wrapper\" role=\"status\">\n <ExclamationCircleIconSolid className=\"ndl-time-picker-error-icon\" />\n <Typography\n variant={size === 'large' ? 'body-medium' : 'body-small'}\n className=\"ndl-time-picker-error-text\"\n htmlAttributes={{ id: errorTextId }}\n >\n {errorToShow}\n </Typography>\n </div>\n )}\n </div>\n\n {context.open && (\n <ConditionalWrap\n shouldWrap={isPortaled}\n wrap={(wrapChildren) => (\n <FloatingPortal>{wrapChildren}</FloatingPortal>\n )}\n >\n <FloatingFocusManager\n context={context}\n modal={false}\n initialFocus={-1}\n >\n <div\n ref={refs.setFloating}\n className={classNames(themeClassName, 'ndl-time-picker-popover', {\n ...classes,\n })}\n style={{\n ...transitionStyles,\n ...floatingStyles,\n width:\n isFluid === true\n ? containerRef.current?.clientWidth\n : undefined,\n }}\n {...getFloatingProps()}\n >\n <ul ref={listRef} tabIndex={-1}>\n {timeOptions.map((time, i) => (\n <li\n key={i}\n role=\"option\"\n aria-selected={\n value?.toString(is24Hour) === time ||\n editedInput?.toString(is24Hour) === time\n }\n value={time}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n handleOnClick(time);\n setIsPopoverOpen(false);\n }}\n onMouseDown={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n tabIndex={-1}\n className={classNames(\n focusedIndex === i ? 'focused' : '',\n 'ndl-time-picker-popover-item',\n )}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.stopPropagation();\n handleOnClick(time);\n }\n }}\n >\n {time}\n </li>\n ))}\n </ul>\n </div>\n </FloatingFocusManager>\n </ConditionalWrap>\n )}\n </>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"TimePicker.js","sourceRoot":"","sources":["../../../src/time-picker/TimePicker.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAY4B;AAC5B,0CAAyC;AACzC,4DAAoC;AAEpC,iCAQe;AAGf,0DAAsD;AACtD,6DAA6D;AAC7D,oCAAwE;AACxE,oCAA0C;AAC1C,8CAA2C;AAC3C,mEAA8D;AAC9D,+CAA2C;AAC3C,2DAG6B;AAuCtB,MAAM,UAAU,GAAG,CAAsC,EAoBnB,EAAE,EAAE;;QApBe,EAC9D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,IAAI,EAAC,QAAQ,mBAEX,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,CAAC,QAAQ,CAAC,MAAK,IAAI;oCAClC,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,QAAQ,CAAC,QAAQ,CAAC,MAAK,IAAI,EAE1C,KAAK,EAAE,IAAI,EACX,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oCACb,CAAC,CAAC,eAAe,EAAE,CAAC;oCACpB,CAAC,CAAC,cAAc,EAAE,CAAC;oCACnB,aAAa,CAAC,IAAI,CAAC,CAAC;oCACpB,gBAAgB,CAAC,KAAK,CAAC,CAAC;gCAC1B,CAAC,EACD,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE;oCACjB,CAAC,CAAC,eAAe,EAAE,CAAC;oCACpB,CAAC,CAAC,cAAc,EAAE,CAAC;gCACrB,CAAC,EACD,QAAQ,EAAE,CAAC,CAAC,EACZ,SAAS,EAAE,IAAA,oBAAU,EACnB,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EACnC,8BAA8B,CAC/B,EACD,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;oCACf,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;wCACtB,CAAC,CAAC,eAAe,EAAE,CAAC;wCACpB,aAAa,CAAC,IAAI,CAAC,CAAC;oCACtB,CAAC;gCACH,CAAC,YAEA,IAAI,IA7BA,CAAC,CA8BH,CACN,CAAC,GACC,IACD,GACe,GACP,CACnB,IACA,CACJ,CAAC;AACJ,CAAC,CAAC;AA/ZW,QAAA,UAAU,cA+ZrB","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n autoUpdate,\n flip,\n FloatingFocusManager,\n FloatingPortal,\n offset,\n shift,\n useDismiss,\n useFloating,\n useInteractions,\n useMergeRefs,\n useTransitionStyles,\n} from '@floating-ui/react';\nimport { tokens } from '@neo4j-ndl/base';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport {\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { ClockIconOutline, ExclamationCircleIconSolid } from '../icons';\nimport { useNeedleTheme } from '../theme';\nimport { Typography } from '../typography';\nimport { generateTimeOptions } from './generate-time-options';\nimport { NeedleTime } from './needle-time';\nimport {\n useKeyboardNavigation,\n useTimePickerPopover,\n} from './time-picker-hooks';\n\nexport type TimeFormat = 'hh:mm' | 'hh:mm aa';\n\nexport type TimePickerProps = {\n /** The value of the time picker */\n value?: NeedleTime;\n /** The format of the time picker */\n format?: TimeFormat;\n /** Whether the time picker is fluid */\n isFluid?: boolean;\n /** Whether the time picker is read only */\n isReadOnly?: boolean;\n /** Whether the time picker is required */\n isRequired?: boolean;\n /** Whether the time picker is disabled */\n isDisabled?: boolean;\n /** The time interval of the time picker, in minutes */\n timeInterval?: number;\n /** The label of the time picker */\n label?: string;\n /** The size of the time picker */\n size?: 'small' | 'medium' | 'large';\n /** Manually set the error text */\n errorText?: string;\n /** Callback function triggered when the time picker value changes */\n onChange?: (time: NeedleTime) => void;\n /** Callback function triggered when the time picker encounters an error */\n onError?: (error: string, time: NeedleTime) => void;\n /**\n * Strategy for the dropdown floating element.\n * By default it is absolute, but if the component is inside of a needle Dialog, it is set to fixed.\n * If this prop is set, no auto-detection of Dialog is done.\n */\n floatingStrategy?: 'absolute' | 'fixed';\n /** Whether the dropdown element is rendered in a portal. */\n isPortaled?: boolean;\n};\n\nexport const TimePicker = <T extends React.ElementType = 'div'>({\n format = 'hh:mm',\n isDisabled,\n isFluid,\n isReadOnly,\n isRequired,\n value,\n timeInterval = 15,\n label,\n onChange,\n className,\n onError,\n style,\n size = 'medium',\n errorText,\n htmlAttributes,\n floatingStrategy,\n isPortaled: isPortaledProp,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, TimePickerProps>) => {\n const [editedInput, setEditedInput] = useState<NeedleTime | undefined>(value);\n\n const is24Hour = format === 'hh:mm';\n const [inputValue, setInputValue] = useState<string>(\n value?.toString(is24Hour) ?? '',\n );\n const listRef = useRef<HTMLUListElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n useImperativeHandle(ref, () => inputRef.current as HTMLInputElement, []);\n const [lastAction, setLastAction] = useState<'type' | 'arrow'>('type');\n const [error, setError] = useState<string | undefined>(undefined);\n const errorTextId = useId();\n const listboxId = useId();\n\n const timeOptions = useMemo(\n () => generateTimeOptions(is24Hour, timeInterval),\n [is24Hour, timeInterval],\n );\n\n const { themeClassName } = useNeedleTheme();\n const { isPopoverOpen, setIsPopoverOpen } = useTimePickerPopover(false);\n const { focusedIndex, setFocusedIndex, handleArrowNavigation } =\n useKeyboardNavigation(listRef, timeOptions.length);\n\n const errorToShow =\n errorText !== undefined && errorText !== '' ? errorText : error;\n\n const classes = {\n 'ndl-disabled': isDisabled,\n 'ndl-error': errorToShow !== undefined,\n 'ndl-fluid': isFluid,\n 'ndl-large': size === 'large',\n 'ndl-medium': size === 'medium',\n 'ndl-read-only': isReadOnly,\n 'ndl-small': size === 'small',\n };\n\n const inputWidth =\n isFluid === true ? '100%' : is24Hour === true ? '6rem' : '9rem';\n\n const isValidTime = useCallback((hours: number, minutes: number) => {\n if (hours > 23 || hours < 0) {\n return false;\n }\n\n if (minutes > 59 || minutes < 0) {\n return false;\n }\n\n return true;\n }, []);\n\n useEffect(() => {\n if (error !== undefined) {\n onError?.(error, NeedleTime.fromString(inputValue));\n }\n }, [error, inputValue, onError]);\n\n useEffect(() => {\n setEditedInput(value);\n setInputValue(value?.toString(is24Hour) ?? '');\n }, [is24Hour, value]);\n\n useEffect(() => {\n if (isPopoverOpen) {\n setTimeout(() => {\n listRef.current?.children[focusedIndex]?.scrollIntoView({\n block: 'center',\n inline: 'nearest',\n });\n }, 0);\n } else {\n setTimeout(() => {\n inputRef.current?.blur();\n const selectedIndex =\n timeOptions.indexOf(value?.toString(is24Hour) ?? '') ?? 0;\n setFocusedIndex(selectedIndex);\n }, 0);\n }\n }, [\n focusedIndex,\n is24Hour,\n isPopoverOpen,\n value,\n setFocusedIndex,\n timeOptions,\n ]);\n\n const handleOnClick = (timeText: string) => {\n if (onChange) {\n onChange(NeedleTime.fromString(timeText));\n }\n setError(undefined);\n setInputValue(timeText);\n setEditedInput(NeedleTime.fromString(timeText));\n setIsPopoverOpen(false);\n };\n const newHandleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n scrollToTime(e.target.value);\n setInputValue(e.target.value);\n setLastAction('type');\n\n const time = NeedleTime.fromString(e.target.value);\n if (!isValidTime(time.hour, time.minute)) {\n setError('Invalid time');\n } else {\n setError(undefined);\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (isReadOnly === true || isDisabled === true) {\n e.preventDefault();\n return;\n }\n\n if (e.key === 'Escape') {\n setIsPopoverOpen(false);\n }\n\n setIsPopoverOpen(true);\n\n if (e.key === 'Enter') {\n if (lastAction === 'type' && inputValue.length >= (is24Hour ? 5 : 6)) {\n const time = NeedleTime.fromString(inputValue);\n handleOnClick(time.toString(is24Hour));\n } else if (lastAction === 'type' && !inputValue.includes(':')) {\n const time = NeedleTime.fromString(inputValue);\n if (isValidTime(time.hour, time.minute)) {\n handleOnClick(time.toString(is24Hour));\n }\n setIsPopoverOpen(false);\n } else {\n handleOnClick(timeOptions[focusedIndex]);\n }\n } else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n e.preventDefault();\n setLastAction('arrow');\n handleArrowNavigation(e.key);\n }\n };\n\n const scrollToTime = (startOfTime: string) => {\n const parsedTime = startOfTime.toLowerCase().replace(/[^0-9amp]/g, '');\n let index = -1;\n\n // Handle AM/PM input\n const isPM = parsedTime.includes('p');\n const isAM = parsedTime.includes('a');\n const timeDigits = parsedTime.replace(/[amp]/g, '');\n\n if (timeDigits.length === 1) {\n // Single digit - assume it's an hour\n const hour = `0${timeDigits}`;\n const searchTime = is24Hour\n ? `${hour}:00`\n : `${hour}:00 ${isPM ? 'PM' : 'AM'}`;\n index = timeOptions.indexOf(searchTime);\n } else {\n // Find closest matching time\n const closestTime = timeOptions.find((time) => {\n const timeWithoutSpecialChars = time\n .toLowerCase()\n .replace(/[^0-9amp]/g, '');\n if (isPM || isAM) {\n // If AM/PM specified, match that specifically\n return timeWithoutSpecialChars.startsWith(parsedTime);\n } else {\n // Otherwise just match the numbers\n return timeWithoutSpecialChars\n .replace(/[amp]/g, '')\n .startsWith(timeDigits);\n }\n });\n index = closestTime !== undefined ? timeOptions.indexOf(closestTime) : -1;\n }\n\n if (index !== -1) {\n setFocusedIndex(index);\n }\n\n return index;\n };\n\n /** Custom floating ui solution */\n const isInsideDialog = useIsInsideDialog();\n const isPortaled = isPortaledProp ?? !isInsideDialog;\n const containerRef = useRef<HTMLDivElement>(null);\n const { refs, floatingStyles, context } = useFloating({\n elements: {\n reference: containerRef.current,\n },\n middleware: [\n offset(10),\n flip({\n fallbackPlacements: ['top'],\n fallbackStrategy: 'bestFit',\n }),\n shift({ padding: 5 }),\n ],\n onOpenChange: (open) => {\n setIsPopoverOpen(open);\n },\n open: isDisabled !== true && isReadOnly !== true && isPopoverOpen,\n placement: 'bottom',\n strategy: floatingStrategy ?? (isInsideDialog ? 'fixed' : 'absolute'),\n whileElementsMounted: autoUpdate,\n });\n const dismiss = useDismiss(context);\n const { getReferenceProps, getFloatingProps } = useInteractions([dismiss]);\n const { styles: transitionStyles } = useTransitionStyles(context, {\n duration: Number.parseInt(tokens.motion.duration.quick) ?? 0,\n });\n\n const mergedRef = useMergeRefs([refs.setReference, containerRef]);\n\n return (\n <>\n <div\n className={classNames('ndl-time-picker', className, {\n ...classes,\n })}\n ref={mergedRef}\n {...getReferenceProps()}\n style={{\n width: isFluid === true ? '100%' : 'fit-content',\n }}\n >\n <label className=\"ndl-time-picker-label\">\n {label !== undefined && (\n <Typography\n variant={size === 'large' ? 'body-large' : 'body-medium'}\n >\n {label}\n </Typography>\n )}\n <div\n className=\"ndl-time-picker-input-wrapper\"\n style={{\n width: inputWidth,\n ...style,\n }}\n >\n <input\n role=\"combobox\"\n aria-expanded={isPopoverOpen}\n aria-controls={listboxId}\n aria-activedescendant={\n isPopoverOpen && focusedIndex >= 0\n ? `${listboxId}-option-${focusedIndex}`\n : undefined\n }\n aria-label={label} // TODO: handle label natively\n aria-invalid={Boolean(errorToShow)}\n aria-describedby={errorToShow ? errorTextId : undefined}\n className=\"ndl-time-picker-input\"\n type=\"text\"\n ref={inputRef}\n value={inputValue}\n disabled={isDisabled}\n readOnly={isReadOnly}\n required={isRequired}\n onChange={newHandleInputChange}\n onKeyDown={handleKeyDown}\n onClick={() => {\n if (isReadOnly === true || isDisabled === true) {\n return;\n }\n setIsPopoverOpen(true);\n }}\n onBlur={(e) => {\n if (isReadOnly === true || isDisabled === true) {\n return;\n }\n\n if (\n e.relatedTarget?.classList.contains(\n 'ndl-time-picker-popover-item',\n ) === true\n ) {\n return;\n }\n\n if (inputValue.length < 4) {\n setError('Invalid time');\n return;\n }\n\n const time = NeedleTime.fromString(inputValue);\n\n if (time === undefined || time === null) {\n setError('Invalid time');\n return;\n }\n\n if (!isValidTime(time.hour, time.minute)) {\n setError('Invalid time');\n } else {\n setError(undefined);\n setInputValue(time.toString(is24Hour));\n }\n }}\n placeholder={format}\n maxLength={is24Hour ? 5 : 8}\n {...restProps}\n {...htmlAttributes}\n />\n <ClockIconOutline className=\"ndl-icon-svg ndl-time-picker-icon\" />\n </div>\n </label>\n {errorToShow !== undefined && (\n <div className=\"ndl-time-picker-error-wrapper\" role=\"status\">\n <ExclamationCircleIconSolid className=\"ndl-time-picker-error-icon\" />\n <Typography\n variant={size === 'large' ? 'body-medium' : 'body-small'}\n className=\"ndl-time-picker-error-text\"\n htmlAttributes={{ id: errorTextId }}\n >\n {errorToShow}\n </Typography>\n </div>\n )}\n </div>\n\n {context.open && (\n <ConditionalWrap\n shouldWrap={isPortaled}\n wrap={(wrapChildren) => (\n <FloatingPortal>{wrapChildren}</FloatingPortal>\n )}\n >\n <FloatingFocusManager\n context={context}\n modal={false}\n initialFocus={-1}\n >\n <div\n ref={refs.setFloating}\n className={classNames(themeClassName, 'ndl-time-picker-popover', {\n ...classes,\n })}\n style={{\n ...transitionStyles,\n ...floatingStyles,\n width:\n isFluid === true\n ? containerRef.current?.clientWidth\n : undefined,\n }}\n {...getFloatingProps()}\n >\n <ul ref={listRef} role=\"listbox\" id={listboxId} tabIndex={-1}>\n {timeOptions.map((time, i) => (\n <li\n id={`${listboxId}-option-${i}`}\n key={i}\n role=\"option\"\n aria-selected={\n value?.toString(is24Hour) === time ||\n editedInput?.toString(is24Hour) === time\n }\n value={time}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n handleOnClick(time);\n setIsPopoverOpen(false);\n }}\n onMouseDown={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n tabIndex={-1}\n className={classNames(\n focusedIndex === i ? 'focused' : '',\n 'ndl-time-picker-popover-item',\n )}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.stopPropagation();\n handleOnClick(time);\n }\n }}\n >\n {time}\n </li>\n ))}\n </ul>\n </div>\n </FloatingFocusManager>\n </ConditionalWrap>\n )}\n </>\n );\n};\n"]}
|
|
@@ -60,6 +60,7 @@ const TimeZonePicker = (_a) => {
|
|
|
60
60
|
(0, react_2.useImperativeHandle)(ref, () => inputRef.current, []);
|
|
61
61
|
const [error, setError] = (0, react_2.useState)(undefined);
|
|
62
62
|
const errorTextId = (0, react_2.useId)();
|
|
63
|
+
const listboxId = (0, react_2.useId)();
|
|
63
64
|
const timezoneOptions = (0, react_2.useMemo)(() => {
|
|
64
65
|
if (mode === 'utc') {
|
|
65
66
|
return (0, generate_timezone_options_1.generateUTCTimeZoneOptions)(referenceDate);
|
|
@@ -241,7 +242,9 @@ const TimeZonePicker = (_a) => {
|
|
|
241
242
|
const mergedRef = (0, react_1.useMergeRefs)([refs.setReference, containerRef]);
|
|
242
243
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: (0, classnames_1.default)('ndl-timezone-picker', className, Object.assign({}, classes)), ref: mergedRef }, getReferenceProps(), { style: {
|
|
243
244
|
width: isFluid === true ? '100%' : 'fit-content',
|
|
244
|
-
}, children: [(0, jsx_runtime_1.jsxs)("label", { className: "ndl-timezone-picker-label", children: [label !== undefined && ((0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: size === 'large' ? 'body-large' : 'body-medium', children: label })), (0, jsx_runtime_1.jsxs)("div", { className: "ndl-timezone-picker-input-wrapper", style: Object.assign({ width: inputWidth }, style), children: [(0, jsx_runtime_1.jsx)("input", Object.assign({ "
|
|
245
|
+
}, children: [(0, jsx_runtime_1.jsxs)("label", { className: "ndl-timezone-picker-label", children: [label !== undefined && ((0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: size === 'large' ? 'body-large' : 'body-medium', children: label })), (0, jsx_runtime_1.jsxs)("div", { className: "ndl-timezone-picker-input-wrapper", style: Object.assign({ width: inputWidth }, style), children: [(0, jsx_runtime_1.jsx)("input", Object.assign({ role: "combobox", "aria-expanded": isPopoverOpen, "aria-controls": listboxId, "aria-activedescendant": isPopoverOpen && focusedIndex >= 0
|
|
246
|
+
? `${listboxId}-option-${focusedIndex}`
|
|
247
|
+
: undefined, "aria-label": label, "aria-invalid": Boolean(errorToShow), "aria-describedby": errorToShow ? errorTextId : undefined, className: "ndl-timezone-picker-input", type: "text", ref: inputRef, value: inputValue, disabled: isDisabled, readOnly: isReadOnly, required: isRequired, onChange: handleInputChange, onKeyDown: handleKeyDown, onClick: (e) => {
|
|
245
248
|
if (isReadOnly === true || isDisabled === true) {
|
|
246
249
|
return;
|
|
247
250
|
}
|
|
@@ -287,7 +290,7 @@ const TimeZonePicker = (_a) => {
|
|
|
287
290
|
? 'Select or type UTC offset (e.g., UTC+5:30)'
|
|
288
291
|
: 'Select timezone or type UTC offset' }, htmlAttributes, restProps)), (0, jsx_runtime_1.jsx)(outline_1.ChevronDownIcon, { className: "ndl-icon-svg ndl-timezone-picker-icon" })] })] }), errorToShow !== undefined && ((0, jsx_runtime_1.jsxs)("div", { className: "ndl-timezone-picker-error-wrapper", role: "status", children: [(0, jsx_runtime_1.jsx)(icons_1.ExclamationCircleIconSolid, { className: "ndl-timezone-picker-error-icon" }), (0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: size === 'large' ? 'body-medium' : 'body-small', className: "ndl-timezone-picker-error-text", htmlAttributes: { id: errorTextId }, children: errorToShow })] }))] })), context.open && ((0, jsx_runtime_1.jsx)(conditional_wrap_1.ConditionalWrap, { shouldWrap: isPortaled, wrap: (wrapChildren) => ((0, jsx_runtime_1.jsx)(react_1.FloatingPortal, { children: wrapChildren })), children: (0, jsx_runtime_1.jsx)(react_1.FloatingFocusManager, { context: context, modal: false, initialFocus: -1, children: (0, jsx_runtime_1.jsx)("div", Object.assign({ ref: refs.setFloating, className: (0, classnames_1.default)(themeClassName, 'ndl-timezone-picker-popover', Object.assign({}, classes)), style: Object.assign(Object.assign(Object.assign({}, transitionStyles), floatingStyles), { width: isFluid === true
|
|
289
292
|
? (_c = containerRef.current) === null || _c === void 0 ? void 0 : _c.clientWidth
|
|
290
|
-
: undefined }) }, getFloatingProps(), { children: (0, jsx_runtime_1.jsx)("ul", { ref: listRef, tabIndex: -1, children: mode === 'both' ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [utcOptions.length > 0 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("li", { className: "ndl-timezone-picker-section-header", children: "UTC Offsets" }), utcOptions.map((option, i) => ((0, jsx_runtime_1.jsx)("li", { role: "option", "aria-selected": value === option.value, value: option.value, onClick: (e) => {
|
|
293
|
+
: undefined }) }, getFloatingProps(), { children: (0, jsx_runtime_1.jsx)("ul", { ref: listRef, role: "listbox", id: listboxId, tabIndex: -1, children: mode === 'both' ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [utcOptions.length > 0 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("li", { className: "ndl-timezone-picker-section-header", children: "UTC Offsets" }), utcOptions.map((option, i) => ((0, jsx_runtime_1.jsx)("li", { id: `${listboxId}-option-${i}`, role: "option", "aria-selected": value === option.value, value: option.value, onClick: (e) => {
|
|
291
294
|
e.stopPropagation();
|
|
292
295
|
e.preventDefault();
|
|
293
296
|
handleOnClick(option.value);
|
|
@@ -302,7 +305,7 @@ const TimeZonePicker = (_a) => {
|
|
|
302
305
|
}
|
|
303
306
|
}, children: option.label }, option.value)))] })), cityOptions.length > 0 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("li", { className: "ndl-timezone-picker-section-header", children: "City-Based Timezones" }), cityOptions.map((option, i) => {
|
|
304
307
|
const adjustedIndex = i + utcOptions.length;
|
|
305
|
-
return ((0, jsx_runtime_1.jsx)("li", { role: "option", "aria-selected": value === option.value, value: option.value, onClick: (e) => {
|
|
308
|
+
return ((0, jsx_runtime_1.jsx)("li", { id: `${listboxId}-option-${adjustedIndex}`, role: "option", "aria-selected": value === option.value, value: option.value, onClick: (e) => {
|
|
306
309
|
e.stopPropagation();
|
|
307
310
|
e.preventDefault();
|
|
308
311
|
handleOnClick(option.value);
|
|
@@ -316,7 +319,7 @@ const TimeZonePicker = (_a) => {
|
|
|
316
319
|
handleOnClick(option.value);
|
|
317
320
|
}
|
|
318
321
|
}, children: option.label }, option.value));
|
|
319
|
-
})] })), utcOptions.length === 0 && cityOptions.length === 0 && ((0, jsx_runtime_1.jsx)("li", { className: "ndl-timezone-picker-popover-item ndl-timezone-picker-no-results", children: "No timezones found" }))] })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: filteredOptions.length > 0 ? (filteredOptions.map((option, i) => ((0, jsx_runtime_1.jsx)("li", { role: "option", "aria-selected": value === option.value, value: option.value, onClick: (e) => {
|
|
322
|
+
})] })), utcOptions.length === 0 && cityOptions.length === 0 && ((0, jsx_runtime_1.jsx)("li", { className: "ndl-timezone-picker-popover-item ndl-timezone-picker-no-results", children: "No timezones found" }))] })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: filteredOptions.length > 0 ? (filteredOptions.map((option, i) => ((0, jsx_runtime_1.jsx)("li", { id: `${listboxId}-option-${i}`, role: "option", "aria-selected": value === option.value, value: option.value, onClick: (e) => {
|
|
320
323
|
e.stopPropagation();
|
|
321
324
|
e.preventDefault();
|
|
322
325
|
handleOnClick(option.value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeZonePicker.js","sourceRoot":"","sources":["../../../src/timezone-picker/TimeZonePicker.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAY4B;AAC5B,yDAA8D;AAC9D,0CAAyC;AACzC,4DAAoC;AAEpC,iCAOe;AAGf,0DAAsD;AACtD,6DAA6D;AAC7D,oCAAsD;AACtD,oCAA0C;AAC1C,8CAA2C;AAC3C,2EAMqC;AACrC,mEAGiC;AA+C1B,MAAM,cAAc,GAAG,CAAC,EAoBa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*\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n autoUpdate,\n flip,\n FloatingFocusManager,\n FloatingPortal,\n offset,\n shift,\n useDismiss,\n useFloating,\n useInteractions,\n useMergeRefs,\n useTransitionStyles,\n} from '@floating-ui/react';\nimport { ChevronDownIcon } from '@heroicons/react/24/outline';\nimport { tokens } from '@neo4j-ndl/base';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport {\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { type CommonProps } from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { ExclamationCircleIconSolid } from '../icons';\nimport { useNeedleTheme } from '../theme';\nimport { Typography } from '../typography';\nimport {\n formatTimeZone,\n generateTimeZoneOptions,\n generateUTCTimeZoneOptions,\n isValidUTCFormat,\n parseCustomUTCOffset,\n} from './generate-timezone-options';\nimport {\n useKeyboardNavigation,\n useTimeZonePickerPopover,\n} from './timezone-picker-hooks';\n\nexport type TimeZonePickerProps = {\n /** The value of the timezone picker (IANA timezone identifier) */\n value?: string;\n /** Whether the timezone picker is fluid */\n isFluid?: boolean;\n /** Whether the timezone picker is read only */\n isReadOnly?: boolean;\n /** Whether the timezone picker is required */\n isRequired?: boolean;\n /** Whether the timezone picker is disabled */\n isDisabled?: boolean;\n /** The label of the timezone picker */\n label?: string;\n /** The size of the timezone picker */\n size?: 'small' | 'medium' | 'large';\n /** Manually set the error text */\n errorText?: string;\n /** Callback function triggered when the timezone picker value changes */\n onChange?: (timezone: string) => void;\n /** Callback function triggered when the timezone picker encounters an error */\n onError?: (error: string, timezone: string) => void;\n /**\n * Strategy for the dropdown floating element.\n * By default it is absolute, but if the component is inside of a needle Dialog, it is set to fixed.\n * If this prop is set, no auto-detection of Dialog is done.\n */\n floatingStrategy?: 'absolute' | 'fixed';\n /** Whether the dropdown element is rendered in a portal. */\n isPortaled?: boolean;\n /** Reference date for calculating timezone offsets (useful for DST-aware offset display) */\n referenceDate?: Date;\n /**\n * Display mode: 'city', 'utc', or 'both'\n * 'city' - shows city-based timezones, This should be used when the user needs to select a timezone for themselves or if they are selecting a timezone that's related to a date.\n * 'utc' - shows UTC timezones, This should be used when the user needs to select a timezone for a database entry or a technical application.\n * 'both' - shows both city-based and UTC timezones in separate sections, This should be used when the user needs to select a timezone for a database entry or a technical application, but also wants to see the city-based timezones for context for example a zoned date time.\n * @default 'city'\n * @example\n * <TimeZonePicker mode=\"city\" />\n * <TimeZonePicker mode=\"utc\" />\n * <TimeZonePicker mode=\"both\" />\n */\n mode?: 'city' | 'utc' | 'both';\n};\n\nexport const TimeZonePicker = ({\n isDisabled,\n isFluid,\n isReadOnly,\n isRequired,\n value,\n label,\n onChange,\n className,\n onError,\n style,\n size = 'medium',\n errorText,\n htmlAttributes,\n floatingStrategy,\n isPortaled: isPortaledProp,\n referenceDate,\n mode = 'city',\n ref,\n ...restProps\n}: CommonProps<'input', TimeZonePickerProps>) => {\n const [inputValue, setInputValue] = useState<string>(\n value\n ? formatTimeZone(value, referenceDate)\n : formatTimeZone(\n new Date().toISOString().split('T')[1].split('.')[0],\n referenceDate,\n ),\n );\n const [searchQuery, setSearchQuery] = useState<string>('');\n const listRef = useRef<HTMLUListElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n useImperativeHandle(ref, () => inputRef.current as HTMLInputElement, []);\n const [error, setError] = useState<string | undefined>(undefined);\n const errorTextId = useId();\n\n const timezoneOptions = useMemo(() => {\n if (mode === 'utc') {\n return generateUTCTimeZoneOptions(referenceDate);\n } else if (mode === 'city') {\n return generateTimeZoneOptions(referenceDate);\n } else {\n // 'both' mode - combine both lists, excluding UTC from city list to avoid duplication\n return [\n ...generateUTCTimeZoneOptions(referenceDate),\n ...generateTimeZoneOptions(referenceDate, true), // excludeUTC = true\n ];\n }\n }, [referenceDate, mode]);\n\n const { themeClassName } = useNeedleTheme();\n const { isPopoverOpen, setIsPopoverOpen } = useTimeZonePickerPopover(false);\n\n // Filter options based on search query\n const filteredOptions = useMemo(() => {\n if (!searchQuery) {\n return timezoneOptions;\n }\n\n const query = searchQuery.toLowerCase();\n return timezoneOptions.filter(\n (option) =>\n option.label.toLowerCase().includes(query) ||\n option.value.toLowerCase().includes(query),\n );\n }, [timezoneOptions, searchQuery]);\n\n // Split options into UTC and city-based sections for 'both' mode\n const { utcOptions, cityOptions } = useMemo(() => {\n if (mode !== 'both') {\n return { cityOptions: filteredOptions, utcOptions: [] };\n }\n\n const utc: typeof filteredOptions = [];\n const city: typeof filteredOptions = [];\n\n filteredOptions.forEach((option) => {\n // UTC options are those that start with \"UTC\" in their value or label\n if (\n option.value.toUpperCase().startsWith('UTC') ||\n option.label.toUpperCase().startsWith('UTC')\n ) {\n utc.push(option);\n } else {\n city.push(option);\n }\n });\n\n return { cityOptions: city, utcOptions: utc };\n }, [filteredOptions, mode]);\n\n const { focusedIndex, setFocusedIndex, handleArrowNavigation } =\n useKeyboardNavigation(filteredOptions.length);\n\n const errorToShow =\n errorText !== undefined && errorText !== '' ? errorText : error;\n\n const classes = {\n 'ndl-disabled': isDisabled,\n 'ndl-error': errorToShow !== undefined,\n 'ndl-fluid': isFluid,\n 'ndl-large': size === 'large',\n 'ndl-medium': size === 'medium',\n 'ndl-read-only': isReadOnly,\n 'ndl-small': size === 'small',\n };\n\n const inputWidth = isFluid === true ? '100%' : '16rem';\n\n useEffect(() => {\n if (error !== undefined) {\n onError?.(error, inputValue);\n }\n }, [error, inputValue, onError]);\n\n useEffect(() => {\n setInputValue(value ? formatTimeZone(value, referenceDate) : '');\n }, [value, referenceDate]);\n\n useEffect(() => {\n if (isPopoverOpen) {\n setTimeout(() => {\n listRef.current?.children[focusedIndex]?.scrollIntoView({\n block: 'center',\n inline: 'nearest',\n });\n }, 0);\n } else {\n setTimeout(() => {\n inputRef.current?.blur();\n const selectedIndex =\n filteredOptions.findIndex((opt) => opt.value === value) ?? 0;\n setFocusedIndex(selectedIndex >= 0 ? selectedIndex : 0);\n setSearchQuery('');\n }, 0);\n }\n }, [focusedIndex, isPopoverOpen, value, setFocusedIndex, filteredOptions]);\n\n const handleOnClick = (timezone: string) => {\n if (onChange) {\n onChange(timezone);\n }\n setError(undefined);\n setInputValue(formatTimeZone(timezone, referenceDate));\n setIsPopoverOpen(false);\n setSearchQuery('');\n };\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const query = e.target.value;\n setSearchQuery(query);\n setInputValue(query);\n\n // In UTC mode (utc or both), validate custom UTC input\n if (\n (mode === 'utc' || mode === 'both') &&\n query.trim().toUpperCase().startsWith('UTC')\n ) {\n if (isValidUTCFormat(query.trim())) {\n setError(undefined);\n } else {\n setError('Invalid UTC format. Use UTC+H:MM or UTC-H:MM');\n }\n return;\n }\n\n // Try to find a matching timezone\n const matchingOption = timezoneOptions.find(\n (opt) =>\n opt.label.toLowerCase().includes(query.toLowerCase()) ||\n opt.value.toLowerCase().includes(query.toLowerCase()),\n );\n\n if (matchingOption) {\n setError(undefined);\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (isReadOnly === true || isDisabled === true) {\n e.preventDefault();\n return;\n }\n\n if (e.key === 'Escape') {\n setIsPopoverOpen(false);\n setSearchQuery('');\n setInputValue(value ? formatTimeZone(value, referenceDate) : '');\n }\n\n setIsPopoverOpen(true);\n\n if (e.key === 'Enter') {\n // In UTC mode (utc or both), allow custom UTC input\n if (\n (mode === 'utc' || mode === 'both') &&\n inputValue.trim().toUpperCase().startsWith('UTC')\n ) {\n const parsedOffset = parseCustomUTCOffset(inputValue.trim());\n if (parsedOffset) {\n handleOnClick(parsedOffset);\n return;\n }\n }\n\n if (filteredOptions.length > 0) {\n const selectedOption = filteredOptions[focusedIndex];\n if (selectedOption) {\n handleOnClick(selectedOption.value);\n }\n }\n } else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n e.preventDefault();\n handleArrowNavigation(e.key);\n }\n };\n\n /** Custom floating ui solution */\n const isInsideDialog = useIsInsideDialog();\n const isPortaled = isPortaledProp ?? !isInsideDialog;\n const containerRef = useRef<HTMLDivElement>(null);\n const { refs, floatingStyles, context } = useFloating({\n elements: {\n reference: containerRef.current,\n },\n middleware: [\n offset(10),\n flip({\n fallbackPlacements: ['top'],\n fallbackStrategy: 'bestFit',\n }),\n shift({ padding: 5 }),\n ],\n onOpenChange: (open) => {\n setIsPopoverOpen(open);\n },\n open: isDisabled !== true && isReadOnly !== true && isPopoverOpen,\n placement: 'bottom',\n strategy: floatingStrategy ?? (isInsideDialog ? 'fixed' : 'absolute'),\n whileElementsMounted: autoUpdate,\n });\n const dismiss = useDismiss(context);\n const { getReferenceProps, getFloatingProps } = useInteractions([dismiss]);\n const { styles: transitionStyles } = useTransitionStyles(context, {\n duration: Number.parseInt(tokens.motion.duration.quick) ?? 0,\n });\n\n const mergedRef = useMergeRefs([refs.setReference, containerRef]);\n\n return (\n <>\n <div\n className={classNames('ndl-timezone-picker', className, {\n ...classes,\n })}\n ref={mergedRef}\n {...getReferenceProps()}\n style={{\n width: isFluid === true ? '100%' : 'fit-content',\n }}\n >\n <label className=\"ndl-timezone-picker-label\">\n {label !== undefined && (\n <Typography\n variant={size === 'large' ? 'body-large' : 'body-medium'}\n >\n {label}\n </Typography>\n )}\n <div\n className=\"ndl-timezone-picker-input-wrapper\"\n style={{\n width: inputWidth,\n ...style,\n }}\n >\n <input\n aria-label={label}\n aria-invalid={Boolean(errorToShow)}\n aria-describedby={errorToShow ? errorTextId : undefined}\n className=\"ndl-timezone-picker-input\"\n type=\"text\"\n ref={inputRef}\n value={inputValue}\n disabled={isDisabled}\n readOnly={isReadOnly}\n required={isRequired}\n onChange={handleInputChange}\n onKeyDown={handleKeyDown}\n onClick={(e) => {\n if (isReadOnly === true || isDisabled === true) {\n return;\n }\n setIsPopoverOpen(true);\n // Select all text on click for easy searching\n e.currentTarget.select();\n }}\n onFocus={(e) => {\n if (isReadOnly === true || isDisabled === true) {\n return;\n }\n // Select all text on focus for easy searching\n e.currentTarget.select();\n }}\n onBlur={(e) => {\n if (isReadOnly === true || isDisabled === true) {\n return;\n }\n\n if (\n e.relatedTarget?.classList.contains(\n 'ndl-timezone-picker-popover-item',\n ) === true\n ) {\n return;\n }\n\n // In UTC mode (utc or both), try to parse custom input on blur\n if (\n (mode === 'utc' || mode === 'both') &&\n inputValue.trim().toUpperCase().startsWith('UTC')\n ) {\n const parsedOffset = parseCustomUTCOffset(inputValue.trim());\n if (parsedOffset) {\n handleOnClick(parsedOffset);\n setError(undefined);\n return;\n }\n }\n\n // Reset to the current value if no valid selection was made\n if (value) {\n setInputValue(formatTimeZone(value, referenceDate));\n } else {\n setInputValue('');\n }\n setSearchQuery('');\n setError(undefined);\n }}\n placeholder={\n mode === 'city'\n ? 'Select timezone'\n : mode === 'utc'\n ? 'Select or type UTC offset (e.g., UTC+5:30)'\n : 'Select timezone or type UTC offset'\n }\n {...htmlAttributes}\n {...restProps}\n />\n <ChevronDownIcon className=\"ndl-icon-svg ndl-timezone-picker-icon\" />\n </div>\n </label>\n {errorToShow !== undefined && (\n <div className=\"ndl-timezone-picker-error-wrapper\" role=\"status\">\n <ExclamationCircleIconSolid className=\"ndl-timezone-picker-error-icon\" />\n <Typography\n variant={size === 'large' ? 'body-medium' : 'body-small'}\n className=\"ndl-timezone-picker-error-text\"\n htmlAttributes={{ id: errorTextId }}\n >\n {errorToShow}\n </Typography>\n </div>\n )}\n </div>\n\n {context.open && (\n <ConditionalWrap\n shouldWrap={isPortaled}\n wrap={(wrapChildren) => (\n <FloatingPortal>{wrapChildren}</FloatingPortal>\n )}\n >\n <FloatingFocusManager\n context={context}\n modal={false}\n initialFocus={-1}\n >\n <div\n ref={refs.setFloating}\n className={classNames(\n themeClassName,\n 'ndl-timezone-picker-popover',\n {\n ...classes,\n },\n )}\n style={{\n ...transitionStyles,\n ...floatingStyles,\n width:\n isFluid === true\n ? containerRef.current?.clientWidth\n : undefined,\n }}\n {...getFloatingProps()}\n >\n <ul ref={listRef} tabIndex={-1}>\n {mode === 'both' ? (\n <>\n {utcOptions.length > 0 && (\n <>\n <li className=\"ndl-timezone-picker-section-header\">\n UTC Offsets\n </li>\n {utcOptions.map((option, i) => (\n <li\n key={option.value}\n role=\"option\"\n aria-selected={value === option.value}\n value={option.value}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n handleOnClick(option.value);\n setIsPopoverOpen(false);\n }}\n onMouseDown={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n tabIndex={-1}\n className={classNames(\n focusedIndex === i ? 'focused' : '',\n 'ndl-timezone-picker-popover-item',\n )}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.stopPropagation();\n handleOnClick(option.value);\n }\n }}\n >\n {option.label}\n </li>\n ))}\n </>\n )}\n {cityOptions.length > 0 && (\n <>\n <li className=\"ndl-timezone-picker-section-header\">\n City-Based Timezones\n </li>\n {cityOptions.map((option, i) => {\n const adjustedIndex = i + utcOptions.length;\n return (\n <li\n key={option.value}\n role=\"option\"\n aria-selected={value === option.value}\n value={option.value}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n handleOnClick(option.value);\n setIsPopoverOpen(false);\n }}\n onMouseDown={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n tabIndex={-1}\n className={classNames(\n focusedIndex === adjustedIndex ? 'focused' : '',\n 'ndl-timezone-picker-popover-item',\n )}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.stopPropagation();\n handleOnClick(option.value);\n }\n }}\n >\n {option.label}\n </li>\n );\n })}\n </>\n )}\n {utcOptions.length === 0 && cityOptions.length === 0 && (\n <li className=\"ndl-timezone-picker-popover-item ndl-timezone-picker-no-results\">\n No timezones found\n </li>\n )}\n </>\n ) : (\n <>\n {filteredOptions.length > 0 ? (\n filteredOptions.map((option, i) => (\n <li\n key={option.value}\n role=\"option\"\n aria-selected={value === option.value}\n value={option.value}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n handleOnClick(option.value);\n setIsPopoverOpen(false);\n }}\n onMouseDown={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n tabIndex={-1}\n className={classNames(\n focusedIndex === i ? 'focused' : '',\n 'ndl-timezone-picker-popover-item',\n )}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.stopPropagation();\n handleOnClick(option.value);\n }\n }}\n >\n {option.label}\n </li>\n ))\n ) : (\n <li className=\"ndl-timezone-picker-popover-item ndl-timezone-picker-no-results\">\n No timezones found\n </li>\n )}\n </>\n )}\n </ul>\n </div>\n </FloatingFocusManager>\n </ConditionalWrap>\n )}\n </>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"TimeZonePicker.js","sourceRoot":"","sources":["../../../src/timezone-picker/TimeZonePicker.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAY4B;AAC5B,yDAA8D;AAC9D,0CAAyC;AACzC,4DAAoC;AAEpC,iCAOe;AAGf,0DAAsD;AACtD,6DAA6D;AAC7D,oCAAsD;AACtD,oCAA0C;AAC1C,8CAA2C;AAC3C,2EAMqC;AACrC,mEAGiC;AA+C1B,MAAM,cAAc,GAAG,CAAC,EAoBa,EAAE,EAAE;;QApBjB,EAC7B,UAAU,EACV,OAAO,EACP,UAAU,EACV,UAAU,EACV,KAAK,EACL,KAAK,EACL,QAAQ,EACR,SAAS,EACT,OAAO,EACP,KA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B,CAAC;oCACH,CAAC,YAEA,MAAM,CAAC,KAAK,IA1BR,MAAM,CAAC,KAAK,CA2Bd,CACN,CAAC,CACH,CAAC,CAAC,CAAC,CACF,+BAAI,SAAS,EAAC,iEAAiE,mCAE1E,CACN,GACA,CACJ,GACE,IACD,GACe,GACP,CACnB,IACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAjiBW,QAAA,cAAc,kBAiiBzB","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n autoUpdate,\n flip,\n FloatingFocusManager,\n FloatingPortal,\n offset,\n shift,\n useDismiss,\n useFloating,\n useInteractions,\n useMergeRefs,\n useTransitionStyles,\n} from '@floating-ui/react';\nimport { ChevronDownIcon } from '@heroicons/react/24/outline';\nimport { tokens } from '@neo4j-ndl/base';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport {\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { type CommonProps } from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { ExclamationCircleIconSolid } from '../icons';\nimport { useNeedleTheme } from '../theme';\nimport { Typography } from '../typography';\nimport {\n formatTimeZone,\n generateTimeZoneOptions,\n generateUTCTimeZoneOptions,\n isValidUTCFormat,\n parseCustomUTCOffset,\n} from './generate-timezone-options';\nimport {\n useKeyboardNavigation,\n useTimeZonePickerPopover,\n} from './timezone-picker-hooks';\n\nexport type TimeZonePickerProps = {\n /** The value of the timezone picker (IANA timezone identifier) */\n value?: string;\n /** Whether the timezone picker is fluid */\n isFluid?: boolean;\n /** Whether the timezone picker is read only */\n isReadOnly?: boolean;\n /** Whether the timezone picker is required */\n isRequired?: boolean;\n /** Whether the timezone picker is disabled */\n isDisabled?: boolean;\n /** The label of the timezone picker */\n label?: string;\n /** The size of the timezone picker */\n size?: 'small' | 'medium' | 'large';\n /** Manually set the error text */\n errorText?: string;\n /** Callback function triggered when the timezone picker value changes */\n onChange?: (timezone: string) => void;\n /** Callback function triggered when the timezone picker encounters an error */\n onError?: (error: string, timezone: string) => void;\n /**\n * Strategy for the dropdown floating element.\n * By default it is absolute, but if the component is inside of a needle Dialog, it is set to fixed.\n * If this prop is set, no auto-detection of Dialog is done.\n */\n floatingStrategy?: 'absolute' | 'fixed';\n /** Whether the dropdown element is rendered in a portal. */\n isPortaled?: boolean;\n /** Reference date for calculating timezone offsets (useful for DST-aware offset display) */\n referenceDate?: Date;\n /**\n * Display mode: 'city', 'utc', or 'both'\n * 'city' - shows city-based timezones, This should be used when the user needs to select a timezone for themselves or if they are selecting a timezone that's related to a date.\n * 'utc' - shows UTC timezones, This should be used when the user needs to select a timezone for a database entry or a technical application.\n * 'both' - shows both city-based and UTC timezones in separate sections, This should be used when the user needs to select a timezone for a database entry or a technical application, but also wants to see the city-based timezones for context for example a zoned date time.\n * @default 'city'\n * @example\n * <TimeZonePicker mode=\"city\" />\n * <TimeZonePicker mode=\"utc\" />\n * <TimeZonePicker mode=\"both\" />\n */\n mode?: 'city' | 'utc' | 'both';\n};\n\nexport const TimeZonePicker = ({\n isDisabled,\n isFluid,\n isReadOnly,\n isRequired,\n value,\n label,\n onChange,\n className,\n onError,\n style,\n size = 'medium',\n errorText,\n htmlAttributes,\n floatingStrategy,\n isPortaled: isPortaledProp,\n referenceDate,\n mode = 'city',\n ref,\n ...restProps\n}: CommonProps<'input', TimeZonePickerProps>) => {\n const [inputValue, setInputValue] = useState<string>(\n value\n ? formatTimeZone(value, referenceDate)\n : formatTimeZone(\n new Date().toISOString().split('T')[1].split('.')[0],\n referenceDate,\n ),\n );\n const [searchQuery, setSearchQuery] = useState<string>('');\n const listRef = useRef<HTMLUListElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n useImperativeHandle(ref, () => inputRef.current as HTMLInputElement, []);\n const [error, setError] = useState<string | undefined>(undefined);\n const errorTextId = useId();\n const listboxId = useId();\n\n const timezoneOptions = useMemo(() => {\n if (mode === 'utc') {\n return generateUTCTimeZoneOptions(referenceDate);\n } else if (mode === 'city') {\n return generateTimeZoneOptions(referenceDate);\n } else {\n // 'both' mode - combine both lists, excluding UTC from city list to avoid duplication\n return [\n ...generateUTCTimeZoneOptions(referenceDate),\n ...generateTimeZoneOptions(referenceDate, true), // excludeUTC = true\n ];\n }\n }, [referenceDate, mode]);\n\n const { themeClassName } = useNeedleTheme();\n const { isPopoverOpen, setIsPopoverOpen } = useTimeZonePickerPopover(false);\n\n // Filter options based on search query\n const filteredOptions = useMemo(() => {\n if (!searchQuery) {\n return timezoneOptions;\n }\n\n const query = searchQuery.toLowerCase();\n return timezoneOptions.filter(\n (option) =>\n option.label.toLowerCase().includes(query) ||\n option.value.toLowerCase().includes(query),\n );\n }, [timezoneOptions, searchQuery]);\n\n // Split options into UTC and city-based sections for 'both' mode\n const { utcOptions, cityOptions } = useMemo(() => {\n if (mode !== 'both') {\n return { cityOptions: filteredOptions, utcOptions: [] };\n }\n\n const utc: typeof filteredOptions = [];\n const city: typeof filteredOptions = [];\n\n filteredOptions.forEach((option) => {\n // UTC options are those that start with \"UTC\" in their value or label\n if (\n option.value.toUpperCase().startsWith('UTC') ||\n option.label.toUpperCase().startsWith('UTC')\n ) {\n utc.push(option);\n } else {\n city.push(option);\n }\n });\n\n return { cityOptions: city, utcOptions: utc };\n }, [filteredOptions, mode]);\n\n const { focusedIndex, setFocusedIndex, handleArrowNavigation } =\n useKeyboardNavigation(filteredOptions.length);\n\n const errorToShow =\n errorText !== undefined && errorText !== '' ? errorText : error;\n\n const classes = {\n 'ndl-disabled': isDisabled,\n 'ndl-error': errorToShow !== undefined,\n 'ndl-fluid': isFluid,\n 'ndl-large': size === 'large',\n 'ndl-medium': size === 'medium',\n 'ndl-read-only': isReadOnly,\n 'ndl-small': size === 'small',\n };\n\n const inputWidth = isFluid === true ? '100%' : '16rem';\n\n useEffect(() => {\n if (error !== undefined) {\n onError?.(error, inputValue);\n }\n }, [error, inputValue, onError]);\n\n useEffect(() => {\n setInputValue(value ? formatTimeZone(value, referenceDate) : '');\n }, [value, referenceDate]);\n\n useEffect(() => {\n if (isPopoverOpen) {\n setTimeout(() => {\n listRef.current?.children[focusedIndex]?.scrollIntoView({\n block: 'center',\n inline: 'nearest',\n });\n }, 0);\n } else {\n setTimeout(() => {\n inputRef.current?.blur();\n const selectedIndex =\n filteredOptions.findIndex((opt) => opt.value === value) ?? 0;\n setFocusedIndex(selectedIndex >= 0 ? selectedIndex : 0);\n setSearchQuery('');\n }, 0);\n }\n }, [focusedIndex, isPopoverOpen, value, setFocusedIndex, filteredOptions]);\n\n const handleOnClick = (timezone: string) => {\n if (onChange) {\n onChange(timezone);\n }\n setError(undefined);\n setInputValue(formatTimeZone(timezone, referenceDate));\n setIsPopoverOpen(false);\n setSearchQuery('');\n };\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const query = e.target.value;\n setSearchQuery(query);\n setInputValue(query);\n\n // In UTC mode (utc or both), validate custom UTC input\n if (\n (mode === 'utc' || mode === 'both') &&\n query.trim().toUpperCase().startsWith('UTC')\n ) {\n if (isValidUTCFormat(query.trim())) {\n setError(undefined);\n } else {\n setError('Invalid UTC format. Use UTC+H:MM or UTC-H:MM');\n }\n return;\n }\n\n // Try to find a matching timezone\n const matchingOption = timezoneOptions.find(\n (opt) =>\n opt.label.toLowerCase().includes(query.toLowerCase()) ||\n opt.value.toLowerCase().includes(query.toLowerCase()),\n );\n\n if (matchingOption) {\n setError(undefined);\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (isReadOnly === true || isDisabled === true) {\n e.preventDefault();\n return;\n }\n\n if (e.key === 'Escape') {\n setIsPopoverOpen(false);\n setSearchQuery('');\n setInputValue(value ? formatTimeZone(value, referenceDate) : '');\n }\n\n setIsPopoverOpen(true);\n\n if (e.key === 'Enter') {\n // In UTC mode (utc or both), allow custom UTC input\n if (\n (mode === 'utc' || mode === 'both') &&\n inputValue.trim().toUpperCase().startsWith('UTC')\n ) {\n const parsedOffset = parseCustomUTCOffset(inputValue.trim());\n if (parsedOffset) {\n handleOnClick(parsedOffset);\n return;\n }\n }\n\n if (filteredOptions.length > 0) {\n const selectedOption = filteredOptions[focusedIndex];\n if (selectedOption) {\n handleOnClick(selectedOption.value);\n }\n }\n } else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n e.preventDefault();\n handleArrowNavigation(e.key);\n }\n };\n\n /** Custom floating ui solution */\n const isInsideDialog = useIsInsideDialog();\n const isPortaled = isPortaledProp ?? !isInsideDialog;\n const containerRef = useRef<HTMLDivElement>(null);\n const { refs, floatingStyles, context } = useFloating({\n elements: {\n reference: containerRef.current,\n },\n middleware: [\n offset(10),\n flip({\n fallbackPlacements: ['top'],\n fallbackStrategy: 'bestFit',\n }),\n shift({ padding: 5 }),\n ],\n onOpenChange: (open) => {\n setIsPopoverOpen(open);\n },\n open: isDisabled !== true && isReadOnly !== true && isPopoverOpen,\n placement: 'bottom',\n strategy: floatingStrategy ?? (isInsideDialog ? 'fixed' : 'absolute'),\n whileElementsMounted: autoUpdate,\n });\n const dismiss = useDismiss(context);\n const { getReferenceProps, getFloatingProps } = useInteractions([dismiss]);\n const { styles: transitionStyles } = useTransitionStyles(context, {\n duration: Number.parseInt(tokens.motion.duration.quick) ?? 0,\n });\n\n const mergedRef = useMergeRefs([refs.setReference, containerRef]);\n\n return (\n <>\n <div\n className={classNames('ndl-timezone-picker', className, {\n ...classes,\n })}\n ref={mergedRef}\n {...getReferenceProps()}\n style={{\n width: isFluid === true ? '100%' : 'fit-content',\n }}\n >\n <label className=\"ndl-timezone-picker-label\">\n {label !== undefined && (\n <Typography\n variant={size === 'large' ? 'body-large' : 'body-medium'}\n >\n {label}\n </Typography>\n )}\n <div\n className=\"ndl-timezone-picker-input-wrapper\"\n style={{\n width: inputWidth,\n ...style,\n }}\n >\n <input\n role=\"combobox\"\n aria-expanded={isPopoverOpen}\n aria-controls={listboxId}\n aria-activedescendant={\n isPopoverOpen && focusedIndex >= 0\n ? `${listboxId}-option-${focusedIndex}`\n : undefined\n }\n aria-label={label}\n aria-invalid={Boolean(errorToShow)}\n aria-describedby={errorToShow ? errorTextId : undefined}\n className=\"ndl-timezone-picker-input\"\n type=\"text\"\n ref={inputRef}\n value={inputValue}\n disabled={isDisabled}\n readOnly={isReadOnly}\n required={isRequired}\n onChange={handleInputChange}\n onKeyDown={handleKeyDown}\n onClick={(e) => {\n if (isReadOnly === true || isDisabled === true) {\n return;\n }\n setIsPopoverOpen(true);\n // Select all text on click for easy searching\n e.currentTarget.select();\n }}\n onFocus={(e) => {\n if (isReadOnly === true || isDisabled === true) {\n return;\n }\n // Select all text on focus for easy searching\n e.currentTarget.select();\n }}\n onBlur={(e) => {\n if (isReadOnly === true || isDisabled === true) {\n return;\n }\n\n if (\n e.relatedTarget?.classList.contains(\n 'ndl-timezone-picker-popover-item',\n ) === true\n ) {\n return;\n }\n\n // In UTC mode (utc or both), try to parse custom input on blur\n if (\n (mode === 'utc' || mode === 'both') &&\n inputValue.trim().toUpperCase().startsWith('UTC')\n ) {\n const parsedOffset = parseCustomUTCOffset(inputValue.trim());\n if (parsedOffset) {\n handleOnClick(parsedOffset);\n setError(undefined);\n return;\n }\n }\n\n // Reset to the current value if no valid selection was made\n if (value) {\n setInputValue(formatTimeZone(value, referenceDate));\n } else {\n setInputValue('');\n }\n setSearchQuery('');\n setError(undefined);\n }}\n placeholder={\n mode === 'city'\n ? 'Select timezone'\n : mode === 'utc'\n ? 'Select or type UTC offset (e.g., UTC+5:30)'\n : 'Select timezone or type UTC offset'\n }\n {...htmlAttributes}\n {...restProps}\n />\n <ChevronDownIcon className=\"ndl-icon-svg ndl-timezone-picker-icon\" />\n </div>\n </label>\n {errorToShow !== undefined && (\n <div className=\"ndl-timezone-picker-error-wrapper\" role=\"status\">\n <ExclamationCircleIconSolid className=\"ndl-timezone-picker-error-icon\" />\n <Typography\n variant={size === 'large' ? 'body-medium' : 'body-small'}\n className=\"ndl-timezone-picker-error-text\"\n htmlAttributes={{ id: errorTextId }}\n >\n {errorToShow}\n </Typography>\n </div>\n )}\n </div>\n\n {context.open && (\n <ConditionalWrap\n shouldWrap={isPortaled}\n wrap={(wrapChildren) => (\n <FloatingPortal>{wrapChildren}</FloatingPortal>\n )}\n >\n <FloatingFocusManager\n context={context}\n modal={false}\n initialFocus={-1}\n >\n <div\n ref={refs.setFloating}\n className={classNames(\n themeClassName,\n 'ndl-timezone-picker-popover',\n {\n ...classes,\n },\n )}\n style={{\n ...transitionStyles,\n ...floatingStyles,\n width:\n isFluid === true\n ? containerRef.current?.clientWidth\n : undefined,\n }}\n {...getFloatingProps()}\n >\n <ul ref={listRef} role=\"listbox\" id={listboxId} tabIndex={-1}>\n {mode === 'both' ? (\n <>\n {utcOptions.length > 0 && (\n <>\n <li className=\"ndl-timezone-picker-section-header\">\n UTC Offsets\n </li>\n {utcOptions.map((option, i) => (\n <li\n id={`${listboxId}-option-${i}`}\n key={option.value}\n role=\"option\"\n aria-selected={value === option.value}\n value={option.value}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n handleOnClick(option.value);\n setIsPopoverOpen(false);\n }}\n onMouseDown={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n tabIndex={-1}\n className={classNames(\n focusedIndex === i ? 'focused' : '',\n 'ndl-timezone-picker-popover-item',\n )}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.stopPropagation();\n handleOnClick(option.value);\n }\n }}\n >\n {option.label}\n </li>\n ))}\n </>\n )}\n {cityOptions.length > 0 && (\n <>\n <li className=\"ndl-timezone-picker-section-header\">\n City-Based Timezones\n </li>\n {cityOptions.map((option, i) => {\n const adjustedIndex = i + utcOptions.length;\n return (\n <li\n id={`${listboxId}-option-${adjustedIndex}`}\n key={option.value}\n role=\"option\"\n aria-selected={value === option.value}\n value={option.value}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n handleOnClick(option.value);\n setIsPopoverOpen(false);\n }}\n onMouseDown={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n tabIndex={-1}\n className={classNames(\n focusedIndex === adjustedIndex ? 'focused' : '',\n 'ndl-timezone-picker-popover-item',\n )}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.stopPropagation();\n handleOnClick(option.value);\n }\n }}\n >\n {option.label}\n </li>\n );\n })}\n </>\n )}\n {utcOptions.length === 0 && cityOptions.length === 0 && (\n <li className=\"ndl-timezone-picker-popover-item ndl-timezone-picker-no-results\">\n No timezones found\n </li>\n )}\n </>\n ) : (\n <>\n {filteredOptions.length > 0 ? (\n filteredOptions.map((option, i) => (\n <li\n id={`${listboxId}-option-${i}`}\n key={option.value}\n role=\"option\"\n aria-selected={value === option.value}\n value={option.value}\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n handleOnClick(option.value);\n setIsPopoverOpen(false);\n }}\n onMouseDown={(e) => {\n e.stopPropagation();\n e.preventDefault();\n }}\n tabIndex={-1}\n className={classNames(\n focusedIndex === i ? 'focused' : '',\n 'ndl-timezone-picker-popover-item',\n )}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.stopPropagation();\n handleOnClick(option.value);\n }\n }}\n >\n {option.label}\n </li>\n ))\n ) : (\n <li className=\"ndl-timezone-picker-popover-item ndl-timezone-picker-no-results\">\n No timezones found\n </li>\n )}\n </>\n )}\n </ul>\n </div>\n </FloatingFocusManager>\n </ConditionalWrap>\n )}\n </>\n );\n};\n"]}
|
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
36
|
var t = {};
|
|
4
37
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -38,7 +71,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
38
71
|
*/
|
|
39
72
|
const react_1 = require("@floating-ui/react");
|
|
40
73
|
const classnames_1 = __importDefault(require("classnames"));
|
|
41
|
-
const react_2 = require("react");
|
|
74
|
+
const react_2 = __importStar(require("react"));
|
|
42
75
|
const conditional_wrap_1 = require("../conditional-wrap");
|
|
43
76
|
const dialog_context_1 = require("../dialog/dialog-context");
|
|
44
77
|
const theme_1 = require("../theme");
|
|
@@ -81,17 +114,25 @@ const TooltipTrigger = (_a) => {
|
|
|
81
114
|
'ndl-open': context.isOpen,
|
|
82
115
|
}, 'ndl-tooltip-trigger', className);
|
|
83
116
|
// `hasButtonWrapper=true` allows the user to pass any element as the anchor
|
|
84
|
-
if (hasButtonWrapper &&
|
|
117
|
+
if (hasButtonWrapper && react_2.default.isValidElement(children)) {
|
|
85
118
|
const props = Object.assign(Object.assign(Object.assign({ className: triggerClasses }, htmlAttributes), childrenProps), { ref: mergedRefs });
|
|
86
|
-
return
|
|
119
|
+
return react_2.default.cloneElement(children, context.getReferenceProps(props));
|
|
87
120
|
}
|
|
88
121
|
return ((0, jsx_runtime_1.jsx)("button", Object.assign({ type: "button", className: triggerClasses, style: style, ref: mergedRefs }, context.getReferenceProps(htmlAttributes), restProps, { children: children })));
|
|
89
122
|
};
|
|
90
123
|
const TooltipContent = (_a) => {
|
|
124
|
+
var _b;
|
|
91
125
|
var { children, style, htmlAttributes, className, ref } = _a, restProps = __rest(_a, ["children", "style", "htmlAttributes", "className", "ref"]);
|
|
92
126
|
const context = (0, use_tooltip_1.useTooltipContext)();
|
|
93
127
|
const mergedRef = (0, react_1.useMergeRefs)([context.refs.setFloating, ref]);
|
|
94
128
|
const { themeClassName } = (0, theme_1.useNeedleTheme)();
|
|
129
|
+
const hasHeaderChild = react_2.default.useMemo(() => {
|
|
130
|
+
if (context.type !== 'rich') {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
const childrenArray = react_2.default.Children.toArray(children);
|
|
134
|
+
return childrenArray.some((child) => react_2.default.isValidElement(child) && child.type === TooltipHeader);
|
|
135
|
+
}, [children, context.type]);
|
|
95
136
|
if (!context.isOpen) {
|
|
96
137
|
return null;
|
|
97
138
|
}
|
|
@@ -102,16 +143,26 @@ const TooltipContent = (_a) => {
|
|
|
102
143
|
if (context.type === 'simple') {
|
|
103
144
|
return ((0, jsx_runtime_1.jsx)(conditional_wrap_1.ConditionalWrap, { shouldWrap: context.isPortaled, wrap: (wrapChildren) => (0, jsx_runtime_1.jsx)(react_1.FloatingPortal, { children: wrapChildren }), children: (0, jsx_runtime_1.jsx)("div", Object.assign({ ref: mergedRef, className: classes, style: Object.assign(Object.assign({}, context.floatingStyles), style) }, restProps, context.getFloatingProps(htmlAttributes), { children: (0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: "body-medium", children: children }) })) }));
|
|
104
145
|
}
|
|
105
|
-
|
|
146
|
+
const ariaLabelledBy = (_b = htmlAttributes === null || htmlAttributes === void 0 ? void 0 : htmlAttributes['aria-labelledby']) !== null && _b !== void 0 ? _b : (hasHeaderChild ? context.headerId : undefined);
|
|
147
|
+
if ((htmlAttributes === null || htmlAttributes === void 0 ? void 0 : htmlAttributes['aria-label']) === undefined && !ariaLabelledBy) {
|
|
148
|
+
console.warn('The rich Tooltip is missing aria-label and Header. Please add one of them for accessibility.');
|
|
149
|
+
}
|
|
150
|
+
return ((0, jsx_runtime_1.jsx)(conditional_wrap_1.ConditionalWrap, { shouldWrap: context.isPortaled, wrap: (wrapChildren) => (0, jsx_runtime_1.jsx)(react_1.FloatingPortal, { children: wrapChildren }), children: (0, jsx_runtime_1.jsx)(react_1.FloatingFocusManager, { context: context.context, returnFocus: true, modal: false, initialFocus: 0, closeOnFocusOut: true, children: (0, jsx_runtime_1.jsx)("div", Object.assign({ ref: mergedRef, className: classes, style: Object.assign(Object.assign({}, context.floatingStyles), style) }, restProps, context.getFloatingProps(Object.assign(Object.assign({}, htmlAttributes), { 'aria-labelledby': ariaLabelledBy })), { children: children })) }) }));
|
|
106
151
|
};
|
|
107
152
|
const TooltipHeader = (_a) => {
|
|
108
153
|
var { children, passThroughProps, typographyVariant = 'subheading-medium', className, style, htmlAttributes, ref } = _a, restProps = __rest(_a, ["children", "passThroughProps", "typographyVariant", "className", "style", "htmlAttributes", "ref"]);
|
|
109
154
|
const context = (0, use_tooltip_1.useTooltipContext)();
|
|
110
155
|
const classes = (0, classnames_1.default)('ndl-tooltip-header', className);
|
|
156
|
+
(0, react_2.useEffect)(() => {
|
|
157
|
+
var _a;
|
|
158
|
+
if (Boolean(htmlAttributes === null || htmlAttributes === void 0 ? void 0 : htmlAttributes.id) === true) {
|
|
159
|
+
(_a = context.setHeaderId) === null || _a === void 0 ? void 0 : _a.call(context, htmlAttributes === null || htmlAttributes === void 0 ? void 0 : htmlAttributes.id);
|
|
160
|
+
}
|
|
161
|
+
}, [context, htmlAttributes === null || htmlAttributes === void 0 ? void 0 : htmlAttributes.id]);
|
|
111
162
|
if (!context.isOpen) {
|
|
112
163
|
return null;
|
|
113
164
|
}
|
|
114
|
-
return ((0, jsx_runtime_1.jsx)(typography_1.Typography, Object.assign({ ref: ref, variant: typographyVariant, className: classes, style: style, htmlAttributes: htmlAttributes }, passThroughProps, restProps, { children: children })));
|
|
165
|
+
return ((0, jsx_runtime_1.jsx)(typography_1.Typography, Object.assign({ ref: ref, variant: typographyVariant, className: classes, style: style, htmlAttributes: Object.assign(Object.assign({}, htmlAttributes), { id: context.headerId }) }, passThroughProps, restProps, { children: children })));
|
|
115
166
|
};
|
|
116
167
|
const TooltipBody = (_a) => {
|
|
117
168
|
var { children, className, style, htmlAttributes, passThroughProps, ref } = _a, restProps = __rest(_a, ["children", "className", "style", "htmlAttributes", "passThroughProps", "ref"]);
|
|
@@ -132,6 +183,7 @@ const Actions = (_a) => {
|
|
|
132
183
|
const classes = (0, classnames_1.default)('ndl-tooltip-actions', className);
|
|
133
184
|
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: classes, ref: mergedRefs, style: style }, restProps, htmlAttributes, { children: children })));
|
|
134
185
|
};
|
|
186
|
+
Actions.displayName = 'Tooltip.Actions';
|
|
135
187
|
const Tooltip = Object.assign(TooltipComponent, {
|
|
136
188
|
Actions: Actions,
|
|
137
189
|
Body: TooltipBody,
|