@neo4j-ndl/react 4.8.3 → 4.8.4

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.
Files changed (85) hide show
  1. package/lib/cjs/accordion/Accordion.js +1 -1
  2. package/lib/cjs/accordion/Accordion.js.map +1 -1
  3. package/lib/cjs/ai/prompt/Prompt.js +1 -1
  4. package/lib/cjs/ai/prompt/Prompt.js.map +1 -1
  5. package/lib/cjs/ai/suggestion/Suggestion.js +1 -1
  6. package/lib/cjs/ai/suggestion/Suggestion.js.map +1 -1
  7. package/lib/cjs/breadcrumbs/Breadcrumbs.js +1 -1
  8. package/lib/cjs/breadcrumbs/Breadcrumbs.js.map +1 -1
  9. package/lib/cjs/breadcrumbs/stories/breadcrumbs-header.story.js +1 -1
  10. package/lib/cjs/breadcrumbs/stories/breadcrumbs-header.story.js.map +1 -1
  11. package/lib/cjs/color-picker/ColorPicker.js +1 -1
  12. package/lib/cjs/color-picker/ColorPicker.js.map +1 -1
  13. package/lib/cjs/date-picker/DatePicker.js +2 -2
  14. package/lib/cjs/date-picker/DatePicker.js.map +1 -1
  15. package/lib/cjs/graph-label/GraphLabel.js +5 -1
  16. package/lib/cjs/graph-label/GraphLabel.js.map +1 -1
  17. package/lib/cjs/inline-edit/InlineEdit.js +1 -1
  18. package/lib/cjs/inline-edit/InlineEdit.js.map +1 -1
  19. package/lib/cjs/select-icon-button/SelectIconButton.js +1 -1
  20. package/lib/cjs/select-icon-button/SelectIconButton.js.map +1 -1
  21. package/lib/cjs/side-navigation/SideNavigation.js +1 -1
  22. package/lib/cjs/side-navigation/SideNavigation.js.map +1 -1
  23. package/lib/cjs/tabs/Tabs.js +1 -1
  24. package/lib/cjs/tabs/Tabs.js.map +1 -1
  25. package/lib/cjs/timezone-picker/stories/timezone-picker-dst-aware.story.js +2 -2
  26. package/lib/cjs/timezone-picker/stories/timezone-picker-dst-aware.story.js.map +1 -1
  27. package/lib/cjs/tooltip/Tooltip.js +1 -1
  28. package/lib/cjs/tooltip/Tooltip.js.map +1 -1
  29. package/lib/cjs/tree-view/TreeItemWrapper.js +1 -1
  30. package/lib/cjs/tree-view/TreeItemWrapper.js.map +1 -1
  31. package/lib/cjs/tree-view/TreeViewTextItem.js +2 -2
  32. package/lib/cjs/tree-view/TreeViewTextItem.js.map +1 -1
  33. package/lib/cjs/tree-view/stories/treeview-custom.story.js +1 -1
  34. package/lib/cjs/tree-view/stories/treeview-custom.story.js.map +1 -1
  35. package/lib/esm/accordion/Accordion.js +1 -1
  36. package/lib/esm/accordion/Accordion.js.map +1 -1
  37. package/lib/esm/ai/prompt/Prompt.js +1 -1
  38. package/lib/esm/ai/prompt/Prompt.js.map +1 -1
  39. package/lib/esm/ai/suggestion/Suggestion.js +1 -1
  40. package/lib/esm/ai/suggestion/Suggestion.js.map +1 -1
  41. package/lib/esm/breadcrumbs/Breadcrumbs.js +1 -1
  42. package/lib/esm/breadcrumbs/Breadcrumbs.js.map +1 -1
  43. package/lib/esm/breadcrumbs/stories/breadcrumbs-header.story.js +1 -1
  44. package/lib/esm/breadcrumbs/stories/breadcrumbs-header.story.js.map +1 -1
  45. package/lib/esm/color-picker/ColorPicker.js +1 -1
  46. package/lib/esm/color-picker/ColorPicker.js.map +1 -1
  47. package/lib/esm/date-picker/DatePicker.js +2 -2
  48. package/lib/esm/date-picker/DatePicker.js.map +1 -1
  49. package/lib/esm/graph-label/GraphLabel.js +5 -1
  50. package/lib/esm/graph-label/GraphLabel.js.map +1 -1
  51. package/lib/esm/inline-edit/InlineEdit.js +1 -1
  52. package/lib/esm/inline-edit/InlineEdit.js.map +1 -1
  53. package/lib/esm/select-icon-button/SelectIconButton.js +1 -1
  54. package/lib/esm/select-icon-button/SelectIconButton.js.map +1 -1
  55. package/lib/esm/side-navigation/SideNavigation.js +1 -1
  56. package/lib/esm/side-navigation/SideNavigation.js.map +1 -1
  57. package/lib/esm/tabs/Tabs.js +1 -1
  58. package/lib/esm/tabs/Tabs.js.map +1 -1
  59. package/lib/esm/timezone-picker/stories/timezone-picker-dst-aware.story.js +2 -2
  60. package/lib/esm/timezone-picker/stories/timezone-picker-dst-aware.story.js.map +1 -1
  61. package/lib/esm/tooltip/Tooltip.js +1 -1
  62. package/lib/esm/tooltip/Tooltip.js.map +1 -1
  63. package/lib/esm/tree-view/TreeItemWrapper.js +1 -1
  64. package/lib/esm/tree-view/TreeItemWrapper.js.map +1 -1
  65. package/lib/esm/tree-view/TreeViewTextItem.js +2 -2
  66. package/lib/esm/tree-view/TreeViewTextItem.js.map +1 -1
  67. package/lib/esm/tree-view/stories/treeview-custom.story.js +1 -1
  68. package/lib/esm/tree-view/stories/treeview-custom.story.js.map +1 -1
  69. package/lib/types/accordion/Accordion.d.ts.map +1 -1
  70. package/lib/types/ai/prompt/Prompt.d.ts.map +1 -1
  71. package/lib/types/ai/suggestion/Suggestion.d.ts.map +1 -1
  72. package/lib/types/breadcrumbs/Breadcrumbs.d.ts.map +1 -1
  73. package/lib/types/breadcrumbs/stories/breadcrumbs-header.story.d.ts.map +1 -1
  74. package/lib/types/date-picker/DatePicker.d.ts.map +1 -1
  75. package/lib/types/graph-label/GraphLabel.d.ts.map +1 -1
  76. package/lib/types/inline-edit/InlineEdit.d.ts.map +1 -1
  77. package/lib/types/select-icon-button/SelectIconButton.d.ts.map +1 -1
  78. package/lib/types/side-navigation/SideNavigation.d.ts.map +1 -1
  79. package/lib/types/tabs/Tabs.d.ts.map +1 -1
  80. package/lib/types/timezone-picker/stories/timezone-picker-dst-aware.story.d.ts.map +1 -1
  81. package/lib/types/tooltip/Tooltip.d.ts.map +1 -1
  82. package/lib/types/tree-view/TreeItemWrapper.d.ts.map +1 -1
  83. package/lib/types/tree-view/TreeViewTextItem.d.ts.map +1 -1
  84. package/lib/types/tree-view/stories/treeview-custom.story.d.ts.map +1 -1
  85. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../src/date-picker/DatePicker.tsx"],"names":[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EAAE,cAAc,GAC9B,EAEJ,eAAe,EACb,kCAAM,SAAS,EAAC,yBAAyB,aACvC,uBAAC,iBAAO,KAAG,EACX,uBAAC,wBAAU,kBACT,OAAO,QACP,KAAK,EACH,eAAe;4BACb,CAAC,CAAC,IAAI,wBAAU,CACZ,eAAe,CAAC,QAAQ,EAAE,EAC1B,eAAe,CAAC,UAAU,EAAE,CAC7B;4BACH,CAAC,CAAC,SAAS,EAEf,QAAQ,EAAE,gBAAgB,IACtB,eAAe,IACnB,gBAAgB,EAAC,UAAU,EAC3B,UAAU,EAAE,KAAK,IACjB,EACD,mBAAmB,IAAI,CACtB,uBAAC,gCAAc,kBACb,OAAO,QACP,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,oBAAoB,EAC9B,aAAa,EAAE,eAAe,IAAI,SAAS,IACvC,mBAAmB,IACvB,gBAAgB,EAAC,UAAU,EAC3B,UAAU,EAAE,KAAK,IACjB,CACH,IACI,EAET,QAAQ,EAAE,UAAU,EACpB,eAAe,EAAE,KAAK,EACtB,mBAAmB,EAAE,MAAM,KAAK,OAAO,EACvC,cAAc,EAAE,MAAM,KAAK,MAAM,EACjC,mBAAmB,EACjB,MAAM,KAAK,KAAK,IAAI,CAAC,CAAC,MAAA,oBAAoB,CAAC,aAAa,mCAAI,KAAK,CAAC,EAEpE,YAAY,EAAE,GAAG,EAAE,CAAC,oBAAoB,EACxC,kBAAkB,EAAE,YAAY,IAC5B,eAAe,IACnB,eAAe,EAAE,IAAA,oBAAU,EACzB,uBAAuB,EACvB,oBAAoB,CAAC,eAAe,CACrC,EACD,WAAW,kBACT,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,IAC5C,oBAAoB,CAAC,WAAW,KAErC,IACE,CACP,CAAC;AACJ,CAAC,CAAC;AAzUW,QAAA,UAAU,cAyUrB","sourcesContent":["// TODO: try to fix as some point\n/* eslint-disable @typescript-eslint/naming-convention */\n\n/**\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 classNames from 'classnames';\nimport { format } from 'date-fns';\nimport { useCallback, useRef, useState } from 'react';\nimport ReactDatePicker, {\n type ReactDatePickerCustomHeaderProps,\n} from 'react-datepicker';\n\nimport type { CommonProps, HtmlAttributes } from '../_common/types';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { Divider } from '../divider';\nimport {\n ArrowLeftIconOutline,\n ArrowRightIconOutline,\n CalendarDaysIconOutline,\n ChevronDownIconOutline,\n} from '../icons';\nimport { TextInput } from '../text-input';\nimport { NeedleTime, TimePicker, type TimePickerProps } from '../time-picker';\nimport { TimeZonePicker } from '../timezone-picker';\nimport { Typography } from '../typography';\nimport { daysInMonth, getYearsPeriodString } from './utils';\n\ntype DatePickerTextInputWrapperProps = React.ComponentProps<'input'> & {\n textInputProps?: React.ComponentProps<typeof TextInput>;\n isDisabled?: boolean;\n value?: string;\n ariaLabel?: string;\n};\n\n// This wrapper is needed due to react-datepicker injecting html attributes\n// into the custom input component on root level, since we use htmlAttributes\n// we need to help spread them there instead of the root level\nconst DatePickerTextInputWrapper = ({\n textInputProps,\n isDisabled,\n value,\n placeholder,\n ...restProps\n}: DatePickerTextInputWrapperProps) => {\n // deconstruct textInputProps to avoid bugs with react-datepicker injecting props\n const {\n placeholder: textInputPlaceholder,\n htmlAttributes: textInputHtmlAttributes,\n ref,\n ...restTextInputProps\n } = textInputProps ?? {};\n\n return (\n <TextInput\n ref={ref}\n trailingElement={<CalendarDaysIconOutline />}\n value={value}\n placeholder={placeholder ?? textInputPlaceholder}\n isDisabled={isDisabled}\n // react-datepicker injects html attributes into the custom input\n htmlAttributes={{\n ...textInputHtmlAttributes,\n ...restProps,\n }}\n {...restTextInputProps}\n />\n );\n};\n\n/**\n *\n *\n * Types\n *\n *\n */\n\ntype PickerType = 'day' | 'month' | 'year';\n\n// Define a more flexible type for onChange\ntype DatePickerChangeHandler = (\n date: Date | null | [Date | null, Date | null] | Date[],\n event?: React.SyntheticEvent | undefined,\n) => void;\n\ninterface DatePickerProps {\n /** Props for the embedded `TextInput` component. */\n textInputProps?: React.ComponentProps<typeof TextInput>;\n /** Whether the date picker is disabled. */\n isDisabled?: boolean;\n /** Props for the embedded `TimePicker` component. */\n timePickerProps?: TimePickerProps;\n /** Props for the embedded `TimeZonePicker` component. */\n timeZonePickerProps?: React.ComponentProps<typeof TimeZonePicker>;\n /** Props forwarded to underlying `react-datepicker` component. */\n reactDatePickerProps: React.ComponentProps<typeof ReactDatePicker>;\n /**\n * WARNING: these attributes do not apply to the underlying input element currently. This will be fixed in a future version.\n */\n htmlAttributes?: HtmlAttributes<'div'>;\n}\n\nexport const DatePicker = ({\n reactDatePickerProps,\n textInputProps,\n timePickerProps,\n timeZonePickerProps,\n isDisabled,\n ref,\n className,\n style,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', DatePickerProps>) => {\n const classes = classNames(`ndl-datepicker`, className, {});\n const datetimeRef = useRef<ReactDatePicker>(null);\n const [picker, setPicker] = useState<PickerType>('day');\n const [preSelectedDate, setPreSelectedDate] = useState<Date | null>(\n (reactDatePickerProps.selected as Date | null) ||\n (reactDatePickerProps.startDate as Date | null),\n );\n const [selectedTimeZone, setSelectedTimeZone] = useState<string | undefined>(\n timeZonePickerProps?.value,\n );\n\n const isInsideDialog = useIsInsideDialog();\n\n const headerAction = useCallback(\n (action: PickerType) => {\n setPicker(picker === action ? 'day' : action);\n },\n [picker],\n );\n\n const CustomHeader = useCallback(\n (props: ReactDatePickerCustomHeaderProps) => {\n const {\n decreaseMonth,\n increaseMonth,\n increaseYear,\n decreaseYear,\n nextMonthButtonDisabled,\n nextYearButtonDisabled,\n prevMonthButtonDisabled,\n prevYearButtonDisabled,\n } = props;\n\n const prevCallback = picker === 'year' ? decreaseYear : decreaseMonth;\n const nextCallback = picker === 'year' ? increaseYear : increaseMonth;\n const prevDisabled =\n picker === 'year' ? prevYearButtonDisabled : prevMonthButtonDisabled;\n const nextDisabled =\n picker === 'year' ? nextYearButtonDisabled : nextMonthButtonDisabled;\n\n return (\n <div className=\"ndl-datepicker-header\">\n <div className=\"ndl-datepicker-selects\">\n {picker !== 'year' && (\n <button\n aria-label={`${picker === 'month' ? 'Close' : 'Open'} month picker`}\n aria-pressed={picker === 'month'}\n onClick={() => headerAction('month')}\n >\n <div className=\"n-flex n-items-center n-gap-token-4\">\n <Typography variant=\"subheading-small\">\n {format(props.date, 'MMM')}\n </Typography>\n <ChevronDownIconOutline\n className={classNames('ndl-datepicker-chevron', {\n 'n-rotate-180': picker === 'month',\n })}\n aria-label=\"Chevron icon\"\n />\n </div>\n </button>\n )}\n {picker !== 'month' && (\n <button\n aria-label={`${picker === 'year' ? 'Close' : 'Open'} year picker`}\n onClick={() => headerAction('year')}\n >\n <div className=\"n-flex n-items-center n-gap-token-4\">\n <Typography variant=\"subheading-small\">\n {picker === 'year'\n ? getYearsPeriodString(\n props.date,\n reactDatePickerProps?.yearItemNumber,\n )\n : format(props.date, 'yyyy')}\n </Typography>\n <ChevronDownIconOutline\n className={classNames('ndl-datepicker-chevron', {\n 'n-rotate-180': picker === 'year',\n })}\n aria-label=\"Chevron icon\"\n />\n </div>\n </button>\n )}\n </div>\n {picker !== 'month' && (\n <div className=\"n-flex n-justify-center n-gap-token-16\">\n <CleanIconButton\n description={\n picker === 'year' ? 'Previous period' : 'Previous month'\n }\n onClick={prevCallback}\n isDisabled={prevDisabled}\n className=\"n-text-neutral-text-weak\"\n size=\"small\"\n >\n <ArrowLeftIconOutline />\n </CleanIconButton>\n <CleanIconButton\n description={picker === 'year' ? 'Next period' : 'Next month'}\n onClick={nextCallback}\n isDisabled={nextDisabled}\n className=\"n-text-neutral-text-weak\"\n size=\"small\"\n >\n <ArrowRightIconOutline />\n </CleanIconButton>\n </div>\n )}\n </div>\n );\n },\n [picker, headerAction, reactDatePickerProps?.yearItemNumber],\n );\n\n const handleTimeChange = (newTime: NeedleTime) => {\n if (\n reactDatePickerProps.selectsRange ||\n reactDatePickerProps.selectsMultiple\n ) {\n // this is consistent with the behavior of react-datepicker\n return;\n }\n\n if (!preSelectedDate) {\n return;\n }\n\n const newDate = new Date(preSelectedDate);\n newDate.setHours(newTime.hour, newTime.minute, 0, 0);\n setPreSelectedDate(newDate);\n\n if (reactDatePickerProps.onChange) {\n // For single date selection\n reactDatePickerProps.onChange(newDate, undefined);\n }\n };\n\n const handleTimeZoneChange = (timezone: string) => {\n setSelectedTimeZone(timezone);\n if (timeZonePickerProps?.onChange) {\n timeZonePickerProps.onChange(timezone);\n }\n };\n\n /**\n * Intercept onChange so we can work with\n * Month and Year pickers\n */\n const interceptedChange: DatePickerChangeHandler = useCallback(\n (\n date: Date | null | [Date | null, Date | null] | Date[],\n event?: React.SyntheticEvent,\n ) => {\n if (picker !== 'day') {\n // setTimeout to prevent picker change before the handleMonthChange logic\n setTimeout(() => {\n setPicker('day');\n });\n } else if (picker === 'day') {\n if (date instanceof Date) {\n setPreSelectedDate(date);\n } else if (\n Array.isArray(date) &&\n date.length > 0 &&\n date[0] instanceof Date\n ) {\n setPreSelectedDate(date[0]);\n } else if (date === null) {\n setPreSelectedDate(null);\n }\n\n if (reactDatePickerProps.onChange && date !== null) {\n (reactDatePickerProps.onChange as DatePickerChangeHandler)(\n date,\n event,\n );\n }\n }\n },\n [picker, reactDatePickerProps],\n );\n\n /**\n * Intercept onCalendarClose so we can\n * switch to \"day\" picker if we close on \"month\" or \"year\"\n * view\n */\n const interceptedOnCalendarClose = useCallback(() => {\n if (picker !== 'day') {\n setPicker('day');\n }\n reactDatePickerProps?.onCalendarClose?.();\n }, [picker, reactDatePickerProps]);\n\n const handleMonthChange = useCallback(\n (date: Date) => {\n if (picker === 'month') {\n const selectedDay = preSelectedDate?.getDate() ?? 1;\n const daysInNewMonth = daysInMonth(date.getMonth(), date.getFullYear());\n date.setDate(Math.min(selectedDay, daysInNewMonth));\n reactDatePickerProps?.onMonthChange?.(date);\n } else if (picker === 'year') {\n const selectedDay = preSelectedDate?.getDate() ?? 1;\n const selectedMonth = preSelectedDate?.getMonth() ?? 0;\n const daysInNewMonth = daysInMonth(selectedMonth, date.getFullYear());\n date.setMonth(selectedMonth, Math.min(selectedDay, daysInNewMonth));\n reactDatePickerProps?.onMonthChange?.(date);\n }\n setPreSelectedDate(date);\n },\n [picker, preSelectedDate, reactDatePickerProps],\n );\n\n /**\n * Intercept onChangeRaw to handle clearing the input\n * When the user clears the text input, set the date to null\n */\n const interceptedOnChangeRaw = useCallback(\n (\n event?:\n | React.KeyboardEvent<HTMLElement>\n | React.MouseEvent<HTMLElement, MouseEvent>,\n ) => {\n const target = event?.target as HTMLInputElement | undefined;\n if (target?.value === '') {\n setPreSelectedDate(null);\n if (reactDatePickerProps.onChange) {\n (reactDatePickerProps.onChange as DatePickerChangeHandler)(\n null,\n event,\n );\n }\n }\n reactDatePickerProps?.onChangeRaw?.(event);\n },\n [reactDatePickerProps],\n );\n\n const datePickerProps = {\n ...reactDatePickerProps,\n onCalendarClose: interceptedOnCalendarClose,\n onChange: interceptedChange,\n onChangeRaw: interceptedOnChangeRaw,\n onMonthChange: handleMonthChange,\n };\n\n return (\n <div\n className={classes}\n ref={ref}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {/** TODO v5: Remove the div wrapper, type the component as an input, and apply all root props to the TextInput */}\n <ReactDatePicker\n ref={datetimeRef}\n customInput={\n <DatePickerTextInputWrapper\n isDisabled={isDisabled}\n textInputProps={textInputProps}\n />\n }\n customTimeInput={\n <span className=\"ndl-time-picker-wrapper\">\n <Divider />\n <TimePicker\n isFluid\n value={\n preSelectedDate\n ? new NeedleTime(\n preSelectedDate.getHours(),\n preSelectedDate.getMinutes(),\n )\n : undefined\n }\n onChange={handleTimeChange}\n {...timePickerProps}\n floatingStrategy=\"absolute\"\n isPortaled={false}\n />\n {timeZonePickerProps && (\n <TimeZonePicker\n isFluid\n value={selectedTimeZone}\n onChange={handleTimeZoneChange}\n referenceDate={preSelectedDate || undefined}\n {...timeZonePickerProps}\n floatingStrategy=\"absolute\"\n isPortaled={false}\n />\n )}\n </span>\n }\n disabled={isDisabled}\n showPopperArrow={false}\n showMonthYearPicker={picker === 'month'}\n showYearPicker={picker === 'year'}\n shouldCloseOnSelect={\n picker === 'day' && !(reactDatePickerProps.showTimeInput ?? false)\n }\n dayClassName={() => 'ndl-datepicker-day'}\n renderCustomHeader={CustomHeader}\n {...datePickerProps}\n popperClassName={classNames(\n 'ndl-datepicker-popper',\n reactDatePickerProps.popperClassName,\n )}\n popperProps={{\n strategy: isInsideDialog ? 'fixed' : 'absolute',\n ...reactDatePickerProps.popperProps,\n }}\n />\n </div>\n );\n};\n"]}
1
+ {"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../src/date-picker/DatePicker.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iCAAiC;AACjC,yDAAyD;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAAoC;AACpC,uCAAkC;AAClC,iCAAsD;AACtD,wEAE0B;AAG1B,4DAAuD;AACvD,6DAA6D;AAC7D,wCAAqC;AACrC,oCAKkB;AAClB,8CAA0C;AAC1C,gDAA8E;AAC9E,wDAAoD;AACpD,8CAA2C;AAC3C,mCAA4D;AAS5D,2EAA2E;AAC3E,6EAA6E;AAC7E,8DAA8D;AAC9D,MAAM,0BAA0B,GAAG,CAAC,EAMF,EAAE,EAAE;QANF,EAClC,cAAc,EACd,UAAU,EACV,KAAK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mBAAmB,IAAI,CACtB,uBAAC,gCAAc,kBACb,OAAO,QACP,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,oBAAoB,EAC9B,aAAa,EAAE,eAAe,IAAI,SAAS,IACvC,mBAAmB,IACvB,gBAAgB,EAAC,UAAU,EAC3B,UAAU,EAAE,KAAK,IACjB,CACH,IACI,EAET,QAAQ,EAAE,UAAU,EACpB,eAAe,EAAE,KAAK,EACtB,mBAAmB,EAAE,MAAM,KAAK,OAAO,EACvC,cAAc,EAAE,MAAM,KAAK,MAAM,EACjC,mBAAmB,EACjB,MAAM,KAAK,KAAK,IAAI,CAAC,CAAC,MAAA,oBAAoB,CAAC,aAAa,mCAAI,KAAK,CAAC,EAEpE,YAAY,EAAE,GAAG,EAAE,CAAC,oBAAoB,EACxC,kBAAkB,EAAE,YAAY,IAC5B,eAAe,IACnB,eAAe,EAAE,IAAA,oBAAU,EACzB,uBAAuB,EACvB,oBAAoB,CAAC,eAAe,CACrC,EACD,WAAW,kBACT,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,IAC5C,oBAAoB,CAAC,WAAW,KAErC,IACE,CACP,CAAC;AACJ,CAAC,CAAC;AA3UW,QAAA,UAAU,cA2UrB","sourcesContent":["// TODO: try to fix as some point\n/* eslint-disable @typescript-eslint/naming-convention */\n\n/**\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 classNames from 'classnames';\nimport { format } from 'date-fns';\nimport { useCallback, useRef, useState } from 'react';\nimport ReactDatePicker, {\n type ReactDatePickerCustomHeaderProps,\n} from 'react-datepicker';\n\nimport type { CommonProps, HtmlAttributes } from '../_common/types';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { Divider } from '../divider';\nimport {\n ArrowLeftIconOutline,\n ArrowRightIconOutline,\n CalendarDaysIconOutline,\n ChevronDownIconOutline,\n} from '../icons';\nimport { TextInput } from '../text-input';\nimport { NeedleTime, TimePicker, type TimePickerProps } from '../time-picker';\nimport { TimeZonePicker } from '../timezone-picker';\nimport { Typography } from '../typography';\nimport { daysInMonth, getYearsPeriodString } from './utils';\n\ntype DatePickerTextInputWrapperProps = React.ComponentProps<'input'> & {\n textInputProps?: React.ComponentProps<typeof TextInput>;\n isDisabled?: boolean;\n value?: string;\n ariaLabel?: string;\n};\n\n// This wrapper is needed due to react-datepicker injecting html attributes\n// into the custom input component on root level, since we use htmlAttributes\n// we need to help spread them there instead of the root level\nconst DatePickerTextInputWrapper = ({\n textInputProps,\n isDisabled,\n value,\n placeholder,\n ...restProps\n}: DatePickerTextInputWrapperProps) => {\n // deconstruct textInputProps to avoid bugs with react-datepicker injecting props\n const {\n placeholder: textInputPlaceholder,\n htmlAttributes: textInputHtmlAttributes,\n ref,\n ...restTextInputProps\n } = textInputProps ?? {};\n\n return (\n <TextInput\n ref={ref}\n trailingElement={<CalendarDaysIconOutline />}\n value={value}\n placeholder={placeholder ?? textInputPlaceholder}\n isDisabled={isDisabled}\n // react-datepicker injects html attributes into the custom input\n htmlAttributes={{\n ...textInputHtmlAttributes,\n ...restProps,\n }}\n {...restTextInputProps}\n />\n );\n};\n\n/**\n *\n *\n * Types\n *\n *\n */\n\ntype PickerType = 'day' | 'month' | 'year';\n\n// Define a more flexible type for onChange\ntype DatePickerChangeHandler = (\n date: Date | null | [Date | null, Date | null] | Date[],\n event?: React.SyntheticEvent | undefined,\n) => void;\n\ninterface DatePickerProps {\n /** Props for the embedded `TextInput` component. */\n textInputProps?: React.ComponentProps<typeof TextInput>;\n /** Whether the date picker is disabled. */\n isDisabled?: boolean;\n /** Props for the embedded `TimePicker` component. */\n timePickerProps?: TimePickerProps;\n /** Props for the embedded `TimeZonePicker` component. */\n timeZonePickerProps?: React.ComponentProps<typeof TimeZonePicker>;\n /** Props forwarded to underlying `react-datepicker` component. */\n reactDatePickerProps: React.ComponentProps<typeof ReactDatePicker>;\n /**\n * WARNING: these attributes do not apply to the underlying input element currently. This will be fixed in a future version.\n */\n htmlAttributes?: HtmlAttributes<'div'>;\n}\n\nexport const DatePicker = ({\n reactDatePickerProps,\n textInputProps,\n timePickerProps,\n timeZonePickerProps,\n isDisabled,\n ref,\n className,\n style,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', DatePickerProps>) => {\n const classes = classNames(`ndl-datepicker`, className, {});\n const datetimeRef = useRef<ReactDatePicker>(null);\n const [picker, setPicker] = useState<PickerType>('day');\n const [preSelectedDate, setPreSelectedDate] = useState<Date | null>(\n (reactDatePickerProps.selected as Date | null) ||\n (reactDatePickerProps.startDate as Date | null),\n );\n const [selectedTimeZone, setSelectedTimeZone] = useState<string | undefined>(\n timeZonePickerProps?.value,\n );\n\n const isInsideDialog = useIsInsideDialog();\n\n const headerAction = useCallback(\n (action: PickerType) => {\n setPicker(picker === action ? 'day' : action);\n },\n [picker],\n );\n\n const CustomHeader = useCallback(\n (props: ReactDatePickerCustomHeaderProps) => {\n const {\n decreaseMonth,\n increaseMonth,\n increaseYear,\n decreaseYear,\n nextMonthButtonDisabled,\n nextYearButtonDisabled,\n prevMonthButtonDisabled,\n prevYearButtonDisabled,\n } = props;\n\n const prevCallback = picker === 'year' ? decreaseYear : decreaseMonth;\n const nextCallback = picker === 'year' ? increaseYear : increaseMonth;\n const prevDisabled =\n picker === 'year' ? prevYearButtonDisabled : prevMonthButtonDisabled;\n const nextDisabled =\n picker === 'year' ? nextYearButtonDisabled : nextMonthButtonDisabled;\n\n return (\n <div className=\"ndl-datepicker-header\">\n <div className=\"ndl-datepicker-selects\">\n {picker !== 'year' && (\n <button\n type=\"button\"\n aria-label={`${picker === 'month' ? 'Close' : 'Open'} month picker`}\n aria-pressed={picker === 'month'}\n onClick={() => headerAction('month')}\n >\n <div className=\"n-flex n-items-center n-gap-token-4\">\n <Typography variant=\"subheading-small\">\n {format(props.date, 'MMM')}\n </Typography>\n <ChevronDownIconOutline\n className={classNames('ndl-datepicker-chevron', {\n 'n-rotate-180': picker === 'month',\n })}\n aria-label=\"Chevron icon\"\n />\n </div>\n </button>\n )}\n {picker !== 'month' && (\n <button\n type=\"button\"\n aria-label={`${picker === 'year' ? 'Close' : 'Open'} year picker`}\n onClick={() => headerAction('year')}\n >\n <div className=\"n-flex n-items-center n-gap-token-4\">\n <Typography variant=\"subheading-small\">\n {picker === 'year'\n ? getYearsPeriodString(\n props.date,\n reactDatePickerProps?.yearItemNumber,\n )\n : format(props.date, 'yyyy')}\n </Typography>\n <ChevronDownIconOutline\n className={classNames('ndl-datepicker-chevron', {\n 'n-rotate-180': picker === 'year',\n })}\n aria-label=\"Chevron icon\"\n />\n </div>\n </button>\n )}\n </div>\n {picker !== 'month' && (\n <div className=\"n-flex n-justify-center n-gap-token-16\">\n <CleanIconButton\n description={\n picker === 'year' ? 'Previous period' : 'Previous month'\n }\n onClick={prevCallback}\n isDisabled={prevDisabled}\n className=\"n-text-neutral-text-weak\"\n size=\"small\"\n >\n <ArrowLeftIconOutline />\n </CleanIconButton>\n <CleanIconButton\n description={picker === 'year' ? 'Next period' : 'Next month'}\n onClick={nextCallback}\n isDisabled={nextDisabled}\n className=\"n-text-neutral-text-weak\"\n size=\"small\"\n >\n <ArrowRightIconOutline />\n </CleanIconButton>\n </div>\n )}\n </div>\n );\n },\n [picker, headerAction, reactDatePickerProps?.yearItemNumber],\n );\n\n const handleTimeChange = (newTime: NeedleTime) => {\n if (\n reactDatePickerProps.selectsRange ||\n reactDatePickerProps.selectsMultiple\n ) {\n // this is consistent with the behavior of react-datepicker\n return;\n }\n\n if (!preSelectedDate) {\n return;\n }\n\n const newDate = new Date(preSelectedDate);\n newDate.setHours(newTime.hour, newTime.minute, 0, 0);\n setPreSelectedDate(newDate);\n\n if (reactDatePickerProps.onChange) {\n // For single date selection\n reactDatePickerProps.onChange(newDate, undefined);\n }\n };\n\n const handleTimeZoneChange = (timezone: string) => {\n setSelectedTimeZone(timezone);\n if (timeZonePickerProps?.onChange) {\n timeZonePickerProps.onChange(timezone);\n }\n };\n\n /**\n * Intercept onChange so we can work with\n * Month and Year pickers\n */\n const interceptedChange: DatePickerChangeHandler = useCallback(\n (\n date: Date | null | [Date | null, Date | null] | Date[],\n event?: React.SyntheticEvent,\n ) => {\n if (picker !== 'day') {\n // setTimeout to prevent picker change before the handleMonthChange logic\n setTimeout(() => {\n setPicker('day');\n });\n } else if (picker === 'day') {\n if (date instanceof Date) {\n setPreSelectedDate(date);\n } else if (\n Array.isArray(date) &&\n date.length > 0 &&\n date[0] instanceof Date\n ) {\n setPreSelectedDate(date[0]);\n } else if (date === null) {\n setPreSelectedDate(null);\n }\n\n if (reactDatePickerProps.onChange && date !== null) {\n (reactDatePickerProps.onChange as DatePickerChangeHandler)(\n date,\n event,\n );\n }\n }\n },\n [picker, reactDatePickerProps],\n );\n\n /**\n * Intercept onCalendarClose so we can\n * switch to \"day\" picker if we close on \"month\" or \"year\"\n * view\n */\n const interceptedOnCalendarClose = useCallback(() => {\n if (picker !== 'day') {\n setPicker('day');\n }\n reactDatePickerProps?.onCalendarClose?.();\n }, [picker, reactDatePickerProps]);\n\n const handleMonthChange = useCallback(\n (date: Date) => {\n if (picker === 'month') {\n const selectedDay = preSelectedDate?.getDate() ?? 1;\n const daysInNewMonth = daysInMonth(date.getMonth(), date.getFullYear());\n date.setDate(Math.min(selectedDay, daysInNewMonth));\n reactDatePickerProps?.onMonthChange?.(date);\n } else if (picker === 'year') {\n const selectedDay = preSelectedDate?.getDate() ?? 1;\n const selectedMonth = preSelectedDate?.getMonth() ?? 0;\n const daysInNewMonth = daysInMonth(selectedMonth, date.getFullYear());\n date.setMonth(selectedMonth, Math.min(selectedDay, daysInNewMonth));\n reactDatePickerProps?.onMonthChange?.(date);\n }\n setPreSelectedDate(date);\n },\n [picker, preSelectedDate, reactDatePickerProps],\n );\n\n /**\n * Intercept onChangeRaw to handle clearing the input\n * When the user clears the text input, set the date to null\n */\n const interceptedOnChangeRaw = useCallback(\n (\n event?:\n | React.KeyboardEvent<HTMLElement>\n | React.MouseEvent<HTMLElement, MouseEvent>,\n ) => {\n const target = event?.target as HTMLInputElement | undefined;\n if (target?.value === '') {\n setPreSelectedDate(null);\n if (reactDatePickerProps.onChange) {\n (reactDatePickerProps.onChange as DatePickerChangeHandler)(\n null,\n event,\n );\n }\n }\n reactDatePickerProps?.onChangeRaw?.(event);\n },\n [reactDatePickerProps],\n );\n\n const datePickerProps = {\n ...reactDatePickerProps,\n onCalendarClose: interceptedOnCalendarClose,\n onChange: interceptedChange,\n onChangeRaw: interceptedOnChangeRaw,\n onMonthChange: handleMonthChange,\n };\n\n return (\n <div\n className={classes}\n ref={ref}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {/** TODO v5: Remove the div wrapper, type the component as an input, and apply all root props to the TextInput */}\n <ReactDatePicker\n ref={datetimeRef}\n customInput={\n <DatePickerTextInputWrapper\n isDisabled={isDisabled}\n textInputProps={textInputProps}\n />\n }\n customTimeInput={\n <span className=\"ndl-time-picker-wrapper\">\n <Divider />\n <TimePicker\n isFluid\n value={\n preSelectedDate\n ? new NeedleTime(\n preSelectedDate.getHours(),\n preSelectedDate.getMinutes(),\n )\n : undefined\n }\n onChange={handleTimeChange}\n {...timePickerProps}\n floatingStrategy=\"absolute\"\n isPortaled={false}\n />\n {timeZonePickerProps && (\n <TimeZonePicker\n isFluid\n value={selectedTimeZone}\n onChange={handleTimeZoneChange}\n referenceDate={preSelectedDate || undefined}\n {...timeZonePickerProps}\n floatingStrategy=\"absolute\"\n isPortaled={false}\n />\n )}\n </span>\n }\n disabled={isDisabled}\n showPopperArrow={false}\n showMonthYearPicker={picker === 'month'}\n showYearPicker={picker === 'year'}\n shouldCloseOnSelect={\n picker === 'day' && !(reactDatePickerProps.showTimeInput ?? false)\n }\n dayClassName={() => 'ndl-datepicker-day'}\n renderCustomHeader={CustomHeader}\n {...datePickerProps}\n popperClassName={classNames(\n 'ndl-datepicker-popper',\n reactDatePickerProps.popperClassName,\n )}\n popperProps={{\n strategy: isInsideDialog ? 'fixed' : 'absolute',\n ...reactDatePickerProps.popperProps,\n }}\n />\n </div>\n );\n};\n"]}
@@ -136,6 +136,7 @@ const GraphLabel = (_a) => {
136
136
  onClick: handleClick,
137
137
  onMouseEnter: handleMouseEnter,
138
138
  onMouseLeave: handleMouseLeave,
139
+ type: 'button',
139
140
  }), htmlAttributes, { children: (0, jsx_runtime_1.jsx)("div", { className: "ndl-node-label-content", children: children }) })));
140
141
  }
141
142
  else if (type === 'relationship' ||
@@ -148,13 +149,16 @@ const GraphLabel = (_a) => {
148
149
  onClick: handleClick,
149
150
  onMouseEnter: handleMouseEnter,
150
151
  onMouseLeave: handleMouseLeave,
152
+ type: 'button',
151
153
  }), { ref: ref }, restProps, htmlAttributes, { children: [type === 'relationshipLeft' || type === 'relationship' ? ((0, jsx_runtime_1.jsx)(HexagonEnd, { direction: "left", color: backgroundColor, height: height })) : ((0, jsx_runtime_1.jsx)(SquareEnd, { direction: "left", color: backgroundColor, height: height })), (0, jsx_runtime_1.jsxs)("div", { className: "ndl-relationship-label-container", style: {
152
154
  backgroundColor: backgroundColor,
153
155
  }, children: [(0, jsx_runtime_1.jsx)("div", { className: "ndl-relationship-label-content", children: children }), (0, jsx_runtime_1.jsx)(HorizontalLines, { height: height })] }), type === 'relationshipRight' || type === 'relationship' ? ((0, jsx_runtime_1.jsx)(HexagonEnd, { direction: "right", color: backgroundColor, height: height })) : ((0, jsx_runtime_1.jsx)(SquareEnd, { direction: "right", color: backgroundColor, height: height }))] })));
154
156
  }
155
157
  else {
156
158
  const classes = (0, classnames_1.default)('ndl-property-key-label', commonClasses);
157
- return ((0, jsx_runtime_1.jsx)(Component, Object.assign({ style: Object.assign({ backgroundColor: backgroundColor, color: isDisabled ? disabledTextColor : textColor, maxWidth: isFluid ? '100%' : MAX_WIDTH }, style), className: classes, onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, ref: ref }, htmlAttributes, { children: (0, jsx_runtime_1.jsx)("div", { className: "ndl-property-key-label-content", children: children }) })));
159
+ return ((0, jsx_runtime_1.jsx)(Component, Object.assign({}, (isButton && {
160
+ type: 'button',
161
+ }), { style: Object.assign({ backgroundColor: backgroundColor, color: isDisabled ? disabledTextColor : textColor, maxWidth: isFluid ? '100%' : MAX_WIDTH }, style), className: classes, onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, ref: ref }, htmlAttributes, { children: (0, jsx_runtime_1.jsx)("div", { className: "ndl-property-key-label-content", children: children }) })));
158
162
  }
159
163
  };
160
164
  exports.GraphLabel = GraphLabel;
@@ -1 +1 @@
1
- {"version":3,"file":"GraphLabel.js","sourceRoot":"","sources":["../../../src/graph-label/GraphLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,0CAAyC;AACzC,4DAAoC;AAEpC,iCAA0C;AAM1C,mCAIiB;AAgDjB;;;;;;GAMG;AAEH,MAAM,UAAU,GAAG,CAAC,EAClB,SAAS,GAAG,MAAM,EAClB,KAAK,EACL,cAAc,EACd,MAAM,GAAG,EAAE,GACK,EAAE,EAAE;IACpB,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,iBAAiB,EAAE;QAC5C,UAAU,EAAE,SAAS,KAAK,MAAM;QAChC,WAAW,EAAE,SAAS,KAAK,OAAO;KACnC,CAAC,CAAC;IAEH,OAAO,CACL,+CAAK,SAAS,EAAE,OAAO,IAAM,cAAc,eACzC,+C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right (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 { tokens } from '@neo4j-ndl/base';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { useMemo, useState } from 'react';\n\nimport {\n type HtmlAttributes,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport {\n getDisabledTextColor,\n getHoverColor,\n getTextColorFromBackground,\n} from './color';\n\n/**\n *\n *\n * Types\n *\n *\n */\n\ntype GraphLabelProps = {\n /** The type of label */\n type:\n | 'node'\n | 'relationship'\n | 'propertyKey'\n | 'relationshipLeft'\n | 'relationshipRight';\n /** Callback function that is called when the label is clicked */\n onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /** Additional styles to apply to the label */\n style?: React.CSSProperties;\n /** Content displayed inside the label */\n children?: React.ReactNode;\n /** The background color of the label */\n color?: string;\n /** Whether the label is disabled */\n isDisabled?: boolean;\n /** Additional class names */\n className?: string;\n /** Whether the label is selected */\n isSelected?: boolean;\n /** Whether the label should expand to full available width */\n isFluid?: boolean;\n /** The size of the label */\n size?: 'small' | 'large';\n};\n\ntype HexagonEndProps = {\n /** The direction of the hexagon end */\n direction: 'left' | 'right';\n /** The color of the hexagon end */\n color?: string;\n /** The height of the hexagon end in pixels */\n height?: number;\n /** HTML attributes */\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n/**\n *\n *\n * Helpers\n *\n *\n */\n\nconst HexagonEnd = ({\n direction = 'left',\n color,\n htmlAttributes,\n height = 24,\n}: HexagonEndProps) => {\n const classes = classNames('ndl-hexagon-end', {\n 'ndl-left': direction === 'left',\n 'ndl-right': direction === 'right',\n });\n\n return (\n <div className={classes} {...htmlAttributes}>\n <svg\n aria-hidden={true}\n className=\"ndl-hexagon-end-inner\"\n fill=\"none\"\n height={height}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 9 24\"\n width=\"9\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n {/* triangle */}\n <path\n style={{ fill: color }}\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M5.73024 1.03676C6.08165 0.397331 6.75338 0 7.48301 0H9V24H7.483C6.75338 24 6.08165 23.6027 5.73024 22.9632L0.315027 13.1094C-0.105009 12.4376 -0.105009 11.5624 0.315026 10.8906L5.73024 1.03676Z\"\n />\n </svg>\n <svg\n aria-hidden={true}\n className=\"ndl-hexagon-end-active\"\n fill=\"none\"\n height={height + 6}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 13 30\"\n width=\"13\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10.075 2C9.12474 2 8.24318 2.54521 7.74867 3.43873L2.21419 13.4387C1.68353 14.3976 1.68353 15.6024 2.21419 16.5613L7.74867 26.5613C8.24318 27.4548 9.12474 28 10.075 28H13V30H10.075C8.49126 30 7.022 29.0913 6.1978 27.6021L0.663324 17.6021C-0.221109 16.0041 -0.221108 13.9959 0.663325 12.3979L6.1978 2.39789C7.022 0.90869 8.49126 0 10.075 0H13V2H10.075Z\"\n />\n </svg>\n </div>\n );\n};\n\ntype SquareEndProps = {\n /** The direction of the square end (where it's rounded and has the active state) */\n direction: 'left' | 'right';\n /** The color of the square end */\n color: string;\n /** The height of the square end in pixels */\n height: number;\n /** HTML attributes */\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n\nconst SquareEnd = ({\n direction = 'left',\n color,\n height = 24,\n htmlAttributes,\n}: SquareEndProps) => {\n const classes = classNames('ndl-square-end', {\n 'ndl-left': direction === 'left',\n 'ndl-right': direction === 'right',\n });\n\n return (\n <div className={classes} {...htmlAttributes}>\n <div\n className=\"ndl-square-end-inner\"\n style={{ backgroundColor: color }}\n />\n <svg\n className=\"ndl-square-end-active\"\n width=\"7\"\n height={height + 6}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 7 30\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M 3.8774 2 C 3.2697 2 2.7917 2.248 2.3967 2.6605 C 1.928 3.1498 1.7993 3.8555 1.7993 4.5331 V 13.8775 V 25.4669 C 1.7993 26.1445 1.928 26.8502 2.3967 27.3395 C 2.7917 27.752 3.2697 28 3.8774 28 H 7 V 30 H 3.8774 C 2.6211 30 1.4369 29.4282 0.5895 28.4485 C 0.1462 27.936 0.0002 27.2467 0.0002 26.5691 L -0.0002 13.8775 L 0.0002 3.4309 C 0.0002 2.7533 0.1462 2.064 0.5895 1.5515 C 1.4368 0.5718 2.6211 0 3.8774 0 H 7 V 2 H 3.8774 Z\"\n />\n </svg>\n </div>\n );\n};\n\ntype HorizontalLinesProps = {\n height?: number;\n};\n\nconst HorizontalLines = ({ height = 24 }: HorizontalLinesProps) => {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height={height + 6}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 37 30\"\n fill=\"none\"\n className=\"ndl-relationship-label-lines\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M 37 2 H 0 V 0 H 37 V 2 Z\"\n />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M 37 30 H 0 V 28 H 37 V 30 Z\"\n />\n </svg>\n );\n};\n\n/**\n *\n *\n * GraphLabel Component\n *\n *\n */\n\nconst MAX_WIDTH = 200;\n\nexport const GraphLabel = <T extends React.ElementType = 'button'>({\n type = 'node',\n color,\n isDisabled = false,\n isSelected = false,\n as,\n onClick,\n className,\n style,\n children,\n htmlAttributes,\n isFluid = false,\n size = 'large',\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, GraphLabelProps>) => {\n const [isHover, setIsHover] = useState(false);\n\n const handleMouseEnter = (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => {\n setIsHover(true);\n\n if (htmlAttributes && htmlAttributes.onMouseEnter !== undefined) {\n htmlAttributes.onMouseEnter(event);\n }\n };\n\n const handleMouseLeave = (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => {\n setIsHover(false);\n\n htmlAttributes?.onMouseLeave?.(event);\n };\n\n const Component: React.ElementType = as ?? 'button';\n const isButton = Component === 'button';\n\n const handleClick = (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => {\n // By default, a <button /> element with disabled set to true will not get its\n // on click handler called. To support the same behavior on <a /> tags we\n // swallow the event here when disabled, since the <a /> tag with disabled set to\n // true will have its onClick handler called\n if (isDisabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n if (onClick) {\n onClick(event);\n }\n };\n\n let backgroundColor = useMemo(() => {\n if (color === undefined) {\n switch (type) {\n case 'node':\n return tokens.graph['1'];\n case 'relationship':\n case 'relationshipLeft':\n case 'relationshipRight':\n return tokens.theme.light.color.neutral.bg.strong;\n default:\n return tokens.theme.light.color.neutral.bg.strongest;\n }\n }\n return color;\n }, [color, type]);\n\n const hoverColor = useMemo(\n () =>\n getHoverColor(\n backgroundColor ? backgroundColor : tokens.palette.lemon[40],\n ),\n [backgroundColor],\n );\n const textColor = useMemo(\n () =>\n getTextColorFromBackground(\n backgroundColor ? backgroundColor : tokens.palette.lemon[40],\n ),\n [backgroundColor],\n );\n const disabledTextColor = useMemo(\n () =>\n getDisabledTextColor(\n backgroundColor ? backgroundColor : tokens.palette.lemon[40],\n ),\n [backgroundColor],\n );\n\n if (isHover && !isDisabled) {\n backgroundColor = hoverColor;\n }\n\n const commonClasses = classNames('ndl-graph-label', className, {\n 'ndl-disabled': isDisabled,\n 'ndl-interactable': isButton,\n 'ndl-selected': isSelected,\n 'ndl-small': size === 'small',\n });\n\n if (type === 'node') {\n const classes = classNames('ndl-node-label', commonClasses);\n\n return (\n <Component\n className={classes}\n ref={ref}\n style={{\n backgroundColor: backgroundColor,\n color: isDisabled ? disabledTextColor : textColor,\n maxWidth: isFluid ? '100%' : MAX_WIDTH,\n ...style,\n }}\n {...(isButton && {\n disabled: isDisabled,\n onClick: handleClick,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n })}\n {...htmlAttributes}\n >\n <div className=\"ndl-node-label-content\">{children}</div>\n </Component>\n );\n } else if (\n type === 'relationship' ||\n type === 'relationshipLeft' ||\n type === 'relationshipRight'\n ) {\n const classes = classNames('ndl-relationship-label', commonClasses);\n const height = size === 'small' ? 20 : 24;\n\n return (\n <Component\n style={{\n maxWidth: isFluid ? '100%' : MAX_WIDTH,\n ...style,\n color: isDisabled ? disabledTextColor : textColor,\n }}\n className={classes}\n {...(isButton && {\n disabled: isDisabled,\n onClick: handleClick,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n })}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n {type === 'relationshipLeft' || type === 'relationship' ? (\n <HexagonEnd\n direction=\"left\"\n color={backgroundColor}\n height={height}\n />\n ) : (\n <SquareEnd direction=\"left\" color={backgroundColor} height={height} />\n )}\n <div\n className=\"ndl-relationship-label-container\"\n style={{\n backgroundColor: backgroundColor,\n }}\n >\n <div className=\"ndl-relationship-label-content\">{children}</div>\n <HorizontalLines height={height} />\n </div>\n {type === 'relationshipRight' || type === 'relationship' ? (\n <HexagonEnd\n direction=\"right\"\n color={backgroundColor}\n height={height}\n />\n ) : (\n <SquareEnd\n direction=\"right\"\n color={backgroundColor}\n height={height}\n />\n )}\n </Component>\n );\n } else {\n const classes = classNames('ndl-property-key-label', commonClasses);\n\n return (\n <Component\n style={{\n backgroundColor: backgroundColor,\n color: isDisabled ? disabledTextColor : textColor,\n maxWidth: isFluid ? '100%' : MAX_WIDTH,\n ...style,\n }}\n className={classes}\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n ref={ref}\n {...htmlAttributes}\n >\n <div className=\"ndl-property-key-label-content\">{children}</div>\n </Component>\n );\n }\n};\n"]}
1
+ {"version":3,"file":"GraphLabel.js","sourceRoot":"","sources":["../../../src/graph-label/GraphLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,0CAAyC;AACzC,4DAAoC;AAEpC,iCAA0C;AAM1C,mCAIiB;AAgDjB;;;;;;GAMG;AAEH,MAAM,UAAU,GAAG,CAAC,EAClB,SAAS,GAAG,MAAM,EAClB,KAAK,EACL,cAAc,EACd,MAAM,GAAG,EAAE,GACK,EAAE,EAAE;IACpB,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,iBAAiB,EAAE;QAC5C,UAAU,EAAE,SAAS,KAAK,MAAM;QAChC,WAAW,EAAE,SAAS,KAAK,OAAO;KACnC,CAAC,CAAC;IAEH,OAAO,CACL,+CAAK,SAAS,EAAE,OAAO,IAAM,cAAc,eACzC,+CACe,IAAI,EACjB,SAAS,EAAC,uBAAuB,EACjC,IAAI,EAAC,MAAM,EACX,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAC,MAAM,EAC1B,OAAO,EAAC,UAAU,EAClB,KAAK,EAAC,GAAG,EACT,KAAK,EAAC,4BAA4B,YAGlC,iCACE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EACtB,QAAQ,EAAC,SAAS,EAClB,QAAQ,EAAC,SAAS,EAClB,CAAC,EAAC,oMAAoM,GACtM,GACE,EACN,+CACe,IAAI,EACjB,SAAS,EAAC,wBAAwB,EAClC,IAAI,EAAC,MAAM,EACX,MAAM,EAAE,MAAM,GAAG,CAAC,EAClB,m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zD,uBAAC,UAAU,IACT,SAAS,EAAC,OAAO,EACjB,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,MAAM,GACd,CACH,CAAC,CAAC,CAAC,CACF,uBAAC,SAAS,IACR,SAAS,EAAC,OAAO,EACjB,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,MAAM,GACd,CACH,KACS,CACb,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,wBAAwB,EAAE,aAAa,CAAC,CAAC;QAEpE,OAAO,CACL,uBAAC,SAAS,oBACJ,CAAC,QAAQ,IAAI;YACf,IAAI,EAAE,QAAQ;SACf,CAAC,IACF,KAAK,kBACH,eAAe,EAAE,eAAe,EAChC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,EACjD,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,IACnC,KAAK,GAEV,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,WAAW,EACpB,YAAY,EAAE,gBAAgB,EAC9B,YAAY,EAAE,gBAAgB,EAC9B,GAAG,EAAE,GAAG,IACJ,cAAc,cAElB,gCAAK,SAAS,EAAC,gCAAgC,YAAE,QAAQ,GAAO,IACtD,CACb,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAxNW,QAAA,UAAU,cAwNrB","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 { tokens } from '@neo4j-ndl/base';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { useMemo, useState } from 'react';\n\nimport {\n type HtmlAttributes,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport {\n getDisabledTextColor,\n getHoverColor,\n getTextColorFromBackground,\n} from './color';\n\n/**\n *\n *\n * Types\n *\n *\n */\n\ntype GraphLabelProps = {\n /** The type of label */\n type:\n | 'node'\n | 'relationship'\n | 'propertyKey'\n | 'relationshipLeft'\n | 'relationshipRight';\n /** Callback function that is called when the label is clicked */\n onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /** Additional styles to apply to the label */\n style?: React.CSSProperties;\n /** Content displayed inside the label */\n children?: React.ReactNode;\n /** The background color of the label */\n color?: string;\n /** Whether the label is disabled */\n isDisabled?: boolean;\n /** Additional class names */\n className?: string;\n /** Whether the label is selected */\n isSelected?: boolean;\n /** Whether the label should expand to full available width */\n isFluid?: boolean;\n /** The size of the label */\n size?: 'small' | 'large';\n};\n\ntype HexagonEndProps = {\n /** The direction of the hexagon end */\n direction: 'left' | 'right';\n /** The color of the hexagon end */\n color?: string;\n /** The height of the hexagon end in pixels */\n height?: number;\n /** HTML attributes */\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n/**\n *\n *\n * Helpers\n *\n *\n */\n\nconst HexagonEnd = ({\n direction = 'left',\n color,\n htmlAttributes,\n height = 24,\n}: HexagonEndProps) => {\n const classes = classNames('ndl-hexagon-end', {\n 'ndl-left': direction === 'left',\n 'ndl-right': direction === 'right',\n });\n\n return (\n <div className={classes} {...htmlAttributes}>\n <svg\n aria-hidden={true}\n className=\"ndl-hexagon-end-inner\"\n fill=\"none\"\n height={height}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 9 24\"\n width=\"9\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n {/* triangle */}\n <path\n style={{ fill: color }}\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M5.73024 1.03676C6.08165 0.397331 6.75338 0 7.48301 0H9V24H7.483C6.75338 24 6.08165 23.6027 5.73024 22.9632L0.315027 13.1094C-0.105009 12.4376 -0.105009 11.5624 0.315026 10.8906L5.73024 1.03676Z\"\n />\n </svg>\n <svg\n aria-hidden={true}\n className=\"ndl-hexagon-end-active\"\n fill=\"none\"\n height={height + 6}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 13 30\"\n width=\"13\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10.075 2C9.12474 2 8.24318 2.54521 7.74867 3.43873L2.21419 13.4387C1.68353 14.3976 1.68353 15.6024 2.21419 16.5613L7.74867 26.5613C8.24318 27.4548 9.12474 28 10.075 28H13V30H10.075C8.49126 30 7.022 29.0913 6.1978 27.6021L0.663324 17.6021C-0.221109 16.0041 -0.221108 13.9959 0.663325 12.3979L6.1978 2.39789C7.022 0.90869 8.49126 0 10.075 0H13V2H10.075Z\"\n />\n </svg>\n </div>\n );\n};\n\ntype SquareEndProps = {\n /** The direction of the square end (where it's rounded and has the active state) */\n direction: 'left' | 'right';\n /** The color of the square end */\n color: string;\n /** The height of the square end in pixels */\n height: number;\n /** HTML attributes */\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n\nconst SquareEnd = ({\n direction = 'left',\n color,\n height = 24,\n htmlAttributes,\n}: SquareEndProps) => {\n const classes = classNames('ndl-square-end', {\n 'ndl-left': direction === 'left',\n 'ndl-right': direction === 'right',\n });\n\n return (\n <div className={classes} {...htmlAttributes}>\n <div\n className=\"ndl-square-end-inner\"\n style={{ backgroundColor: color }}\n />\n <svg\n className=\"ndl-square-end-active\"\n width=\"7\"\n height={height + 6}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 7 30\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M 3.8774 2 C 3.2697 2 2.7917 2.248 2.3967 2.6605 C 1.928 3.1498 1.7993 3.8555 1.7993 4.5331 V 13.8775 V 25.4669 C 1.7993 26.1445 1.928 26.8502 2.3967 27.3395 C 2.7917 27.752 3.2697 28 3.8774 28 H 7 V 30 H 3.8774 C 2.6211 30 1.4369 29.4282 0.5895 28.4485 C 0.1462 27.936 0.0002 27.2467 0.0002 26.5691 L -0.0002 13.8775 L 0.0002 3.4309 C 0.0002 2.7533 0.1462 2.064 0.5895 1.5515 C 1.4368 0.5718 2.6211 0 3.8774 0 H 7 V 2 H 3.8774 Z\"\n />\n </svg>\n </div>\n );\n};\n\ntype HorizontalLinesProps = {\n height?: number;\n};\n\nconst HorizontalLines = ({ height = 24 }: HorizontalLinesProps) => {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height={height + 6}\n preserveAspectRatio=\"none\"\n viewBox=\"0 0 37 30\"\n fill=\"none\"\n className=\"ndl-relationship-label-lines\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M 37 2 H 0 V 0 H 37 V 2 Z\"\n />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M 37 30 H 0 V 28 H 37 V 30 Z\"\n />\n </svg>\n );\n};\n\n/**\n *\n *\n * GraphLabel Component\n *\n *\n */\n\nconst MAX_WIDTH = 200;\n\nexport const GraphLabel = <T extends React.ElementType = 'button'>({\n type = 'node',\n color,\n isDisabled = false,\n isSelected = false,\n as,\n onClick,\n className,\n style,\n children,\n htmlAttributes,\n isFluid = false,\n size = 'large',\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, GraphLabelProps>) => {\n const [isHover, setIsHover] = useState(false);\n\n const handleMouseEnter = (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => {\n setIsHover(true);\n\n if (htmlAttributes && htmlAttributes.onMouseEnter !== undefined) {\n htmlAttributes.onMouseEnter(event);\n }\n };\n\n const handleMouseLeave = (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => {\n setIsHover(false);\n\n htmlAttributes?.onMouseLeave?.(event);\n };\n\n const Component: React.ElementType = as ?? 'button';\n const isButton = Component === 'button';\n\n const handleClick = (\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n ) => {\n // By default, a <button /> element with disabled set to true will not get its\n // on click handler called. To support the same behavior on <a /> tags we\n // swallow the event here when disabled, since the <a /> tag with disabled set to\n // true will have its onClick handler called\n if (isDisabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n if (onClick) {\n onClick(event);\n }\n };\n\n let backgroundColor = useMemo(() => {\n if (color === undefined) {\n switch (type) {\n case 'node':\n return tokens.graph['1'];\n case 'relationship':\n case 'relationshipLeft':\n case 'relationshipRight':\n return tokens.theme.light.color.neutral.bg.strong;\n default:\n return tokens.theme.light.color.neutral.bg.strongest;\n }\n }\n return color;\n }, [color, type]);\n\n const hoverColor = useMemo(\n () =>\n getHoverColor(\n backgroundColor ? backgroundColor : tokens.palette.lemon[40],\n ),\n [backgroundColor],\n );\n const textColor = useMemo(\n () =>\n getTextColorFromBackground(\n backgroundColor ? backgroundColor : tokens.palette.lemon[40],\n ),\n [backgroundColor],\n );\n const disabledTextColor = useMemo(\n () =>\n getDisabledTextColor(\n backgroundColor ? backgroundColor : tokens.palette.lemon[40],\n ),\n [backgroundColor],\n );\n\n if (isHover && !isDisabled) {\n backgroundColor = hoverColor;\n }\n\n const commonClasses = classNames('ndl-graph-label', className, {\n 'ndl-disabled': isDisabled,\n 'ndl-interactable': isButton,\n 'ndl-selected': isSelected,\n 'ndl-small': size === 'small',\n });\n\n if (type === 'node') {\n const classes = classNames('ndl-node-label', commonClasses);\n\n return (\n <Component\n className={classes}\n ref={ref}\n style={{\n backgroundColor: backgroundColor,\n color: isDisabled ? disabledTextColor : textColor,\n maxWidth: isFluid ? '100%' : MAX_WIDTH,\n ...style,\n }}\n {...(isButton && {\n disabled: isDisabled,\n onClick: handleClick,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n type: 'button',\n })}\n {...htmlAttributes}\n >\n <div className=\"ndl-node-label-content\">{children}</div>\n </Component>\n );\n } else if (\n type === 'relationship' ||\n type === 'relationshipLeft' ||\n type === 'relationshipRight'\n ) {\n const classes = classNames('ndl-relationship-label', commonClasses);\n const height = size === 'small' ? 20 : 24;\n\n return (\n <Component\n style={{\n maxWidth: isFluid ? '100%' : MAX_WIDTH,\n ...style,\n color: isDisabled ? disabledTextColor : textColor,\n }}\n className={classes}\n {...(isButton && {\n disabled: isDisabled,\n onClick: handleClick,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n type: 'button',\n })}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n {type === 'relationshipLeft' || type === 'relationship' ? (\n <HexagonEnd\n direction=\"left\"\n color={backgroundColor}\n height={height}\n />\n ) : (\n <SquareEnd direction=\"left\" color={backgroundColor} height={height} />\n )}\n <div\n className=\"ndl-relationship-label-container\"\n style={{\n backgroundColor: backgroundColor,\n }}\n >\n <div className=\"ndl-relationship-label-content\">{children}</div>\n <HorizontalLines height={height} />\n </div>\n {type === 'relationshipRight' || type === 'relationship' ? (\n <HexagonEnd\n direction=\"right\"\n color={backgroundColor}\n height={height}\n />\n ) : (\n <SquareEnd\n direction=\"right\"\n color={backgroundColor}\n height={height}\n />\n )}\n </Component>\n );\n } else {\n const classes = classNames('ndl-property-key-label', commonClasses);\n\n return (\n <Component\n {...(isButton && {\n type: 'button',\n })}\n style={{\n backgroundColor: backgroundColor,\n color: isDisabled ? disabledTextColor : textColor,\n maxWidth: isFluid ? '100%' : MAX_WIDTH,\n ...style,\n }}\n className={classes}\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n ref={ref}\n {...htmlAttributes}\n >\n <div className=\"ndl-property-key-label-content\">{children}</div>\n </Component>\n );\n }\n};\n"]}
@@ -182,7 +182,7 @@ const InlineEdit = (_a) => {
182
182
  onMouseDown: () => {
183
183
  blurWithinRef.current = true;
184
184
  },
185
- }, children: (0, jsx_runtime_1.jsx)(icons_1.XMarkIconOutline, {}) })] })] }))) : ((0, jsx_runtime_1.jsxs)("button", { className: (0, classnames_1.default)('ndl-inline-idle-container', {
185
+ }, children: (0, jsx_runtime_1.jsx)(icons_1.XMarkIconOutline, {}) })] })] }))) : ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: (0, classnames_1.default)('ndl-inline-idle-container', {
186
186
  'n-text-neutral-text-weaker': displayText === placeholder,
187
187
  'ndl-disabled': isDisabled,
188
188
  'ndl-has-edit-icon': hasEditIcon,
@@ -1 +1 @@
1
- {"version":3,"file":"InlineEdit.js","sourceRoot":"","sources":["../../../src/inline-edit/InlineEdit.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAAoC;AAEpC,iCAQe;AACf,2CAA4C;AAM5C,oFAA8E;AAC9E,4CAAkE;AAClE,gDAA4C;AAC5C,oCAIkB;AAClB,8CAA2C;AAE3C,mCAAqD;AAgFrD,0FAA0F;AAC1F,MAAM,aAAa,GAAG,GAAG,CAAC;AAEnB,MAAM,UAAU,GAAG,CAAsC,EAqBnB,EAAE,EAAE;;QArBe,EAC9D,EAAE,EACF,SAAS,EACT,YAAY,EACZ,cAAc,EACd,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,GAAG,EACH,KAAK,EACL,KAAK,EACL,WAAW,GAAG,KAAK,EACnB,UAAU,EACV,UAAU,GAAG,KAAK,EAClB,SAAS,EACT,YAAY,GAAG,SAAS,EACxB,OAAO,GAAG,KAAK,EACf,iBAAiB,GAAG,mBAAmB,EACvC,WAAW,OAEgC,EADxC,SAAS,cApBkD,mPAqB/D,CADa;IAEZ,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAEnD,MA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UAAU,EACzB,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE;oBACL,SAAS,EAAE,IAAA,oBAAY,EAAC,iBAAiB,CAAC;iBAC3C,aAED,iCAAM,SAAS,EAAC,sBAAsB,YAAE,WAAW,GAAQ,EAC1D,WAAW,IAAI,CACd,uBAAC,yBAAiB,IAChB,SAAS,EAAC,6BAA6B,EACvC,KAAK,EAAE,IAAA,oBAAY,EAAC,iBAAiB,CAAC,GACtC,CACH,IACM,CACV,KACU,CACd,CAAC;AACJ,CAAC,CAAC;AA3QW,QAAA,UAAU,cA2QrB","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 classNames from 'classnames';\nimport type React from 'react';\nimport {\n type ReactNode,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useFocusWithin } from 'react-aria';\n\nimport {\n type HtmlAttributes,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { useSemicontrolledState } from '../_common/use-semi-controlled-state';\nimport { needleWarningMessage, randomId } from '../_common/utils';\nimport { IconButton } from '../icon-button';\nimport {\n CheckIconOutline,\n PencilIconOutline,\n XMarkIconOutline,\n} from '../icons';\nimport { Typography } from '../typography';\nimport { type TypographyVariants } from '../typography';\nimport { getIconStyle, getMinHeight } from './utils';\n\ntype InlineEditProps = {\n /** Label text */\n label?: ReactNode;\n\n /**\n * The typographyVariant of the component applied to Typography as its variant.\n * @default subheading-medium\n */\n typographyVariant?: TypographyVariants;\n\n /**\n * The default input value. Use for an uncontrolled component.\n */\n defaultValue?: string;\n\n /**\n * The input value. Makes the component controlled.\n */\n value?: string;\n\n /**\n * Callback when the input value changes. Must be used when the component is controlled.\n */\n onChange?: (value: string) => void;\n\n /**\n * Placeholder text displayed when the input is empty.\n */\n placeholder: string;\n\n /**\n * @default false\n */\n isDisabled?: boolean;\n\n /**\n * If edit pencil icon should be visible on hover\n * @default false\n */\n hasEditIcon?: boolean;\n\n /**\n * If the input is in editing mode\n * Used in a stateless inline edit\n * @default undefined\n */\n isEditing?: boolean;\n\n /** Callback when confirm icon button is pressed */\n onConfirm?: (\n value: string,\n event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n ) => void;\n\n /** Callback when cancel icon button is pressed */\n onCancel?: (\n event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n ) => void;\n\n /**\n * What the input should do on blur\n * - \"confirm\" will confirm the value\n * - \"cancel\" will cancel the value\n * - \"none\" will do nothing\n * @default \"confirm\"\n */\n blurBehavior?: 'confirm' | 'cancel' | 'none';\n\n /** props applied to the internal input element */\n inputProps?: HtmlAttributes<'input'>;\n\n /**\n * If the input is fluid\n * @default false\n */\n isFluid?: boolean;\n};\n\n// The input should not be less than this (it does shrink if container is smaller though).\nconst MINIMUM_WIDTH = 320;\n\nexport const InlineEdit = <T extends React.ElementType = 'div'>({\n as,\n className,\n defaultValue,\n htmlAttributes,\n label,\n onChange,\n onCancel,\n onConfirm,\n ref,\n style,\n value,\n hasEditIcon = false,\n inputProps,\n isDisabled = false,\n isEditing,\n blurBehavior = 'confirm',\n isFluid = false,\n typographyVariant = 'subheading-medium',\n placeholder,\n ...restProps\n}: PolymorphicCommonProps<T, InlineEditProps>) => {\n const [hasEditMode, setEditMode] = useState(false);\n\n const [currentValue, setCurrentValue] = useSemicontrolledState({\n isControlled: value !== undefined,\n onChange,\n state: value ?? defaultValue ?? '',\n });\n const [previousConfirmedValue, setPreviousConfirmedValue] =\n useState(currentValue);\n\n const mirrorRef = useRef<HTMLSpanElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n /**\n * This ref is used to prevent the blur behavior from being triggered on mouse down events\n * on the confirm and cancel buttons. So when true, the blur behavior is not triggered.\n * This is needed due to Webkit browsers (like Safari) triggering blur on mouse down events.\n *\n * It is also used to prevent the blur behavior from being triggered after the component exits edit mode without blur.\n * This bug caused the handler to be called when something was focused after confirming.\n */\n const blurWithinRef = useRef(false);\n\n // Validate controlled mode requirements\n useEffect(() => {\n if (value !== undefined && onChange === undefined) {\n needleWarningMessage(\n 'onChange prop should be supplied when using controlled mode (value prop is provided).',\n );\n }\n }, [value, onChange]);\n\n const { focusWithinProps } = useFocusWithin({\n onBlurWithin: () => {\n if (blurWithinRef.current) {\n return;\n }\n\n if (blurBehavior === 'confirm') {\n onConfirmHandler();\n return;\n }\n if (blurBehavior === 'cancel') {\n onCancelHandler();\n return;\n }\n },\n });\n\n const resetToDefaults = useCallback(() => {\n // In controlled mode, don't reset the value - let the parent manage it\n // In uncontrolled mode, reset to default value\n if (value === undefined) {\n setCurrentValue(previousConfirmedValue ?? '');\n }\n // Only reset edit mode if isEditing is not controlled (undefined)\n if (isEditing === undefined) {\n blurWithinRef.current = true;\n setEditMode(false);\n }\n }, [previousConfirmedValue, isEditing, setCurrentValue, value]);\n\n const resetEditState = useCallback(() => {\n // Only reset edit mode if isEditing is not controlled (undefined)\n if (isEditing === undefined) {\n blurWithinRef.current = true;\n setEditMode(false);\n }\n }, [isEditing]);\n\n const onConfirmHandler = useCallback(\n async (\n event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n ) => {\n setPreviousConfirmedValue(currentValue);\n onConfirm?.(currentValue, event);\n resetEditState();\n },\n [onConfirm, currentValue, resetEditState],\n );\n\n const onCancelHandler = useCallback(\n (\n event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n ) => {\n onCancel?.(event);\n resetToDefaults();\n },\n [onCancel, resetToDefaults],\n );\n\n const inputID = useMemo(() => {\n return inputProps?.id ?? randomId(12);\n }, [inputProps?.id]);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (['Enter', 'Escape'].includes(e.key)) {\n if (e.key === 'Enter') {\n onConfirmHandler();\n }\n if (e.key === 'Escape') {\n onCancelHandler();\n }\n e.preventDefault();\n e.stopPropagation();\n }\n },\n [onConfirmHandler, onCancelHandler],\n );\n\n const handleInputChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = e.target.value;\n setCurrentValue(newValue);\n },\n [setCurrentValue],\n );\n\n const isInEditMode = isEditing ?? hasEditMode;\n\n const handleEditClick = useCallback(() => {\n if (isDisabled === false) {\n setEditMode(true);\n blurWithinRef.current = false;\n }\n }, [isDisabled]);\n\n const updateInputWidth = useCallback(() => {\n if (mirrorRef.current && containerRef.current && !isFluid) {\n const mirrorWidth = mirrorRef.current.offsetWidth;\n const newWidth = Math.max(mirrorWidth, MINIMUM_WIDTH);\n containerRef.current.style.width = `${newWidth}px`;\n }\n }, [mirrorRef, containerRef, isFluid]);\n\n // Width calculation effect\n useLayoutEffect(() => {\n updateInputWidth();\n }, [updateInputWidth, isInEditMode, currentValue]);\n\n const displayText = currentValue || placeholder;\n\n return (\n <Typography\n as={as ?? 'div'}\n variant={typographyVariant}\n className={classNames('ndl-inline-edit', className, {\n 'ndl-disabled': isDisabled,\n 'ndl-fluid': isFluid,\n })}\n style={style}\n ref={ref}\n htmlAttributes={htmlAttributes}\n {...restProps}\n >\n {Boolean(label) && <label htmlFor={inputID}>{label}</label>}\n {isInEditMode === true ? (\n <div\n className=\"ndl-inline-edit-container\"\n ref={containerRef}\n {...focusWithinProps}\n >\n {/* Mirror span for measuring width */}\n <span\n aria-hidden={true}\n className=\"ndl-inline-edit-mirror\"\n ref={mirrorRef}\n >\n {displayText}\n </span>\n <input\n {...inputProps}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus\n aria-label={typeof label === 'string' ? label : 'Inline edit input'}\n className={classNames(\n 'ndl-inline-edit-input',\n inputProps?.className,\n )}\n id={inputID}\n value={currentValue}\n onChange={handleInputChange}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n />\n <div className=\"ndl-inline-edit-buttons\">\n <IconButton\n description=\"Accept\"\n tooltipProps={{\n root: { placement: 'bottom' },\n }}\n onClick={onConfirmHandler}\n size=\"small\"\n isFloating={true}\n htmlAttributes={{\n onMouseDown: () => {\n blurWithinRef.current = true;\n },\n }}\n >\n <CheckIconOutline />\n </IconButton>\n <IconButton\n description=\"Cancel\"\n tooltipProps={{\n root: { placement: 'bottom' },\n }}\n onClick={(event) => onCancelHandler(event)}\n size=\"small\"\n isFloating={true}\n htmlAttributes={{\n onMouseDown: () => {\n blurWithinRef.current = true;\n },\n }}\n >\n <XMarkIconOutline />\n </IconButton>\n </div>\n </div>\n ) : (\n <button\n className={classNames('ndl-inline-idle-container', {\n 'n-text-neutral-text-weaker': displayText === placeholder,\n 'ndl-disabled': isDisabled,\n 'ndl-has-edit-icon': hasEditIcon,\n })}\n aria-disabled={isDisabled}\n disabled={isDisabled}\n onClick={handleEditClick}\n style={{\n minHeight: getMinHeight(typographyVariant),\n }}\n >\n <span className=\"ndl-inline-edit-text\">{displayText}</span>\n {hasEditIcon && (\n <PencilIconOutline\n className=\"ndl-inline-edit-pencil-icon\"\n style={getIconStyle(typographyVariant)}\n />\n )}\n </button>\n )}\n </Typography>\n );\n};\n"]}
1
+ {"version":3,"file":"InlineEdit.js","sourceRoot":"","sources":["../../../src/inline-edit/InlineEdit.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAAoC;AAEpC,iCAQe;AACf,2CAA4C;AAM5C,oFAA8E;AAC9E,4CAAkE;AAClE,gDAA4C;AAC5C,oCAIkB;AAClB,8CA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AAC,QAAQ,EACpB,YAAY,EAAE;oCACZ,IAAI,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE;iCAC9B,EACD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,EAC1C,IAAI,EAAC,OAAO,EACZ,UAAU,EAAE,IAAI,EAChB,cAAc,EAAE;oCACd,WAAW,EAAE,GAAG,EAAE;wCAChB,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC;oCAC/B,CAAC;iCACF,YAED,uBAAC,wBAAgB,KAAG,GACT,IACT,KACF,CACP,CAAC,CAAC,CAAC,CACF,oCACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,IAAA,oBAAU,EAAC,2BAA2B,EAAE;oBACjD,4BAA4B,EAAE,WAAW,KAAK,WAAW;oBACzD,cAAc,EAAE,UAAU;oBAC1B,mBAAmB,EAAE,WAAW;iBACjC,CAAC,mBACa,UAAU,EACzB,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE;oBACL,SAAS,EAAE,IAAA,oBAAY,EAAC,iBAAiB,CAAC;iBAC3C,aAED,iCAAM,SAAS,EAAC,sBAAsB,YAAE,WAAW,GAAQ,EAC1D,WAAW,IAAI,CACd,uBAAC,yBAAiB,IAChB,SAAS,EAAC,6BAA6B,EACvC,KAAK,EAAE,IAAA,oBAAY,EAAC,iBAAiB,CAAC,GACtC,CACH,IACM,CACV,KACU,CACd,CAAC;AACJ,CAAC,CAAC;AA5QW,QAAA,UAAU,cA4QrB","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 classNames from 'classnames';\nimport type React from 'react';\nimport {\n type ReactNode,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useFocusWithin } from 'react-aria';\n\nimport {\n type HtmlAttributes,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { useSemicontrolledState } from '../_common/use-semi-controlled-state';\nimport { needleWarningMessage, randomId } from '../_common/utils';\nimport { IconButton } from '../icon-button';\nimport {\n CheckIconOutline,\n PencilIconOutline,\n XMarkIconOutline,\n} from '../icons';\nimport { Typography } from '../typography';\nimport { type TypographyVariants } from '../typography';\nimport { getIconStyle, getMinHeight } from './utils';\n\ntype InlineEditProps = {\n /** Label text */\n label?: ReactNode;\n\n /**\n * The typographyVariant of the component applied to Typography as its variant.\n * @default subheading-medium\n */\n typographyVariant?: TypographyVariants;\n\n /**\n * The default input value. Use for an uncontrolled component.\n */\n defaultValue?: string;\n\n /**\n * The input value. Makes the component controlled.\n */\n value?: string;\n\n /**\n * Callback when the input value changes. Must be used when the component is controlled.\n */\n onChange?: (value: string) => void;\n\n /**\n * Placeholder text displayed when the input is empty.\n */\n placeholder: string;\n\n /**\n * @default false\n */\n isDisabled?: boolean;\n\n /**\n * If edit pencil icon should be visible on hover\n * @default false\n */\n hasEditIcon?: boolean;\n\n /**\n * If the input is in editing mode\n * Used in a stateless inline edit\n * @default undefined\n */\n isEditing?: boolean;\n\n /** Callback when confirm icon button is pressed */\n onConfirm?: (\n value: string,\n event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n ) => void;\n\n /** Callback when cancel icon button is pressed */\n onCancel?: (\n event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n ) => void;\n\n /**\n * What the input should do on blur\n * - \"confirm\" will confirm the value\n * - \"cancel\" will cancel the value\n * - \"none\" will do nothing\n * @default \"confirm\"\n */\n blurBehavior?: 'confirm' | 'cancel' | 'none';\n\n /** props applied to the internal input element */\n inputProps?: HtmlAttributes<'input'>;\n\n /**\n * If the input is fluid\n * @default false\n */\n isFluid?: boolean;\n};\n\n// The input should not be less than this (it does shrink if container is smaller though).\nconst MINIMUM_WIDTH = 320;\n\nexport const InlineEdit = <T extends React.ElementType = 'div'>({\n as,\n className,\n defaultValue,\n htmlAttributes,\n label,\n onChange,\n onCancel,\n onConfirm,\n ref,\n style,\n value,\n hasEditIcon = false,\n inputProps,\n isDisabled = false,\n isEditing,\n blurBehavior = 'confirm',\n isFluid = false,\n typographyVariant = 'subheading-medium',\n placeholder,\n ...restProps\n}: PolymorphicCommonProps<T, InlineEditProps>) => {\n const [hasEditMode, setEditMode] = useState(false);\n\n const [currentValue, setCurrentValue] = useSemicontrolledState({\n isControlled: value !== undefined,\n onChange,\n state: value ?? defaultValue ?? '',\n });\n const [previousConfirmedValue, setPreviousConfirmedValue] =\n useState(currentValue);\n\n const mirrorRef = useRef<HTMLSpanElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n /**\n * This ref is used to prevent the blur behavior from being triggered on mouse down events\n * on the confirm and cancel buttons. So when true, the blur behavior is not triggered.\n * This is needed due to Webkit browsers (like Safari) triggering blur on mouse down events.\n *\n * It is also used to prevent the blur behavior from being triggered after the component exits edit mode without blur.\n * This bug caused the handler to be called when something was focused after confirming.\n */\n const blurWithinRef = useRef(false);\n\n // Validate controlled mode requirements\n useEffect(() => {\n if (value !== undefined && onChange === undefined) {\n needleWarningMessage(\n 'onChange prop should be supplied when using controlled mode (value prop is provided).',\n );\n }\n }, [value, onChange]);\n\n const { focusWithinProps } = useFocusWithin({\n onBlurWithin: () => {\n if (blurWithinRef.current) {\n return;\n }\n\n if (blurBehavior === 'confirm') {\n onConfirmHandler();\n return;\n }\n if (blurBehavior === 'cancel') {\n onCancelHandler();\n return;\n }\n },\n });\n\n const resetToDefaults = useCallback(() => {\n // In controlled mode, don't reset the value - let the parent manage it\n // In uncontrolled mode, reset to default value\n if (value === undefined) {\n setCurrentValue(previousConfirmedValue ?? '');\n }\n // Only reset edit mode if isEditing is not controlled (undefined)\n if (isEditing === undefined) {\n blurWithinRef.current = true;\n setEditMode(false);\n }\n }, [previousConfirmedValue, isEditing, setCurrentValue, value]);\n\n const resetEditState = useCallback(() => {\n // Only reset edit mode if isEditing is not controlled (undefined)\n if (isEditing === undefined) {\n blurWithinRef.current = true;\n setEditMode(false);\n }\n }, [isEditing]);\n\n const onConfirmHandler = useCallback(\n async (\n event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n ) => {\n setPreviousConfirmedValue(currentValue);\n onConfirm?.(currentValue, event);\n resetEditState();\n },\n [onConfirm, currentValue, resetEditState],\n );\n\n const onCancelHandler = useCallback(\n (\n event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n ) => {\n onCancel?.(event);\n resetToDefaults();\n },\n [onCancel, resetToDefaults],\n );\n\n const inputID = useMemo(() => {\n return inputProps?.id ?? randomId(12);\n }, [inputProps?.id]);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (['Enter', 'Escape'].includes(e.key)) {\n if (e.key === 'Enter') {\n onConfirmHandler();\n }\n if (e.key === 'Escape') {\n onCancelHandler();\n }\n e.preventDefault();\n e.stopPropagation();\n }\n },\n [onConfirmHandler, onCancelHandler],\n );\n\n const handleInputChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = e.target.value;\n setCurrentValue(newValue);\n },\n [setCurrentValue],\n );\n\n const isInEditMode = isEditing ?? hasEditMode;\n\n const handleEditClick = useCallback(() => {\n if (isDisabled === false) {\n setEditMode(true);\n blurWithinRef.current = false;\n }\n }, [isDisabled]);\n\n const updateInputWidth = useCallback(() => {\n if (mirrorRef.current && containerRef.current && !isFluid) {\n const mirrorWidth = mirrorRef.current.offsetWidth;\n const newWidth = Math.max(mirrorWidth, MINIMUM_WIDTH);\n containerRef.current.style.width = `${newWidth}px`;\n }\n }, [mirrorRef, containerRef, isFluid]);\n\n // Width calculation effect\n useLayoutEffect(() => {\n updateInputWidth();\n }, [updateInputWidth, isInEditMode, currentValue]);\n\n const displayText = currentValue || placeholder;\n\n return (\n <Typography\n as={as ?? 'div'}\n variant={typographyVariant}\n className={classNames('ndl-inline-edit', className, {\n 'ndl-disabled': isDisabled,\n 'ndl-fluid': isFluid,\n })}\n style={style}\n ref={ref}\n htmlAttributes={htmlAttributes}\n {...restProps}\n >\n {Boolean(label) && <label htmlFor={inputID}>{label}</label>}\n {isInEditMode === true ? (\n <div\n className=\"ndl-inline-edit-container\"\n ref={containerRef}\n {...focusWithinProps}\n >\n {/* Mirror span for measuring width */}\n <span\n aria-hidden={true}\n className=\"ndl-inline-edit-mirror\"\n ref={mirrorRef}\n >\n {displayText}\n </span>\n <input\n {...inputProps}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus\n aria-label={typeof label === 'string' ? label : 'Inline edit input'}\n className={classNames(\n 'ndl-inline-edit-input',\n inputProps?.className,\n )}\n id={inputID}\n value={currentValue}\n onChange={handleInputChange}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n />\n <div className=\"ndl-inline-edit-buttons\">\n <IconButton\n description=\"Accept\"\n tooltipProps={{\n root: { placement: 'bottom' },\n }}\n onClick={onConfirmHandler}\n size=\"small\"\n isFloating={true}\n htmlAttributes={{\n onMouseDown: () => {\n blurWithinRef.current = true;\n },\n }}\n >\n <CheckIconOutline />\n </IconButton>\n <IconButton\n description=\"Cancel\"\n tooltipProps={{\n root: { placement: 'bottom' },\n }}\n onClick={(event) => onCancelHandler(event)}\n size=\"small\"\n isFloating={true}\n htmlAttributes={{\n onMouseDown: () => {\n blurWithinRef.current = true;\n },\n }}\n >\n <XMarkIconOutline />\n </IconButton>\n </div>\n </div>\n ) : (\n <button\n type=\"button\"\n className={classNames('ndl-inline-idle-container', {\n 'n-text-neutral-text-weaker': displayText === placeholder,\n 'ndl-disabled': isDisabled,\n 'ndl-has-edit-icon': hasEditIcon,\n })}\n aria-disabled={isDisabled}\n disabled={isDisabled}\n onClick={handleEditClick}\n style={{\n minHeight: getMinHeight(typographyVariant),\n }}\n >\n <span className=\"ndl-inline-edit-text\">{displayText}</span>\n {hasEditIcon && (\n <PencilIconOutline\n className=\"ndl-inline-edit-pencil-icon\"\n style={getIconStyle(typographyVariant)}\n />\n )}\n </button>\n )}\n </Typography>\n );\n};\n"]}
@@ -56,7 +56,7 @@ const SelectIconButton = (_a) => {
56
56
  open: 500,
57
57
  } }, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.root, { type: "simple",
58
58
  // We disable the tooltip if the button is disabled or open, so it doesn't interfere with a menu open
59
- isDisabled: description === null || isDisabled || isOpen === true, children: [(0, jsx_runtime_1.jsx)(tooltip_1.Tooltip.Trigger, Object.assign({}, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.trigger, { hasButtonWrapper: true, children: (0, jsx_runtime_1.jsxs)("button", Object.assign({ ref: ref, className: classes, style: style, disabled: !isInteractable, "aria-disabled": !isInteractable, "aria-label": description !== null && description !== void 0 ? description : undefined, "aria-expanded": isOpen, onClick: onClick }, restProps, htmlAttributes, { children: [(0, jsx_runtime_1.jsx)("div", { className: "ndl-select-icon-btn-inner", children: isLoading ? ((0, jsx_runtime_1.jsx)(loading_spinner_1.LoadingSpinner, { size: "small" })) : ((0, jsx_runtime_1.jsx)("div", { className: "ndl-icon", children: children })) }), (0, jsx_runtime_1.jsx)(icons_1.ChevronDownIconOutline, { className: (0, classnames_1.default)('ndl-select-icon-btn-icon', {
59
+ isDisabled: description === null || isDisabled || isOpen === true, children: [(0, jsx_runtime_1.jsx)(tooltip_1.Tooltip.Trigger, Object.assign({}, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.trigger, { hasButtonWrapper: true, children: (0, jsx_runtime_1.jsxs)("button", Object.assign({ type: "button", ref: ref, className: classes, style: style, disabled: !isInteractable, "aria-disabled": !isInteractable, "aria-label": description !== null && description !== void 0 ? description : undefined, "aria-expanded": isOpen, onClick: onClick }, restProps, htmlAttributes, { children: [(0, jsx_runtime_1.jsx)("div", { className: "ndl-select-icon-btn-inner", children: isLoading ? ((0, jsx_runtime_1.jsx)(loading_spinner_1.LoadingSpinner, { size: "small" })) : ((0, jsx_runtime_1.jsx)("div", { className: "ndl-icon", children: children })) }), (0, jsx_runtime_1.jsx)(icons_1.ChevronDownIconOutline, { className: (0, classnames_1.default)('ndl-select-icon-btn-icon', {
60
60
  'ndl-select-icon-btn-icon-open': isOpen === true,
61
61
  }) })] })) })), (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip.Content, Object.assign({}, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.content, { children: description }))] })));
62
62
  };
@@ -1 +1 @@
1
- {"version":3,"file":"SelectIconButton.js","sourceRoot":"","sources":["../../../src/select-icon-button/SelectIconButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAAoC;AAIpC,oCAAkD;AAClD,wDAAoD;AACpD,wCAAqC;AA0B9B,MAAM,gBAAgB,GAAG,CAAC,EAcc,EAAE,EAAE;QAdlB,EAC/B,QAAQ,EACR,IAAI,GAAG,QAAQ,EACf,UAAU,GAAG,KAAK,EAClB,SAAS,GAAG,KAAK,EACjB,MAAM,GAAG,KAAK,EACd,SAAS,EACT,WAAW,EACX,YAAY,EACZ,OAAO,EACP,KAAK,EACL,cAAc,EACd,GAAG,OAE0C,EAD1C,SAAS,cAbmB,kJAchC,CADa;IAEZ,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,qBAAqB,EAAE,SAAS,EAAE;QAC3D,YAAY,EAAE,MAAM;QACpB,cAAc,EAAE,UAAU;QAC1B,WAAW,EAAE,IAAI,KAAK,OAAO;QAC7B,aAAa,EAAE,SAAS;QACxB,YAAY,EAA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AgB,oBAsE3B","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 classNames from 'classnames';\nimport type React from 'react';\n\nimport { type CommonProps, type TooltipObjectProps } from '../_common/types';\nimport { ChevronDownIconOutline } from '../icons';\nimport { LoadingSpinner } from '../loading-spinner';\nimport { Tooltip } from '../tooltip';\n\ntype SelectIconButtonProps = {\n /** Content displayed in the button */\n children?: React.ReactNode;\n /** Size of button */\n size?: 'small' | 'medium' | 'large';\n /** If the button is doing something Async, it will display a loading spinner */\n isLoading?: boolean;\n /** Whether the button is in disabled state */\n isDisabled?: boolean;\n /** If the button is opened */\n isOpen: boolean;\n /** Callback function to be called when the button is clicked */\n onClick?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /**\n * A string that will be shown as a tooltip when hovering over the button. It also acts as an aria-label.\n * {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label}\n */\n description: string | null;\n /**\n * Props for the tooltip component.\n */\n tooltipProps?: TooltipObjectProps;\n};\n\nexport const SelectIconButton = ({\n children,\n size = 'medium',\n isDisabled = false,\n isLoading = false,\n isOpen = false,\n className,\n description,\n tooltipProps,\n onClick,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'button', SelectIconButtonProps>) => {\n const classes = classNames('ndl-select-icon-btn', className, {\n 'ndl-active': isOpen,\n 'ndl-disabled': isDisabled,\n 'ndl-large': size === 'large',\n 'ndl-loading': isLoading,\n 'ndl-medium': size === 'medium',\n 'ndl-small': size === 'small',\n });\n\n const isInteractable = !isDisabled && !isLoading;\n\n return (\n <Tooltip\n hoverDelay={{\n close: 0,\n open: 500,\n }}\n {...tooltipProps?.root}\n type=\"simple\"\n // We disable the tooltip if the button is disabled or open, so it doesn't interfere with a menu open\n isDisabled={description === null || isDisabled || isOpen === true}\n >\n <Tooltip.Trigger {...tooltipProps?.trigger} hasButtonWrapper>\n <button\n ref={ref}\n className={classes}\n style={style}\n disabled={!isInteractable}\n aria-disabled={!isInteractable}\n aria-label={description ?? undefined}\n aria-expanded={isOpen}\n onClick={onClick}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-select-icon-btn-inner\">\n {isLoading ? (\n <LoadingSpinner size=\"small\" />\n ) : (\n <div className=\"ndl-icon\">{children}</div>\n )}\n </div>\n\n <ChevronDownIconOutline\n className={classNames('ndl-select-icon-btn-icon', {\n 'ndl-select-icon-btn-icon-open': isOpen === true,\n })}\n />\n </button>\n </Tooltip.Trigger>\n <Tooltip.Content {...tooltipProps?.content}>\n {description}\n </Tooltip.Content>\n </Tooltip>\n );\n};\n"]}
1
+ {"version":3,"file":"SelectIconButton.js","sourceRoot":"","sources":["../../../src/select-icon-button/SelectIconButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAAoC;AAIpC,oCAAkD;AAClD,wDAAoD;AACpD,wCAAqC;AA0B9B,MAAM,gBAAgB,GAAG,CAAC,EAcc,EAAE,EAAE;QAdlB,EAC/B,QAAQ,EACR,IAAI,GAAG,QAAQ,EACf,UAAU,GAAG,KAAK,EAClB,SAAS,GAAG,KAAK,EACjB,MAAM,GAAG,KAAK,EACd,SAAS,EACT,WAAW,EACX,YAAY,EACZ,OAAO,EACP,KAAK,EACL,cAAc,EACd,GAAG,OAE0C,EAD1C,SAAS,cAbmB,kJAchC,CADa;IAEZ,MAAM,OAAO,GAA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,MAAM,KAAK,IAAI;6BACjD,CAAC,GACF,KACK,IACO,EAClB,uBAAC,iBAAO,CAAC,OAAO,oBAAK,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,OAAO,cACvC,WAAW,IACI,KACV,CACX,CAAC;AACJ,CAAC,CAAC;AAvEW,QAAA,gBAAgB,oBAuE3B","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 classNames from 'classnames';\nimport type React from 'react';\n\nimport { type CommonProps, type TooltipObjectProps } from '../_common/types';\nimport { ChevronDownIconOutline } from '../icons';\nimport { LoadingSpinner } from '../loading-spinner';\nimport { Tooltip } from '../tooltip';\n\ntype SelectIconButtonProps = {\n /** Content displayed in the button */\n children?: React.ReactNode;\n /** Size of button */\n size?: 'small' | 'medium' | 'large';\n /** If the button is doing something Async, it will display a loading spinner */\n isLoading?: boolean;\n /** Whether the button is in disabled state */\n isDisabled?: boolean;\n /** If the button is opened */\n isOpen: boolean;\n /** Callback function to be called when the button is clicked */\n onClick?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /**\n * A string that will be shown as a tooltip when hovering over the button. It also acts as an aria-label.\n * {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label}\n */\n description: string | null;\n /**\n * Props for the tooltip component.\n */\n tooltipProps?: TooltipObjectProps;\n};\n\nexport const SelectIconButton = ({\n children,\n size = 'medium',\n isDisabled = false,\n isLoading = false,\n isOpen = false,\n className,\n description,\n tooltipProps,\n onClick,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'button', SelectIconButtonProps>) => {\n const classes = classNames('ndl-select-icon-btn', className, {\n 'ndl-active': isOpen,\n 'ndl-disabled': isDisabled,\n 'ndl-large': size === 'large',\n 'ndl-loading': isLoading,\n 'ndl-medium': size === 'medium',\n 'ndl-small': size === 'small',\n });\n\n const isInteractable = !isDisabled && !isLoading;\n\n return (\n <Tooltip\n hoverDelay={{\n close: 0,\n open: 500,\n }}\n {...tooltipProps?.root}\n type=\"simple\"\n // We disable the tooltip if the button is disabled or open, so it doesn't interfere with a menu open\n isDisabled={description === null || isDisabled || isOpen === true}\n >\n <Tooltip.Trigger {...tooltipProps?.trigger} hasButtonWrapper>\n <button\n type=\"button\"\n ref={ref}\n className={classes}\n style={style}\n disabled={!isInteractable}\n aria-disabled={!isInteractable}\n aria-label={description ?? undefined}\n aria-expanded={isOpen}\n onClick={onClick}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-select-icon-btn-inner\">\n {isLoading ? (\n <LoadingSpinner size=\"small\" />\n ) : (\n <div className=\"ndl-icon\">{children}</div>\n )}\n </div>\n\n <ChevronDownIconOutline\n className={classNames('ndl-select-icon-btn-icon', {\n 'ndl-select-icon-btn-icon-open': isOpen === true,\n })}\n />\n </button>\n </Tooltip.Trigger>\n <Tooltip.Content {...tooltipProps?.content}>\n {description}\n </Tooltip.Content>\n </Tooltip>\n );\n};\n"]}
@@ -258,7 +258,7 @@ const CategoryItem = (_a) => {
258
258
  }, children: (0, jsx_runtime_1.jsx)(conditional_wrap_1.ConditionalWrap, { shouldWrap: isExpanded === false && !shouldOverlayOnInteraction && Boolean(label), wrap: (children) => ((0, jsx_runtime_1.jsxs)(tooltip_1.Tooltip, { type: "simple", placement: "top", hoverDelay: {
259
259
  close: 0,
260
260
  open: shouldOverlayOnInteraction ? 100 : 0,
261
- }, isOpen: isTooltipOpen, onOpenChange: setIsTooltipOpen, children: [(0, jsx_runtime_1.jsx)(tooltip_1.Tooltip.Trigger, { hasButtonWrapper: true, children: children }), (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip.Content, { className: "ndl-side-nav ndl-side-nav-category-menu-tooltip-content", children: label })] })), children: (0, jsx_runtime_1.jsxs)(react_1.CompositeItem, { render: (0, jsx_runtime_1.jsx)("button", Object.assign({}, refInteractions.getReferenceProps(Object.assign(Object.assign({ className: classes, ref: mergedRef, style }, restProps), htmlAttributes)), {
261
+ }, isOpen: isTooltipOpen, onOpenChange: setIsTooltipOpen, children: [(0, jsx_runtime_1.jsx)(tooltip_1.Tooltip.Trigger, { hasButtonWrapper: true, children: children }), (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip.Content, { className: "ndl-side-nav ndl-side-nav-category-menu-tooltip-content", children: label })] })), children: (0, jsx_runtime_1.jsxs)(react_1.CompositeItem, { render: (0, jsx_runtime_1.jsx)("button", Object.assign({ type: "button" }, refInteractions.getReferenceProps(Object.assign(Object.assign({ className: classes, ref: mergedRef, style }, restProps), htmlAttributes)), {
262
262
  // {...restProps}
263
263
  // {...htmlAttributes}
264
264
  role: "menuitem", "aria-haspopup": "menu", "aria-expanded": context.open, "aria-controls": floatingId, onFocus: (e) => {