@neo4j-ndl/react 4.21.2 → 4.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/_common/form-control/FormFieldLabel.js +52 -0
- package/lib/cjs/_common/form-control/FormFieldLabel.js.map +1 -0
- package/lib/cjs/_common/form-control/FormFieldMessage.js +72 -0
- package/lib/cjs/_common/form-control/FormFieldMessage.js.map +1 -0
- package/lib/cjs/_common/form-control/form-control-types.js +23 -0
- package/lib/cjs/_common/form-control/form-control-types.js.map +1 -0
- package/lib/cjs/_common/form-control/index.js +39 -0
- package/lib/cjs/_common/form-control/index.js.map +1 -0
- package/lib/cjs/_common/form-control/use-form-field.js +76 -0
- package/lib/cjs/_common/form-control/use-form-field.js.map +1 -0
- package/lib/cjs/_common/form-control/use-inline-field-label.js +76 -0
- package/lib/cjs/_common/form-control/use-inline-field-label.js.map +1 -0
- package/lib/cjs/checkbox/Checkbox.js +9 -21
- package/lib/cjs/checkbox/Checkbox.js.map +1 -1
- package/lib/cjs/combobox/Combobox.js +61 -45
- package/lib/cjs/combobox/Combobox.js.map +1 -1
- package/lib/cjs/combobox/combobox-types.js.map +1 -1
- package/lib/cjs/date-picker/DatePicker.js.map +1 -1
- package/lib/cjs/dropzone/stories/dropzone-full.story.js +5 -5
- package/lib/cjs/dropzone/stories/dropzone-full.story.js.map +1 -1
- package/lib/cjs/helpers/index.js +1 -0
- package/lib/cjs/helpers/index.js.map +1 -1
- package/lib/cjs/helpers/platform.js +59 -0
- package/lib/cjs/helpers/platform.js.map +1 -0
- package/lib/cjs/kbd/kbd-utils.js +6 -22
- package/lib/cjs/kbd/kbd-utils.js.map +1 -1
- package/lib/cjs/next/tree-view/TreeView.js +384 -66
- package/lib/cjs/next/tree-view/TreeView.js.map +1 -1
- package/lib/cjs/next/tree-view/selection.js +181 -0
- package/lib/cjs/next/tree-view/selection.js.map +1 -0
- package/lib/cjs/next/tree-view/stories/index.js +13 -1
- package/lib/cjs/next/tree-view/stories/index.js.map +1 -1
- package/lib/cjs/next/tree-view/stories/tree-view-large.story.js +57 -0
- package/lib/cjs/next/tree-view/stories/tree-view-large.story.js.map +1 -0
- package/lib/cjs/next/tree-view/stories/tree-view-lazy.story.js +1 -0
- package/lib/cjs/next/tree-view/stories/tree-view-lazy.story.js.map +1 -1
- package/lib/cjs/next/tree-view/stories/tree-view-multi.story.js +16 -40
- package/lib/cjs/next/tree-view/stories/tree-view-multi.story.js.map +1 -1
- package/lib/cjs/next/tree-view/stories/tree-view-multiple-replace.story.js +38 -0
- package/lib/cjs/next/tree-view/stories/tree-view-multiple-replace.story.js.map +1 -0
- package/lib/cjs/next/tree-view/stories/tree-view-non-selectable-folders.story.js +7 -4
- package/lib/cjs/next/tree-view/stories/tree-view-non-selectable-folders.story.js.map +1 -1
- package/lib/cjs/next/tree-view/stories/tree-view-root-selection.story.js +125 -0
- package/lib/cjs/next/tree-view/stories/tree-view-root-selection.story.js.map +1 -0
- package/lib/cjs/radio/Radio.js +12 -22
- package/lib/cjs/radio/Radio.js.map +1 -1
- package/lib/cjs/select/Select.js +14 -5
- package/lib/cjs/select/Select.js.map +1 -1
- package/lib/cjs/select/types.js.map +1 -1
- package/lib/cjs/switch/Switch.js +9 -21
- package/lib/cjs/switch/Switch.js.map +1 -1
- package/lib/cjs/text-area/TextArea.js +8 -21
- package/lib/cjs/text-area/TextArea.js.map +1 -1
- package/lib/cjs/text-input/TextInput.js +15 -38
- package/lib/cjs/text-input/TextInput.js.map +1 -1
- package/lib/cjs/text-input/stories/text-input-sizes.story.js +1 -1
- package/lib/cjs/text-input/stories/text-input-sizes.story.js.map +1 -1
- package/lib/cjs/time-picker/TimePicker.js +13 -7
- package/lib/cjs/time-picker/TimePicker.js.map +1 -1
- package/lib/cjs/timezone-picker/TimeZonePicker.js +13 -7
- package/lib/cjs/timezone-picker/TimeZonePicker.js.map +1 -1
- package/lib/cjs/toast/ToastControlled.js +1 -1
- package/lib/cjs/toast/ToastControlled.js.map +1 -1
- package/lib/esm/_common/form-control/FormFieldLabel.js +45 -0
- package/lib/esm/_common/form-control/FormFieldLabel.js.map +1 -0
- package/lib/esm/_common/form-control/FormFieldMessage.js +65 -0
- package/lib/esm/_common/form-control/FormFieldMessage.js.map +1 -0
- package/lib/esm/_common/form-control/form-control-types.js +22 -0
- package/lib/esm/_common/form-control/form-control-types.js.map +1 -0
- package/lib/esm/_common/form-control/index.js +32 -0
- package/lib/esm/_common/form-control/index.js.map +1 -0
- package/lib/esm/_common/form-control/use-form-field.js +72 -0
- package/lib/esm/_common/form-control/use-form-field.js.map +1 -0
- package/lib/esm/_common/form-control/use-inline-field-label.js +69 -0
- package/lib/esm/_common/form-control/use-inline-field-label.js.map +1 -0
- package/lib/esm/checkbox/Checkbox.js +10 -22
- package/lib/esm/checkbox/Checkbox.js.map +1 -1
- package/lib/esm/combobox/Combobox.js +62 -46
- package/lib/esm/combobox/Combobox.js.map +1 -1
- package/lib/esm/combobox/combobox-types.js.map +1 -1
- package/lib/esm/date-picker/DatePicker.js.map +1 -1
- package/lib/esm/dropzone/stories/dropzone-full.story.js +5 -5
- package/lib/esm/dropzone/stories/dropzone-full.story.js.map +1 -1
- package/lib/esm/helpers/index.js +1 -0
- package/lib/esm/helpers/index.js.map +1 -1
- package/lib/esm/helpers/platform.js +55 -0
- package/lib/esm/helpers/platform.js.map +1 -0
- package/lib/esm/kbd/kbd-utils.js +2 -18
- package/lib/esm/kbd/kbd-utils.js.map +1 -1
- package/lib/esm/next/tree-view/TreeView.js +385 -67
- package/lib/esm/next/tree-view/TreeView.js.map +1 -1
- package/lib/esm/next/tree-view/selection.js +175 -0
- package/lib/esm/next/tree-view/selection.js.map +1 -0
- package/lib/esm/next/tree-view/stories/index.js +9 -0
- package/lib/esm/next/tree-view/stories/index.js.map +1 -1
- package/lib/esm/next/tree-view/stories/tree-view-large.story.js +55 -0
- package/lib/esm/next/tree-view/stories/tree-view-large.story.js.map +1 -0
- package/lib/esm/next/tree-view/stories/tree-view-lazy.story.js +1 -0
- package/lib/esm/next/tree-view/stories/tree-view-lazy.story.js.map +1 -1
- package/lib/esm/next/tree-view/stories/tree-view-multi.story.js +16 -40
- package/lib/esm/next/tree-view/stories/tree-view-multi.story.js.map +1 -1
- package/lib/esm/next/tree-view/stories/tree-view-multiple-replace.story.js +36 -0
- package/lib/esm/next/tree-view/stories/tree-view-multiple-replace.story.js.map +1 -0
- package/lib/esm/next/tree-view/stories/tree-view-non-selectable-folders.story.js +7 -4
- package/lib/esm/next/tree-view/stories/tree-view-non-selectable-folders.story.js.map +1 -1
- package/lib/esm/next/tree-view/stories/tree-view-root-selection.story.js +123 -0
- package/lib/esm/next/tree-view/stories/tree-view-root-selection.story.js.map +1 -0
- package/lib/esm/radio/Radio.js +12 -22
- package/lib/esm/radio/Radio.js.map +1 -1
- package/lib/esm/select/Select.js +14 -5
- package/lib/esm/select/Select.js.map +1 -1
- package/lib/esm/select/types.js.map +1 -1
- package/lib/esm/switch/Switch.js +10 -22
- package/lib/esm/switch/Switch.js.map +1 -1
- package/lib/esm/text-area/TextArea.js +9 -22
- package/lib/esm/text-area/TextArea.js.map +1 -1
- package/lib/esm/text-input/TextInput.js +15 -38
- package/lib/esm/text-input/TextInput.js.map +1 -1
- package/lib/esm/text-input/stories/text-input-sizes.story.js +1 -1
- package/lib/esm/text-input/stories/text-input-sizes.story.js.map +1 -1
- package/lib/esm/time-picker/TimePicker.js +13 -7
- package/lib/esm/time-picker/TimePicker.js.map +1 -1
- package/lib/esm/timezone-picker/TimeZonePicker.js +13 -7
- package/lib/esm/timezone-picker/TimeZonePicker.js.map +1 -1
- package/lib/esm/toast/ToastControlled.js +1 -1
- package/lib/esm/toast/ToastControlled.js.map +1 -1
- package/lib/types/_common/form-control/FormFieldLabel.d.ts +58 -0
- package/lib/types/_common/form-control/FormFieldLabel.d.ts.map +1 -0
- package/lib/types/_common/form-control/FormFieldMessage.d.ts +46 -0
- package/lib/types/_common/form-control/FormFieldMessage.d.ts.map +1 -0
- package/lib/types/_common/form-control/form-control-types.d.ts +92 -0
- package/lib/types/_common/form-control/form-control-types.d.ts.map +1 -0
- package/lib/types/_common/form-control/index.d.ts +33 -0
- package/lib/types/_common/form-control/index.d.ts.map +1 -0
- package/lib/types/_common/form-control/use-form-field.d.ts +53 -0
- package/lib/types/_common/form-control/use-form-field.d.ts.map +1 -0
- package/lib/types/_common/form-control/use-inline-field-label.d.ts +69 -0
- package/lib/types/_common/form-control/use-inline-field-label.d.ts.map +1 -0
- package/lib/types/checkbox/Checkbox.d.ts.map +1 -1
- package/lib/types/combobox/Combobox.d.ts.map +1 -1
- package/lib/types/combobox/combobox-types.d.ts +1 -1
- package/lib/types/combobox/combobox-types.d.ts.map +1 -1
- package/lib/types/helpers/index.d.ts +1 -0
- package/lib/types/helpers/index.d.ts.map +1 -1
- package/lib/types/helpers/platform.d.ts +29 -0
- package/lib/types/helpers/platform.d.ts.map +1 -0
- package/lib/types/kbd/kbd-utils.d.ts +2 -5
- package/lib/types/kbd/kbd-utils.d.ts.map +1 -1
- package/lib/types/next/tree-view/TreeView.d.ts +29 -5
- package/lib/types/next/tree-view/TreeView.d.ts.map +1 -1
- package/lib/types/next/tree-view/selection.d.ts +78 -0
- package/lib/types/next/tree-view/selection.d.ts.map +1 -0
- package/lib/types/next/tree-view/stories/index.d.ts +6 -0
- package/lib/types/next/tree-view/stories/index.d.ts.map +1 -1
- package/lib/types/next/tree-view/stories/tree-view-large.story.d.ts +24 -0
- package/lib/types/next/tree-view/stories/tree-view-large.story.d.ts.map +1 -0
- package/lib/types/next/tree-view/stories/tree-view-lazy.story.d.ts.map +1 -1
- package/lib/types/next/tree-view/stories/tree-view-multi.story.d.ts +10 -0
- package/lib/types/next/tree-view/stories/tree-view-multi.story.d.ts.map +1 -1
- package/lib/types/next/tree-view/stories/tree-view-multiple-replace.story.d.ts +29 -0
- package/lib/types/next/tree-view/stories/tree-view-multiple-replace.story.d.ts.map +1 -0
- package/lib/types/next/tree-view/stories/tree-view-non-selectable-folders.story.d.ts +5 -0
- package/lib/types/next/tree-view/stories/tree-view-non-selectable-folders.story.d.ts.map +1 -1
- package/lib/types/next/tree-view/stories/tree-view-root-selection.story.d.ts +24 -0
- package/lib/types/next/tree-view/stories/tree-view-root-selection.story.d.ts.map +1 -0
- package/lib/types/radio/Radio.d.ts.map +1 -1
- package/lib/types/select/Select.d.ts.map +1 -1
- package/lib/types/select/types.d.ts.map +1 -1
- package/lib/types/switch/Switch.d.ts.map +1 -1
- package/lib/types/text-area/TextArea.d.ts.map +1 -1
- package/lib/types/text-input/TextInput.d.ts.map +1 -1
- package/lib/types/text-input/stories/text-input-sizes.story.d.ts.map +1 -1
- package/lib/types/time-picker/TimePicker.d.ts +3 -1
- package/lib/types/time-picker/TimePicker.d.ts.map +1 -1
- package/lib/types/timezone-picker/TimeZonePicker.d.ts +4 -1
- package/lib/types/timezone-picker/TimeZonePicker.d.ts.map +1 -1
- package/package.json +2 -2
- package/skills/ndl-react/SKILL.md +1 -1
- package/skills/ndl-react/components/color-picker.md +32 -32
- package/skills/ndl-react/components/combobox.md +2 -2
- package/skills/ndl-react/components/dropzone.md +5 -5
- package/skills/ndl-react/components/next/tree-view.md +444 -104
- package/skills/ndl-react/components/text-input.md +6 -0
- package/skills/ndl-react/components/time-picker.md +1 -0
- package/skills/ndl-react/components/timezone-picker.md +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox-types.js","sourceRoot":"","sources":["../../../src/combobox/combobox-types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG","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 */\n\ntype ComboboxOption = {\n label: string;\n value: string;\n /** If the option is disabled */\n isDisabled?: boolean;\n /** A visual element to display before the label. Incompatible with multi select. */\n leadingVisual?: React.ReactNode;\n /** A description to display below the label. */\n description?: string;\n};\n\ntype ComboboxOptionGroup<TOption extends ComboboxOption = ComboboxOption> = {\n label: string;\n options: TOption[];\n};\n\ntype ComboboxFilterOption<TOption extends ComboboxOption = ComboboxOption> =\n | ((option: TOption, searchValue: string) => boolean)\n | false;\n\ntype ComboboxSize = 'small' | 'medium' | 'large';\n\n/**\n * A row at the end of the panel that acts instead of selecting.\n *\n * @remarks\n * Deliberately not a `ComboboxOption`, since an action never becomes part of\n * the value. Use it for something that leads out of the selection, such as a\n * link into a create flow.\n */\ntype ComboboxAction = {\n /** Text of the row. */\n label: string;\n /**\n * Called when the row is activated, with the current search value so the\n * action can carry the query with it. The selection is left untouched.\n */\n onSelect: (context: { searchValue: string }) => void;\n /** A description to display below the label. */\n description?: string;\n /** A visual element to display before the label. */\n leadingVisual?: React.ReactNode;\n /** If the action is disabled. */\n isDisabled?: boolean;\n /**\n * Whether a divider is rendered above the action, separating it from the\n * action before it. Ignored on the first action, which already sits below\n * the divider that separates actions from options.\n */\n hasDivider?: boolean;\n};\n\ntype ComboboxBaseProps<TOption extends ComboboxOption = ComboboxOption> = {\n /** Accessible label for the combobox. Rendered above the control. */\n label: string;\n /**\n * Name used to submit the selected option value through a native form.\n * Above 300 options, only the selection is mirrored to the form, so browser\n * autofill no longer offers the option list.\n */\n name?: string;\n /** Id of the form the combobox belongs to when it is outside that form. */\n formId?: string;\n /** Hint for browser autofill on the native form control. */\n autoComplete?: string;\n /** Ref to the focusable combobox trigger. */\n triggerRef?: React.Ref<HTMLElement>;\n /** Whether the label is clipped out of the layout, leaving it to screen readers only. */\n hasVisuallyHiddenLabel?: boolean;\n /** Assistive text below the control. Replaced by `errorText` while there is an error. */\n helpText?: React.ReactNode;\n /** Error message below the control. Puts the control in its error state. */\n errorText?: React.ReactNode;\n /**\n * Whether a selection is required. Sets `aria-required` and, when `name` is\n * provided, enables native form validation.\n */\n isRequired?: boolean;\n /** Whether Required or Optional is shown at the end of the label row. */\n hasRequiredIndicator?: boolean;\n /** The options to display in the combobox. Either an array of options or an array of option groups. */\n options: TOption[] | ComboboxOptionGroup<TOption>[];\n /**\n * Whether a search input is rendered inside the panel. On by default; turn\n * it off for a short list (roughly 10 options or fewer) where filtering\n * adds nothing.\n */\n isSearchable?: boolean;\n /** The search value in controlled mode. */\n searchValue?: string;\n /** The initial search value in uncontrolled mode. */\n defaultSearchValue?: string;\n /** Called when the search value changes. */\n onSearchChange?: (searchValue: string) => void;\n /**\n * How options are matched against the search value. Defaults to a\n * case-insensitive match on the option label. Pass `false` to skip internal\n * filtering when the options are already filtered, such as when searching\n * server side.\n */\n filterOption?: ComboboxFilterOption<TOption>;\n /** Placeholder for the search input, which also names it. */\n searchPlaceholder?: string;\n /**\n * Whether the panel is waiting for options. Replaces the empty message while\n * there are no options.\n */\n isLoading?: boolean;\n /** Text of the loading status. Defaults to `Loading...`. */\n loadingMessage?: React.ReactNode;\n /**\n * Whether the search value can be turned into a new option, shown as an extra\n * row at the end of the list. Requires `isSearchable`.\n */\n isCreatable?: boolean;\n /**\n * Called after a created option has been selected, so it can be persisted\n * into `options`. Created options are not added to `options` by the combobox.\n */\n onCreateOption?: (option: TOption) => void;\n /**\n * Builds the option to create from the search value. Defaults to using the\n * search value as both label and value, which is only enough when the options\n * carry no fields of their own beyond `ComboboxOption`.\n */\n createOption?: (searchValue: string) => TOption;\n /** Text of the create row. Defaults to `Create \"<search value>\"`. */\n formatCreateLabel?: (searchValue: string) => React.ReactNode;\n /**\n * Whether the search value can become a new option. Defaults to requiring a\n * non-blank value that does not exactly match an existing option or a\n * currently selected one.\n */\n isValidNewOption?: (searchValue: string, options: TOption[]) => boolean;\n /**\n * Rows that act instead of selecting, pinned below the scrolling options\n * after a divider so they stay visible however long the list is. They are\n * always shown, never filtered by the search value, and never part of the\n * selection.\n */\n actions?: ComboboxAction[];\n /** Whether the panel is controlled open. */\n isOpen?: boolean;\n /** Called when the panel opens or closes. */\n onOpenChange?: (isOpen: boolean) => void;\n /** Whether a button for clearing the selection is rendered in the trigger. */\n isClearable?: boolean;\n /** Text shown in the trigger while nothing is selected. */\n placeholder?: string;\n /** Whether the combobox is disabled. */\n isDisabled?: boolean;\n /** Size of the combobox control. */\n size?: ComboboxSize;\n /** Whether the combobox fills the available width. */\n isFluid?: boolean;\n /** Whether the control hugs its content without a background or resting outline. */\n isClean?: boolean;\n /** Whether the panel is wrapped in a floating portal. Defaults to true outside a dialog. */\n isPortaled?: boolean;\n /** Portal target element. Defaults to `document.body`. */\n portalTarget?: HTMLElement | null;\n /** Positioning strategy used by Floating UI. */\n floatingStrategy?: 'absolute' | 'fixed';\n /**\n * Replaces the built-in trigger. Spread `triggerProps` onto the focusable\n * element that should open the panel; the panel is anchored to it. The root\n * element then lays out as `display: contents`, so the trigger is placed by\n * whatever contains the combobox, and `isFluid`, `isClean`, `size`,\n * `className` and `style` no longer shape it.\n */\n renderTrigger?: (\n triggerProps: ComboboxTriggerProps,\n state: ComboboxTriggerState<TOption>,\n ) => React.ReactNode;\n /**\n * Replaces how selected values and option labels are presented, keeping the\n * behavior and the ARIA of the combobox.\n */\n components?: ComboboxComponents<TOption>;\n};\n\n/**\n * Presentation overrides for the parts of the combobox that show an option.\n *\n * @remarks\n * Each override is handed the option itself, so widening the option type is\n * what gives them typed access to fields of your own, such as a color. Only\n * presentation is replaced; selection, filtering, keyboard interaction and the\n * ARIA of the surrounding elements stay with the combobox. Use `renderTrigger`\n * instead to replace the control as a whole.\n */\ntype ComboboxComponents<TOption extends ComboboxOption = ComboboxOption> = {\n /** Replaces the tag rendered per selected option in multi select. */\n MultiValue?: React.ComponentType<ComboboxMultiValueProps<TOption>>;\n /** Replaces the value shown in the trigger in single select. Must be non-interactive. */\n SingleValue?: React.ComponentType<ComboboxSingleValueProps<TOption>>;\n /** Replaces the label of an option. The selection and description chrome stays. */\n OptionLabel?: React.ComponentType<ComboboxOptionLabelProps<TOption>>;\n};\n\n/** Props of a `MultiValue` override, rendered once per selected option. */\ntype ComboboxMultiValueProps<TOption extends ComboboxOption = ComboboxOption> =\n {\n option: TOption;\n /** Position of the option in the selection. */\n index: number;\n isDisabled: boolean;\n size: ComboboxSize;\n /**\n * Deselects this option. Nothing calls it unless the override renders an\n * affordance for it, which also makes focus after the removal its own\n * responsibility.\n */\n remove: () => void;\n };\n\n/** Props of a `SingleValue` override, rendered inside the trigger. */\ntype ComboboxSingleValueProps<TOption extends ComboboxOption = ComboboxOption> =\n {\n option: TOption;\n isDisabled: boolean;\n size: ComboboxSize;\n };\n\n/** Props of an `OptionLabel` override, rendered inside each option. */\ntype ComboboxOptionLabelProps<TOption extends ComboboxOption = ComboboxOption> =\n {\n option: TOption;\n isSelected: boolean;\n isDisabled: boolean;\n /** Whether the option currently holds virtual focus. */\n isFocused: boolean;\n isMulti: boolean;\n size: ComboboxSize;\n };\n\n/**\n * Props that must be spread onto a custom trigger element. Includes the\n * Floating UI reference props, so the element it lands on becomes the anchor\n * the panel is positioned against.\n */\ntype ComboboxTriggerProps = React.HTMLAttributes<HTMLElement> & {\n ref: React.Ref<HTMLElement>;\n role: 'combobox';\n 'aria-haspopup': 'dialog' | 'listbox';\n // These are DOM attribute names, so the boolean naming convention cannot apply.\n /* eslint-disable @typescript-eslint/naming-convention */\n 'aria-expanded': boolean;\n 'aria-disabled': boolean | undefined;\n 'aria-invalid': boolean | undefined;\n 'aria-required': boolean | undefined;\n /* eslint-enable @typescript-eslint/naming-convention */\n 'aria-controls': string | undefined;\n 'aria-activedescendant': string | undefined;\n 'aria-describedby': string | undefined;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n};\n\n/**\n * The label, help text, and error text of the combobox, for rendering them from\n * a custom trigger.\n *\n * @remarks\n * A custom trigger is named through `aria-label` and carries the\n * `aria-describedby` of whichever message is currently shown, so it has to\n * render that message with the id it is handed here.\n */\ntype ComboboxFieldState = {\n label: string;\n hasVisuallyHiddenLabel: boolean;\n helpText?: React.ReactNode;\n errorText?: React.ReactNode;\n hasError: boolean;\n isRequired: boolean;\n hasRequiredIndicator: boolean;\n /** Id the trigger's `aria-labelledby` points at when the label is rendered. */\n labelId: string;\n /** Id of the trigger, so a rendered `<label>` can point at it with `htmlFor`. */\n triggerId: string;\n /** Ids the trigger's `aria-describedby` points at. Only one is used at a time. */\n helpTextId: string;\n errorTextId: string;\n};\n\n/** Current combobox state, for rendering a custom trigger. */\ntype ComboboxTriggerState<TOption extends ComboboxOption = ComboboxOption> = {\n isOpen: boolean;\n isMulti: boolean;\n isDisabled: boolean;\n /** The selected options, as a list in both single and multi select. */\n selectedOptions: TOption[];\n /** Clears the whole selection. */\n clear: () => void;\n /** Deselects a single option. */\n remove: (option: TOption) => void;\n /** The label and messages of the combobox, so a custom trigger can present them. */\n field: ComboboxFieldState;\n};\n\ntype ComboboxSingleProps<TOption extends ComboboxOption = ComboboxOption> = {\n /** The selected option in controlled mode. */\n value?: TOption | null;\n /** The initially selected option in uncontrolled mode. */\n defaultValue?: TOption | null;\n /** Called when the selected option changes. `null` when the selection is cleared. */\n onChange?: (value: TOption | null) => void;\n /** Whether multiple options can be selected. */\n isMulti?: false;\n maxRows?: never;\n};\n\ntype ComboboxMultiProps<TOption extends ComboboxOption = ComboboxOption> = {\n /** The selected options in controlled mode. */\n value?: TOption[];\n /** The initially selected options in uncontrolled mode. */\n defaultValue?: TOption[];\n /** Called when the selected options change. */\n onChange?: (value: TOption[]) => void;\n /** Whether multiple options can be selected. */\n isMulti: true;\n /**\n * Maximum number of rows the selected tags may wrap into, a single row by\n * default. Tags that do not fit are collapsed into a read-only counter tag,\n * such as `+4`, at the end of the last row. Pass `null` to let the control\n * grow with the selection.\n */\n maxRows?: number | null;\n};\n\ntype ComboboxProps<TOption extends ComboboxOption = ComboboxOption> =\n ComboboxBaseProps<TOption> &\n (ComboboxSingleProps<TOption> | ComboboxMultiProps<TOption>);\n\ntype ComboboxPanelProps = {\n children?: React.ReactNode;\n ref?: React.Ref<HTMLDivElement>;\n id?: string;\n className?: string;\n style?: React.CSSProperties;\n /**\n * Set when the panel is a dialog popup, which is the case while the search\n * input inside it holds DOM focus.\n */\n ariaLabel?: string;\n isDialog?: boolean;\n} & Record<string, unknown>;\n\ntype ComboboxControlProps<TOption extends ComboboxOption = ComboboxOption> = {\n triggerProps: ComboboxTriggerProps;\n state: ComboboxTriggerState<TOption>;\n field: ComboboxFieldState;\n placeholder: string;\n isClearable: boolean;\n isClean: boolean;\n size: ComboboxSize;\n /** Maximum number of rows the selected tags may wrap into in multi select. `null` is unlimited. */\n maxRows?: number | null;\n components: ComboboxComponents<TOption>;\n /** Floating UI reference props, so clicking anywhere in the control opens the panel. */\n referenceProps: React.HTMLAttributes<HTMLDivElement>;\n referenceRef: React.Ref<HTMLDivElement>;\n};\n\ntype ComboboxEmptyStateProps = {\n children?: React.ReactNode;\n};\n\ntype ComboboxInputProps = {\n ref?: React.Ref<HTMLInputElement>;\n ariaLabel: string;\n value: string;\n onValueChange: (searchValue: string) => void;\n placeholder?: string;\n /** Id of the listbox the input controls, when the listbox is rendered. */\n listboxId?: string;\n /** Id of the virtually focused option, when one is active. */\n activeOptionId?: string;\n onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;\n};\n\ntype ComboboxListBoxProps = {\n ariaLabel: string;\n children?: React.ReactNode;\n isMulti?: boolean;\n id?: string;\n /** Ids of the pinned action rows the listbox owns without containing. */\n ownsIds?: string;\n};\n\ntype ComboboxGroupProps = {\n children?: React.ReactNode;\n label: string;\n};\n\ntype ComboboxOptionProps = {\n children?: React.ReactNode;\n /** Left out on rows that cannot be selected, which drops `aria-selected`. */\n isSelected?: boolean;\n isDisabled?: boolean;\n isFocused?: boolean;\n /** Whether the option is the row that creates a new option from the search value. */\n isCreate?: boolean;\n /** Whether the option is an action row, which acts instead of selecting. */\n isAction?: boolean;\n id?: string;\n onClick?: () => void;\n /** Called when the pointer moves over the option, so hover can drive virtual focus. */\n onHover?: () => void;\n /**\n * One-based position in the full list. Only set while the listbox is\n * virtualized, where the DOM no longer holds every option.\n */\n posInSet?: number;\n /** Total options in the full list. Only set while the listbox is virtualized. */\n setSize?: number;\n};\n\ntype ComboboxOptionContentProps = {\n label: string;\n /**\n * Replaces the label text. Rendered in place of the label typography rather\n * than inside it, so it can be any element rather than inline text.\n */\n customLabel?: React.ReactNode;\n description?: string;\n leadingVisual?: React.ReactNode;\n isDisabled?: boolean;\n isSelected?: boolean;\n isMulti?: boolean;\n};\n\nexport type {\n ComboboxProps,\n ComboboxAction,\n ComboboxComponents,\n ComboboxControlProps,\n ComboboxFieldState,\n ComboboxMultiValueProps,\n ComboboxOptionLabelProps,\n ComboboxSingleValueProps,\n ComboboxTriggerProps,\n ComboboxTriggerState,\n ComboboxPanelProps,\n ComboboxEmptyStateProps,\n ComboboxFilterOption,\n ComboboxInputProps,\n ComboboxListBoxProps,\n ComboboxGroupProps,\n ComboboxOptionProps,\n ComboboxOptionContentProps,\n ComboboxOption,\n ComboboxOptionGroup,\n ComboboxSize,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"combobox-types.js","sourceRoot":"","sources":["../../../src/combobox/combobox-types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG","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 */\n\ntype ComboboxOption = {\n label: string;\n value: string;\n /** If the option is disabled */\n isDisabled?: boolean;\n /** A visual element to display before the label. Incompatible with multi select. */\n leadingVisual?: React.ReactNode;\n /** A description to display below the label. */\n description?: string;\n};\n\ntype ComboboxOptionGroup<TOption extends ComboboxOption = ComboboxOption> = {\n label: string;\n options: TOption[];\n};\n\ntype ComboboxFilterOption<TOption extends ComboboxOption = ComboboxOption> =\n | ((option: TOption, searchValue: string) => boolean)\n | false;\n\ntype ComboboxSize = 'small' | 'medium' | 'large';\n\n/**\n * A row at the end of the panel that acts instead of selecting.\n *\n * @remarks\n * Deliberately not a `ComboboxOption`, since an action never becomes part of\n * the value. Use it for something that leads out of the selection, such as a\n * link into a create flow.\n */\ntype ComboboxAction = {\n /** Text of the row. */\n label: string;\n /**\n * Called when the row is activated, with the current search value so the\n * action can carry the query with it. The selection is left untouched.\n */\n onSelect: (context: { searchValue: string }) => void;\n /** A description to display below the label. */\n description?: string;\n /** A visual element to display before the label. */\n leadingVisual?: React.ReactNode;\n /** If the action is disabled. */\n isDisabled?: boolean;\n /**\n * Whether a divider is rendered above the action, separating it from the\n * action before it. Ignored on the first action, which already sits below\n * the divider that separates actions from options.\n */\n hasDivider?: boolean;\n};\n\ntype ComboboxBaseProps<TOption extends ComboboxOption = ComboboxOption> = {\n /** Accessible label for the combobox. Rendered above the control. */\n label: string;\n /**\n * Name used to submit the selected option value through a native form.\n * Above 300 options, only the selection is mirrored to the form, so browser\n * autofill no longer offers the option list.\n */\n name?: string;\n /** Id of the form the combobox belongs to when it is outside that form. */\n formId?: string;\n /** Hint for browser autofill on the native form control. */\n autoComplete?: string;\n /** Ref to the focusable combobox trigger. */\n triggerRef?: React.Ref<HTMLElement>;\n /** Whether the label is clipped out of the layout, leaving it to screen readers only. */\n hasVisuallyHiddenLabel?: boolean;\n /** Assistive text below the control. Replaced by `errorText` while there is an error. */\n helpText?: React.ReactNode;\n /** Error message below the control. Puts the control in its error state. */\n errorText?: React.ReactNode;\n /**\n * Whether a selection is required. Sets `aria-required` and, when `name` is\n * provided, enables native form validation.\n */\n isRequired?: boolean;\n /** Whether Required or Optional is shown at the end of the label row, based on the `isRequired` prop */\n hasRequiredIndicator?: boolean;\n /** The options to display in the combobox. Either an array of options or an array of option groups. */\n options: TOption[] | ComboboxOptionGroup<TOption>[];\n /**\n * Whether a search input is rendered inside the panel. On by default; turn\n * it off for a short list (roughly 10 options or fewer) where filtering\n * adds nothing.\n */\n isSearchable?: boolean;\n /** The search value in controlled mode. */\n searchValue?: string;\n /** The initial search value in uncontrolled mode. */\n defaultSearchValue?: string;\n /** Called when the search value changes. */\n onSearchChange?: (searchValue: string) => void;\n /**\n * How options are matched against the search value. Defaults to a\n * case-insensitive match on the option label. Pass `false` to skip internal\n * filtering when the options are already filtered, such as when searching\n * server side.\n */\n filterOption?: ComboboxFilterOption<TOption>;\n /** Placeholder for the search input, which also names it. */\n searchPlaceholder?: string;\n /**\n * Whether the panel is waiting for options. Replaces the empty message while\n * there are no options.\n */\n isLoading?: boolean;\n /** Text of the loading status. Defaults to `Loading...`. */\n loadingMessage?: React.ReactNode;\n /**\n * Whether the search value can be turned into a new option, shown as an extra\n * row at the end of the list. Requires `isSearchable`.\n */\n isCreatable?: boolean;\n /**\n * Called after a created option has been selected, so it can be persisted\n * into `options`. Created options are not added to `options` by the combobox.\n */\n onCreateOption?: (option: TOption) => void;\n /**\n * Builds the option to create from the search value. Defaults to using the\n * search value as both label and value, which is only enough when the options\n * carry no fields of their own beyond `ComboboxOption`.\n */\n createOption?: (searchValue: string) => TOption;\n /** Text of the create row. Defaults to `Create \"<search value>\"`. */\n formatCreateLabel?: (searchValue: string) => React.ReactNode;\n /**\n * Whether the search value can become a new option. Defaults to requiring a\n * non-blank value that does not exactly match an existing option or a\n * currently selected one.\n */\n isValidNewOption?: (searchValue: string, options: TOption[]) => boolean;\n /**\n * Rows that act instead of selecting, pinned below the scrolling options\n * after a divider so they stay visible however long the list is. They are\n * always shown, never filtered by the search value, and never part of the\n * selection.\n */\n actions?: ComboboxAction[];\n /** Whether the panel is controlled open. */\n isOpen?: boolean;\n /** Called when the panel opens or closes. */\n onOpenChange?: (isOpen: boolean) => void;\n /** Whether a button for clearing the selection is rendered in the trigger. */\n isClearable?: boolean;\n /** Text shown in the trigger while nothing is selected. */\n placeholder?: string;\n /** Whether the combobox is disabled. */\n isDisabled?: boolean;\n /** Size of the combobox control. */\n size?: ComboboxSize;\n /** Whether the combobox fills the available width. */\n isFluid?: boolean;\n /** Whether the control hugs its content without a background or resting outline. */\n isClean?: boolean;\n /** Whether the panel is wrapped in a floating portal. Defaults to true outside a dialog. */\n isPortaled?: boolean;\n /** Portal target element. Defaults to `document.body`. */\n portalTarget?: HTMLElement | null;\n /** Positioning strategy used by Floating UI. */\n floatingStrategy?: 'absolute' | 'fixed';\n /**\n * Replaces the built-in trigger. Spread `triggerProps` onto the focusable\n * element that should open the panel; the panel is anchored to it. The root\n * element then lays out as `display: contents`, so the trigger is placed by\n * whatever contains the combobox, and `isFluid`, `isClean`, `size`,\n * `className` and `style` no longer shape it.\n */\n renderTrigger?: (\n triggerProps: ComboboxTriggerProps,\n state: ComboboxTriggerState<TOption>,\n ) => React.ReactNode;\n /**\n * Replaces how selected values and option labels are presented, keeping the\n * behavior and the ARIA of the combobox.\n */\n components?: ComboboxComponents<TOption>;\n};\n\n/**\n * Presentation overrides for the parts of the combobox that show an option.\n *\n * @remarks\n * Each override is handed the option itself, so widening the option type is\n * what gives them typed access to fields of your own, such as a color. Only\n * presentation is replaced; selection, filtering, keyboard interaction and the\n * ARIA of the surrounding elements stay with the combobox. Use `renderTrigger`\n * instead to replace the control as a whole.\n */\ntype ComboboxComponents<TOption extends ComboboxOption = ComboboxOption> = {\n /** Replaces the tag rendered per selected option in multi select. */\n MultiValue?: React.ComponentType<ComboboxMultiValueProps<TOption>>;\n /** Replaces the value shown in the trigger in single select. Must be non-interactive. */\n SingleValue?: React.ComponentType<ComboboxSingleValueProps<TOption>>;\n /** Replaces the label of an option. The selection and description chrome stays. */\n OptionLabel?: React.ComponentType<ComboboxOptionLabelProps<TOption>>;\n};\n\n/** Props of a `MultiValue` override, rendered once per selected option. */\ntype ComboboxMultiValueProps<TOption extends ComboboxOption = ComboboxOption> =\n {\n option: TOption;\n /** Position of the option in the selection. */\n index: number;\n isDisabled: boolean;\n size: ComboboxSize;\n /**\n * Deselects this option. Nothing calls it unless the override renders an\n * affordance for it, which also makes focus after the removal its own\n * responsibility.\n */\n remove: () => void;\n };\n\n/** Props of a `SingleValue` override, rendered inside the trigger. */\ntype ComboboxSingleValueProps<TOption extends ComboboxOption = ComboboxOption> =\n {\n option: TOption;\n isDisabled: boolean;\n size: ComboboxSize;\n };\n\n/** Props of an `OptionLabel` override, rendered inside each option. */\ntype ComboboxOptionLabelProps<TOption extends ComboboxOption = ComboboxOption> =\n {\n option: TOption;\n isSelected: boolean;\n isDisabled: boolean;\n /** Whether the option currently holds virtual focus. */\n isFocused: boolean;\n isMulti: boolean;\n size: ComboboxSize;\n };\n\n/**\n * Props that must be spread onto a custom trigger element. Includes the\n * Floating UI reference props, so the element it lands on becomes the anchor\n * the panel is positioned against.\n */\ntype ComboboxTriggerProps = React.HTMLAttributes<HTMLElement> & {\n ref: React.Ref<HTMLElement>;\n role: 'combobox';\n 'aria-haspopup': 'dialog' | 'listbox';\n // These are DOM attribute names, so the boolean naming convention cannot apply.\n /* eslint-disable @typescript-eslint/naming-convention */\n 'aria-expanded': boolean;\n 'aria-disabled': boolean | undefined;\n 'aria-invalid': boolean | undefined;\n 'aria-required': boolean | undefined;\n /* eslint-enable @typescript-eslint/naming-convention */\n 'aria-controls': string | undefined;\n 'aria-activedescendant': string | undefined;\n 'aria-describedby': string | undefined;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n};\n\n/**\n * The label, help text, and error text of the combobox, for rendering them from\n * a custom trigger.\n *\n * @remarks\n * A custom trigger is named through `aria-label` and carries the\n * `aria-describedby` of whichever message is currently shown, so it has to\n * render that message with the id it is handed here.\n */\ntype ComboboxFieldState = {\n label: string;\n hasVisuallyHiddenLabel: boolean;\n helpText?: React.ReactNode;\n errorText?: React.ReactNode;\n hasError: boolean;\n isRequired: boolean;\n hasRequiredIndicator: boolean;\n /** Id the trigger's `aria-labelledby` points at when the label is rendered. */\n labelId: string;\n /** Id of the trigger, so a rendered `<label>` can point at it with `htmlFor`. */\n triggerId: string;\n /** Ids the trigger's `aria-describedby` points at. Only one is used at a time. */\n helpTextId: string;\n errorTextId: string;\n};\n\n/** Current combobox state, for rendering a custom trigger. */\ntype ComboboxTriggerState<TOption extends ComboboxOption = ComboboxOption> = {\n isOpen: boolean;\n isMulti: boolean;\n isDisabled: boolean;\n /** The selected options, as a list in both single and multi select. */\n selectedOptions: TOption[];\n /** Clears the whole selection. */\n clear: () => void;\n /** Deselects a single option. */\n remove: (option: TOption) => void;\n /** The label and messages of the combobox, so a custom trigger can present them. */\n field: ComboboxFieldState;\n};\n\ntype ComboboxSingleProps<TOption extends ComboboxOption = ComboboxOption> = {\n /** The selected option in controlled mode. */\n value?: TOption | null;\n /** The initially selected option in uncontrolled mode. */\n defaultValue?: TOption | null;\n /** Called when the selected option changes. `null` when the selection is cleared. */\n onChange?: (value: TOption | null) => void;\n /** Whether multiple options can be selected. */\n isMulti?: false;\n maxRows?: never;\n};\n\ntype ComboboxMultiProps<TOption extends ComboboxOption = ComboboxOption> = {\n /** The selected options in controlled mode. */\n value?: TOption[];\n /** The initially selected options in uncontrolled mode. */\n defaultValue?: TOption[];\n /** Called when the selected options change. */\n onChange?: (value: TOption[]) => void;\n /** Whether multiple options can be selected. */\n isMulti: true;\n /**\n * Maximum number of rows the selected tags may wrap into, a single row by\n * default. Tags that do not fit are collapsed into a read-only counter tag,\n * such as `+4`, at the end of the last row. Pass `null` to let the control\n * grow with the selection.\n */\n maxRows?: number | null;\n};\n\ntype ComboboxProps<TOption extends ComboboxOption = ComboboxOption> =\n ComboboxBaseProps<TOption> &\n (ComboboxSingleProps<TOption> | ComboboxMultiProps<TOption>);\n\ntype ComboboxPanelProps = {\n children?: React.ReactNode;\n ref?: React.Ref<HTMLDivElement>;\n id?: string;\n className?: string;\n style?: React.CSSProperties;\n /**\n * Set when the panel is a dialog popup, which is the case while the search\n * input inside it holds DOM focus.\n */\n ariaLabel?: string;\n isDialog?: boolean;\n} & Record<string, unknown>;\n\ntype ComboboxControlProps<TOption extends ComboboxOption = ComboboxOption> = {\n triggerProps: ComboboxTriggerProps;\n state: ComboboxTriggerState<TOption>;\n field: ComboboxFieldState;\n placeholder: string;\n isClearable: boolean;\n isClean: boolean;\n size: ComboboxSize;\n /** Maximum number of rows the selected tags may wrap into in multi select. `null` is unlimited. */\n maxRows?: number | null;\n components: ComboboxComponents<TOption>;\n /** Floating UI reference props, so clicking anywhere in the control opens the panel. */\n referenceProps: React.HTMLAttributes<HTMLDivElement>;\n referenceRef: React.Ref<HTMLDivElement>;\n};\n\ntype ComboboxEmptyStateProps = {\n children?: React.ReactNode;\n};\n\ntype ComboboxInputProps = {\n ref?: React.Ref<HTMLInputElement>;\n ariaLabel: string;\n value: string;\n onValueChange: (searchValue: string) => void;\n placeholder?: string;\n /** Id of the listbox the input controls, when the listbox is rendered. */\n listboxId?: string;\n /** Id of the virtually focused option, when one is active. */\n activeOptionId?: string;\n onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;\n};\n\ntype ComboboxListBoxProps = {\n ariaLabel: string;\n children?: React.ReactNode;\n isMulti?: boolean;\n id?: string;\n /** Ids of the pinned action rows the listbox owns without containing. */\n ownsIds?: string;\n};\n\ntype ComboboxGroupProps = {\n children?: React.ReactNode;\n label: string;\n};\n\ntype ComboboxOptionProps = {\n children?: React.ReactNode;\n /** Left out on rows that cannot be selected, which drops `aria-selected`. */\n isSelected?: boolean;\n isDisabled?: boolean;\n isFocused?: boolean;\n /** Whether the option is the row that creates a new option from the search value. */\n isCreate?: boolean;\n /** Whether the option is an action row, which acts instead of selecting. */\n isAction?: boolean;\n id?: string;\n onClick?: () => void;\n /** Called when the pointer moves over the option, so hover can drive virtual focus. */\n onHover?: () => void;\n /**\n * One-based position in the full list. Only set while the listbox is\n * virtualized, where the DOM no longer holds every option.\n */\n posInSet?: number;\n /** Total options in the full list. Only set while the listbox is virtualized. */\n setSize?: number;\n};\n\ntype ComboboxOptionContentProps = {\n label: string;\n /**\n * Replaces the label text. Rendered in place of the label typography rather\n * than inside it, so it can be any element rather than inline text.\n */\n customLabel?: React.ReactNode;\n description?: string;\n leadingVisual?: React.ReactNode;\n isDisabled?: boolean;\n isSelected?: boolean;\n isMulti?: boolean;\n};\n\nexport type {\n ComboboxProps,\n ComboboxAction,\n ComboboxComponents,\n ComboboxControlProps,\n ComboboxFieldState,\n ComboboxMultiValueProps,\n ComboboxOptionLabelProps,\n ComboboxSingleValueProps,\n ComboboxTriggerProps,\n ComboboxTriggerState,\n ComboboxPanelProps,\n ComboboxEmptyStateProps,\n ComboboxFilterOption,\n ComboboxInputProps,\n ComboboxListBoxProps,\n ComboboxGroupProps,\n ComboboxOptionProps,\n ComboboxOptionContentProps,\n ComboboxOption,\n ComboboxOptionGroup,\n ComboboxSize,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../src/date-picker/DatePicker.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iCAAiC;AACjC,yDAAyD;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAAgE;AAChE,4DAAoC;AACpC,uCAAkC;AAClC,iCAAsD;AACtD,wEAE0B;AAG1B,4DAAuD;AACvD,6DAA6D;AAC7D,wCAAqC;AACrC,4FAAyF;AACzF,8FAA2F;AAC3F,kGAA+F;AAC/F,gGAA6F;AAC7F,8CAA0C;AAC1C,gDAA8E;AAC9E,wDAAoD;AACpD,8CAA2C;AAC3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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 { type Boundary, shift, size } from '@floating-ui/react';\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 { ArrowLeftIconOutline } from '../icons/generated/heroIcons/ArrowLeftIconOutline';\nimport { ArrowRightIconOutline } from '../icons/generated/heroIcons/ArrowRightIconOutline';\nimport { CalendarDaysIconOutline } from '../icons/generated/heroIcons/CalendarDaysIconOutline';\nimport { ChevronDownIconOutline } from '../icons/generated/heroIcons/ChevronDownIconOutline';\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 isClearable?: 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 isClearable,\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 onChange: textInputOnChange,\n ref,\n ...restTextInputProps\n } = textInputProps ?? {};\n const { onChange: injectedOnChange, ...restInjectedProps } = restProps;\n\n const handleChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n injectedOnChange?.(event);\n textInputOnChange?.(event);\n };\n\n return (\n <TextInput\n ref={ref}\n trailingElement={<CalendarDaysIconOutline />}\n value={value}\n placeholder={placeholder ?? textInputPlaceholder}\n isDisabled={isDisabled}\n isClearable={isClearable}\n onChange={handleChange}\n // react-datepicker injects html attributes into the custom input\n htmlAttributes={{\n ...textInputHtmlAttributes,\n ...restInjectedProps,\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\n/**\n * @remarks\n * The `reactDatePickerProps` prop is forwarded to the underlying `react-datepicker` component. See the [react-datepicker documentation](https://reactdatepicker.com/) for more information.\n *\n * @remarks\n * Where `TextInputProps` is defined in the `TextInput` component and `TimePickerProps` is defined in the `TimePicker` component.\n */\ninterface DatePickerProps {\n /** Props for the embedded `TextInput` component. */\n // TODO v5: this forwards TextInput's props, so its showRequiredOrOptionalLabel\n // to hasRequiredIndicator rename lands here too and needs the same codemod.\n textInputProps?: React.ComponentProps<typeof TextInput>;\n /** Whether the date picker is disabled. */\n isDisabled?: boolean;\n /**\n * Whether to show the clear button.\n * @default false\n */\n isClearable?: 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 isClearable = false,\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 shouldRestoreFocusAfterEscapeRef = useRef(false);\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 // Inside a Dialog the popper is fixed and not portaled. A transformed\n // ancestor (e.g. Popover) can make Floating UI under-measure available\n // space, so use the viewport as the boundary instead.\n const floatingBoundary: Boundary = isInsideDialog ? [] : 'clippingAncestors';\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 const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n // react-datepicker prevents Escape when it closes the calendar, but\n // otherwise lets the event bubble and dismiss ancestor overlays.\n if (event.key === 'Escape' && event.defaultPrevented) {\n shouldRestoreFocusAfterEscapeRef.current = true;\n event.stopPropagation();\n }\n htmlAttributes?.onKeyDown?.(event);\n };\n\n /** These intercepts are needed for webkit to ensure that focus is restored to the input when the calendar is closed. */\n const interceptedOnBlur = useCallback(\n (event: React.FocusEvent<HTMLElement>) => {\n reactDatePickerProps.onBlur?.(event);\n\n if (\n !shouldRestoreFocusAfterEscapeRef.current ||\n event.relatedTarget !== null\n ) {\n return;\n }\n\n const input = event.currentTarget;\n queueMicrotask(() => {\n if (\n shouldRestoreFocusAfterEscapeRef.current &&\n input.isConnected &&\n document.activeElement === document.body\n ) {\n datetimeRef.current?.sendFocusBackToInput();\n }\n shouldRestoreFocusAfterEscapeRef.current = false;\n });\n },\n [reactDatePickerProps],\n );\n\n const interceptedOnFocus = useCallback(\n (event: React.FocusEvent<HTMLElement>) => {\n reactDatePickerProps.onFocus?.(event);\n\n if (!shouldRestoreFocusAfterEscapeRef.current) {\n return;\n }\n\n // react-datepicker schedules both focus and blur while closing. If blur\n // ran first, focus is now stable and the Escape marker can be cleared.\n requestAnimationFrame(() => {\n shouldRestoreFocusAfterEscapeRef.current = false;\n });\n },\n [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 onBlur: interceptedOnBlur,\n onCalendarClose: interceptedOnCalendarClose,\n onChange: interceptedChange,\n onChangeRaw: interceptedOnChangeRaw,\n onFocus: interceptedOnFocus,\n onMonthChange: handleMonthChange,\n };\n\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- the key handlers only stop Escape from propagating, they add no interaction\n <div\n className={classes}\n ref={ref}\n style={style}\n {...restProps}\n {...htmlAttributes}\n onKeyDown={handleKeyDown}\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 isClearable={isClearable}\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 isClearable={isClearable}\n popperClassName={classNames(\n 'ndl-datepicker-popper',\n reactDatePickerProps.popperClassName,\n )}\n popperModifiers={[\n shift({ boundary: floatingBoundary, padding: 8 }),\n size({\n apply({ availableHeight, availableWidth, elements }) {\n elements.floating.style.setProperty(\n '--ndl-datepicker-available-height',\n `${availableHeight}px`,\n );\n Object.assign(elements.floating.style, {\n maxWidth: `${availableWidth}px`,\n });\n },\n boundary: floatingBoundary,\n padding: 8,\n }),\n ...(reactDatePickerProps.popperModifiers ?? []),\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,8CAAgE;AAChE,4DAAoC;AACpC,uCAAkC;AAClC,iCAAsD;AACtD,wEAE0B;AAG1B,4DAAuD;AACvD,6DAA6D;AAC7D,wCAAqC;AACrC,4FAAyF;AACzF,8FAA2F;AAC3F,kGAA+F;AAC/F,gGAA6F;AAC7F,8CAA0C;AAC1C,gDAA8E;AAC9E,wDAAoD;AACpD,8CAA2C;AAC3C,mCAA4D;AAU5D,2EAA2E;AAC3E,6EAA6E;AAC7E,8DAA8D;AAC9D,MAAM,0BAA0B,GAAG,CAAC,EAOF,EAAE,EAAE;QAPF,EAClC,cAAc,EACd,UAAU,EACV,WAAW,EACX,KAAK,EACL,WAAW,OAEqB,EAD7B,SAAS,cANsB,uEAOnC,CADa;IAEZ,iFAAiF;IACjF,MAAM,KAMF,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,EAAE,EANlB,EACJ,WAAW,EAAE,oBAAoB,EACjC,cAAc,EAAE,uBAAuB,EACvC,QAAQ,EAAE,iBAAiB,EAC3B,GAAG,OAEm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zB,uBAAuB,EACvB,oBAAoB,CAAC,eAAe,CACrC,EACD,eAAe,EAAE;gBACf,IAAA,aAAK,EAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;gBACjD,IAAA,YAAI,EAAC;oBACH,KAAK,CAAC,EAAE,eAAe,EAAE,cAAc,EAAE,QAAQ,EAAE;wBACjD,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CACjC,mCAAmC,EACnC,GAAG,eAAe,IAAI,CACvB,CAAC;wBACF,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE;4BACrC,QAAQ,EAAE,GAAG,cAAc,IAAI;yBAChC,CAAC,CAAC;oBACL,CAAC;oBACD,QAAQ,EAAE,gBAAgB;oBAC1B,OAAO,EAAE,CAAC;iBACX,CAAC;gBACF,GAAG,CAAC,MAAA,oBAAoB,CAAC,eAAe,mCAAI,EAAE,CAAC;aAChD,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;AA/ZW,QAAA,UAAU,cA+ZrB","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 { type Boundary, shift, size } from '@floating-ui/react';\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 { ArrowLeftIconOutline } from '../icons/generated/heroIcons/ArrowLeftIconOutline';\nimport { ArrowRightIconOutline } from '../icons/generated/heroIcons/ArrowRightIconOutline';\nimport { CalendarDaysIconOutline } from '../icons/generated/heroIcons/CalendarDaysIconOutline';\nimport { ChevronDownIconOutline } from '../icons/generated/heroIcons/ChevronDownIconOutline';\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 isClearable?: 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 isClearable,\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 onChange: textInputOnChange,\n ref,\n ...restTextInputProps\n } = textInputProps ?? {};\n const { onChange: injectedOnChange, ...restInjectedProps } = restProps;\n\n const handleChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n injectedOnChange?.(event);\n textInputOnChange?.(event);\n };\n\n return (\n <TextInput\n ref={ref}\n trailingElement={<CalendarDaysIconOutline />}\n value={value}\n placeholder={placeholder ?? textInputPlaceholder}\n isDisabled={isDisabled}\n isClearable={isClearable}\n onChange={handleChange}\n // react-datepicker injects html attributes into the custom input\n htmlAttributes={{\n ...textInputHtmlAttributes,\n ...restInjectedProps,\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\n/**\n * @remarks\n * The `reactDatePickerProps` prop is forwarded to the underlying `react-datepicker` component. See the [react-datepicker documentation](https://reactdatepicker.com/) for more information.\n *\n * @remarks\n * Where `TextInputProps` is defined in the `TextInput` component and `TimePickerProps` is defined in the `TimePicker` component.\n */\ninterface DatePickerProps {\n /** Props for the embedded `TextInput` component. */\n // TODO v5: this forwards TextInput's props, so whatever happens to its\n // inconsistently named ones lands here too and needs the same codemod.\n textInputProps?: React.ComponentProps<typeof TextInput>;\n /** Whether the date picker is disabled. */\n isDisabled?: boolean;\n /**\n * Whether to show the clear button.\n * @default false\n */\n isClearable?: 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 isClearable = false,\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 shouldRestoreFocusAfterEscapeRef = useRef(false);\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 // Inside a Dialog the popper is fixed and not portaled. A transformed\n // ancestor (e.g. Popover) can make Floating UI under-measure available\n // space, so use the viewport as the boundary instead.\n const floatingBoundary: Boundary = isInsideDialog ? [] : 'clippingAncestors';\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 const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n // react-datepicker prevents Escape when it closes the calendar, but\n // otherwise lets the event bubble and dismiss ancestor overlays.\n if (event.key === 'Escape' && event.defaultPrevented) {\n shouldRestoreFocusAfterEscapeRef.current = true;\n event.stopPropagation();\n }\n htmlAttributes?.onKeyDown?.(event);\n };\n\n /** These intercepts are needed for webkit to ensure that focus is restored to the input when the calendar is closed. */\n const interceptedOnBlur = useCallback(\n (event: React.FocusEvent<HTMLElement>) => {\n reactDatePickerProps.onBlur?.(event);\n\n if (\n !shouldRestoreFocusAfterEscapeRef.current ||\n event.relatedTarget !== null\n ) {\n return;\n }\n\n const input = event.currentTarget;\n queueMicrotask(() => {\n if (\n shouldRestoreFocusAfterEscapeRef.current &&\n input.isConnected &&\n document.activeElement === document.body\n ) {\n datetimeRef.current?.sendFocusBackToInput();\n }\n shouldRestoreFocusAfterEscapeRef.current = false;\n });\n },\n [reactDatePickerProps],\n );\n\n const interceptedOnFocus = useCallback(\n (event: React.FocusEvent<HTMLElement>) => {\n reactDatePickerProps.onFocus?.(event);\n\n if (!shouldRestoreFocusAfterEscapeRef.current) {\n return;\n }\n\n // react-datepicker schedules both focus and blur while closing. If blur\n // ran first, focus is now stable and the Escape marker can be cleared.\n requestAnimationFrame(() => {\n shouldRestoreFocusAfterEscapeRef.current = false;\n });\n },\n [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 onBlur: interceptedOnBlur,\n onCalendarClose: interceptedOnCalendarClose,\n onChange: interceptedChange,\n onChangeRaw: interceptedOnChangeRaw,\n onFocus: interceptedOnFocus,\n onMonthChange: handleMonthChange,\n };\n\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- the key handlers only stop Escape from propagating, they add no interaction\n <div\n className={classes}\n ref={ref}\n style={style}\n {...restProps}\n {...htmlAttributes}\n onKeyDown={handleKeyDown}\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 isClearable={isClearable}\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 isClearable={isClearable}\n popperClassName={classNames(\n 'ndl-datepicker-popper',\n reactDatePickerProps.popperClassName,\n )}\n popperModifiers={[\n shift({ boundary: floatingBoundary, padding: 8 }),\n size({\n apply({ availableHeight, availableWidth, elements }) {\n elements.floating.style.setProperty(\n '--ndl-datepicker-available-height',\n `${availableHeight}px`,\n );\n Object.assign(elements.floating.style, {\n maxWidth: `${availableWidth}px`,\n });\n },\n boundary: floatingBoundary,\n padding: 8,\n }),\n ...(reactDatePickerProps.popperModifiers ?? []),\n ]}\n popperProps={{\n strategy: isInsideDialog ? 'fixed' : 'absolute',\n ...reactDatePickerProps.popperProps,\n }}\n />\n </div>\n );\n};\n"]}
|
|
@@ -26,11 +26,11 @@ const react_1 = require("@neo4j-ndl/react");
|
|
|
26
26
|
const react_2 = require("react");
|
|
27
27
|
// Configuration constants
|
|
28
28
|
const CONFIG = {
|
|
29
|
-
|
|
29
|
+
ACCEPTED_EXTENSIONS: ['.txt', '.json'],
|
|
30
30
|
MAX_FILE_SIZE: 5 * 1024 * 1024, // 5MB
|
|
31
|
+
MAX_FILES: 3,
|
|
31
32
|
PROGRESS_INCREMENT: 5,
|
|
32
33
|
UPDATE_INTERVAL: 100,
|
|
33
|
-
ACCEPTED_EXTENSIONS: ['.txt', '.json'],
|
|
34
34
|
};
|
|
35
35
|
var UploadState;
|
|
36
36
|
(function (UploadState) {
|
|
@@ -55,7 +55,7 @@ const Component = () => {
|
|
|
55
55
|
});
|
|
56
56
|
}, []);
|
|
57
57
|
const simulateUpload = (0, react_2.useCallback)((files) => {
|
|
58
|
-
setUploadData((prev) => (Object.assign(Object.assign({}, prev), {
|
|
58
|
+
setUploadData((prev) => (Object.assign(Object.assign({}, prev), { files, progress: 0, state: UploadState.Uploading })));
|
|
59
59
|
const interval = setInterval(() => {
|
|
60
60
|
setUploadData((prev) => {
|
|
61
61
|
const newProgress = prev.progress + CONFIG.PROGRESS_INCREMENT;
|
|
@@ -76,11 +76,11 @@ const Component = () => {
|
|
|
76
76
|
}, [simulateUpload]);
|
|
77
77
|
const handleDropRejected = (0, react_2.useCallback)((rejectedFiles) => {
|
|
78
78
|
const errors = rejectedFiles.map((file) => `${file.file.name}: ${file.errors.map((error) => error.message).join(', ')}`);
|
|
79
|
-
setUploadData((prev) => (Object.assign(Object.assign({}, prev), { state: UploadState.Error
|
|
79
|
+
setUploadData((prev) => (Object.assign(Object.assign({}, prev), { errors, state: UploadState.Error })));
|
|
80
80
|
}, []);
|
|
81
81
|
const handleError = (0, react_2.useCallback)((error) => {
|
|
82
82
|
console.error('Dropzone error:', error);
|
|
83
|
-
setUploadData((prev) => (Object.assign(Object.assign({}, prev), {
|
|
83
|
+
setUploadData((prev) => (Object.assign(Object.assign({}, prev), { errors: [error.message], state: UploadState.Error })));
|
|
84
84
|
}, []);
|
|
85
85
|
const renderStatusContent = () => {
|
|
86
86
|
const { state, progress, files, errors } = uploadData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropzone-full.story.js","sourceRoot":"","sources":["../../../../src/dropzone/stories/dropzone-full.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qDAAsD;AACtD,4CAAsE;AACtE,iCAA8C;AAO9C,0BAA0B;AAC1B,MAAM,MAAM,GAAG;IACb,SAAS,EAAE,CAAC;IACZ,aAAa,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,EAAE,MAAM;IACtC,kBAAkB,EAAE,CAAC;IACrB,eAAe,EAAE,GAAG;IACpB,mBAAmB,EAAE,CAAC,MAAM,EAAE,OAAO,CAAa;CAC1C,CAAC;AAEX,IAAK,WAKJ;AALD,WAAK,WAAW;IACd,4BAAa,CAAA;IACb,sCAAuB,CAAA;IACvB,kCAAmB,CAAA;IACnB,8BAAe,CAAA;AACjB,CAAC,EALI,WAAW,KAAX,WAAW,QAKf;AASD,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAa;QACvD,MAAM,EAAE,EAAE;QACV,KAAK,EAAE,EAAE;QACT,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE,WAAW,CAAC,IAAI;KACxB,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QACnC,aAAa,CAAC;YACZ,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,CAAC;YACX,KAAK,EAAE,WAAW,CAAC,IAAI;SACxB,CAAC,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,cAAc,GAAG,I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,EAAC,YAAY,EAAC,SAAS,EAAC,0BAA0B,qBAC9D,MAAM,CAAC,SAAS,mBAAU,GAAG,EACjC,MAAM,CAAC,aAAa,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,mBAC1B,IACT,EAER,sBAAsB,EAAE,MAAM,CAAC,mBAAmB,EAClD,cAAc,EAAE,mBAAmB,EAAE,EACrC,YAAY,EAAC,4DAA4D,EACzE,OAAO,EAAC,wBAAwB,GAChC,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","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 { XMarkIcon } from '@heroicons/react/24/solid';\nimport { Dropzone, FilledButton, Typography } from '@neo4j-ndl/react';\nimport { useCallback, useState } from 'react';\nimport {\n type DropEvent,\n type DropzoneOptions,\n type FileRejection,\n} from 'react-dropzone';\n\n// Configuration constants\nconst CONFIG = {\n MAX_FILES: 3,\n MAX_FILE_SIZE: 5 * 1024 * 1024, // 5MB\n PROGRESS_INCREMENT: 5,\n UPDATE_INTERVAL: 100,\n ACCEPTED_EXTENSIONS: ['.txt', '.json'] as string[],\n} as const;\n\nenum UploadState {\n Idle = 'idle',\n Uploading = 'uploading',\n Success = 'success',\n Error = 'error',\n}\n\ninterface UploadData {\n state: UploadState;\n progress: number;\n files: File[];\n errors: string[];\n}\n\nconst Component = () => {\n const [uploadData, setUploadData] = useState<UploadData>({\n errors: [],\n files: [],\n progress: 0,\n state: UploadState.Idle,\n });\n\n const resetUpload = useCallback(() => {\n setUploadData({\n errors: [],\n files: [],\n progress: 0,\n state: UploadState.Idle,\n });\n }, []);\n\n const simulateUpload = useCallback((files: File[]) => {\n setUploadData((prev) => ({\n ...prev,\n state: UploadState.Uploading,\n files,\n progress: 0,\n }));\n\n const interval = setInterval(() => {\n setUploadData((prev) => {\n const newProgress = prev.progress + CONFIG.PROGRESS_INCREMENT;\n if (newProgress >= 100) {\n clearInterval(interval);\n setTimeout(\n () =>\n setUploadData((current) => ({\n ...current,\n state: UploadState.Success,\n })),\n 500,\n );\n return { ...prev, progress: 100 };\n }\n return { ...prev, progress: newProgress };\n });\n }, CONFIG.UPDATE_INTERVAL);\n }, []);\n\n const handleDrop: DropzoneOptions['onDrop'] = useCallback(\n (\n acceptedFiles: File[],\n rejectedFiles: FileRejection[],\n event: DropEvent,\n ) => {\n console.info('Drop event:', { acceptedFiles, event, rejectedFiles });\n\n if (acceptedFiles.length > 0) {\n simulateUpload(acceptedFiles);\n }\n },\n [simulateUpload],\n );\n\n const handleDropRejected: DropzoneOptions['onDropRejected'] = useCallback(\n (rejectedFiles: FileRejection[]) => {\n const errors = rejectedFiles.map(\n (file) =>\n `${file.file.name}: ${file.errors.map((error) => error.message).join(', ')}`,\n );\n setUploadData((prev) => ({ ...prev, state: UploadState.Error, errors }));\n },\n [],\n );\n\n const handleError = useCallback((error: Error) => {\n console.error('Dropzone error:', error);\n setUploadData((prev) => ({\n ...prev,\n state: UploadState.Error,\n errors: [error.message],\n }));\n }, []);\n\n const renderStatusContent = () => {\n const { state, progress, files, errors } = uploadData;\n\n switch (state) {\n case UploadState.Uploading:\n return (\n <Dropzone.LoadingProgressBar\n progressBarPrecentage={Math.round(progress)}\n />\n );\n\n case UploadState.Success:\n return (\n <div className=\"n-flex n-flex-col n-justify-center n-items-center n-gap-y-token-32\">\n <Typography\n variant=\"title-4\"\n className=\"n-text-success-text n-font-semibold\"\n >\n Upload Complete!\n </Typography>\n <Typography\n variant=\"body-small\"\n className=\"n-text-neutral-text-weak\"\n >\n Successfully uploaded: {files.map((file) => file.name).join(', ')}\n </Typography>\n <FilledButton onClick={resetUpload}>Upload More Files</FilledButton>\n </div>\n );\n\n case UploadState.Error:\n return (\n <div className=\"n-flex n-flex-col n-justify-center n-items-center n-gap-y-token-32\">\n <XMarkIcon className=\"n-w-token-32 n-h-token-32 n-text-danger-text\" />\n <div className=\"n-flex n-flex-col n-gap-y-token-2\">\n {errors.map((message, index) => (\n <Typography\n key={index}\n variant=\"label\"\n className=\"n-text-danger-text n-font-semibold\"\n htmlAttributes={{ role: 'alert' }}\n >\n {message}\n </Typography>\n ))}\n </div>\n <FilledButton onClick={resetUpload}>Try Again</FilledButton>\n </div>\n );\n\n default:\n return undefined;\n }\n };\n\n return (\n <Dropzone\n dropZoneOptions={{\n disabled: uploadData.state === UploadState.Uploading,\n maxFiles: CONFIG.MAX_FILES,\n maxSize: CONFIG.MAX_FILE_SIZE,\n multiple: true,\n onDrop: handleDrop,\n onDropRejected: handleDropRejected,\n onError: handleError,\n }}\n supportedFilesDescription={\n <div className=\"n-text-center n-flex n-flex-col n-gap-y-token-2\">\n <Typography variant=\"body-small\" className=\"n-text-neutral-text-weak\">\n Supports: Text files (.txt, .json) only\n </Typography>\n <Typography variant=\"body-small\" className=\"n-text-neutral-text-weak\">\n Max {CONFIG.MAX_FILES} files •{' '}\n {CONFIG.MAX_FILE_SIZE / (1024 * 1024)}MB per file\n </Typography>\n </div>\n }\n acceptedFileExtensions={CONFIG.ACCEPTED_EXTENSIONS}\n loadingElement={renderStatusContent()}\n rejectedText=\"Error: Please make sure to only upload .json or .txt files\"\n heading=\"Drag & Drop your files\"\n />\n );\n};\n\nexport default Component;\n"]}
|
|
1
|
+
{"version":3,"file":"dropzone-full.story.js","sourceRoot":"","sources":["../../../../src/dropzone/stories/dropzone-full.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qDAAsD;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AAS,CAAC","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 { XMarkIcon } from '@heroicons/react/24/solid';\nimport { Dropzone, FilledButton, Typography } from '@neo4j-ndl/react';\nimport { useCallback, useState } from 'react';\nimport {\n type DropEvent,\n type DropzoneOptions,\n type FileRejection,\n} from 'react-dropzone';\n\n// Configuration constants\nconst CONFIG = {\n ACCEPTED_EXTENSIONS: ['.txt', '.json'] as string[],\n MAX_FILE_SIZE: 5 * 1024 * 1024, // 5MB\n MAX_FILES: 3,\n PROGRESS_INCREMENT: 5,\n UPDATE_INTERVAL: 100,\n} as const;\n\nenum UploadState {\n Idle = 'idle',\n Uploading = 'uploading',\n Success = 'success',\n Error = 'error',\n}\n\ninterface UploadData {\n state: UploadState;\n progress: number;\n files: File[];\n errors: string[];\n}\n\nconst Component = () => {\n const [uploadData, setUploadData] = useState<UploadData>({\n errors: [],\n files: [],\n progress: 0,\n state: UploadState.Idle,\n });\n\n const resetUpload = useCallback(() => {\n setUploadData({\n errors: [],\n files: [],\n progress: 0,\n state: UploadState.Idle,\n });\n }, []);\n\n const simulateUpload = useCallback((files: File[]) => {\n setUploadData((prev) => ({\n ...prev,\n files,\n progress: 0,\n state: UploadState.Uploading,\n }));\n\n const interval = setInterval(() => {\n setUploadData((prev) => {\n const newProgress = prev.progress + CONFIG.PROGRESS_INCREMENT;\n if (newProgress >= 100) {\n clearInterval(interval);\n setTimeout(\n () =>\n setUploadData((current) => ({\n ...current,\n state: UploadState.Success,\n })),\n 500,\n );\n return { ...prev, progress: 100 };\n }\n return { ...prev, progress: newProgress };\n });\n }, CONFIG.UPDATE_INTERVAL);\n }, []);\n\n const handleDrop: DropzoneOptions['onDrop'] = useCallback(\n (\n acceptedFiles: File[],\n rejectedFiles: FileRejection[],\n event: DropEvent,\n ) => {\n console.info('Drop event:', { acceptedFiles, event, rejectedFiles });\n\n if (acceptedFiles.length > 0) {\n simulateUpload(acceptedFiles);\n }\n },\n [simulateUpload],\n );\n\n const handleDropRejected: DropzoneOptions['onDropRejected'] = useCallback(\n (rejectedFiles: FileRejection[]) => {\n const errors = rejectedFiles.map(\n (file) =>\n `${file.file.name}: ${file.errors.map((error) => error.message).join(', ')}`,\n );\n setUploadData((prev) => ({ ...prev, errors, state: UploadState.Error }));\n },\n [],\n );\n\n const handleError = useCallback((error: Error) => {\n console.error('Dropzone error:', error);\n setUploadData((prev) => ({\n ...prev,\n errors: [error.message],\n state: UploadState.Error,\n }));\n }, []);\n\n const renderStatusContent = () => {\n const { state, progress, files, errors } = uploadData;\n\n switch (state) {\n case UploadState.Uploading:\n return (\n <Dropzone.LoadingProgressBar\n progressBarPrecentage={Math.round(progress)}\n />\n );\n\n case UploadState.Success:\n return (\n <div className=\"n-flex n-flex-col n-justify-center n-items-center n-gap-y-token-32\">\n <Typography\n variant=\"title-4\"\n className=\"n-text-success-text n-font-semibold\"\n >\n Upload Complete!\n </Typography>\n <Typography\n variant=\"body-small\"\n className=\"n-text-neutral-text-weak\"\n >\n Successfully uploaded: {files.map((file) => file.name).join(', ')}\n </Typography>\n <FilledButton onClick={resetUpload}>Upload More Files</FilledButton>\n </div>\n );\n\n case UploadState.Error:\n return (\n <div className=\"n-flex n-flex-col n-justify-center n-items-center n-gap-y-token-32\">\n <XMarkIcon className=\"n-w-token-32 n-h-token-32 n-text-danger-text\" />\n <div className=\"n-flex n-flex-col n-gap-y-token-2\">\n {errors.map((message, index) => (\n <Typography\n key={index}\n variant=\"label\"\n className=\"n-text-danger-text n-font-semibold\"\n htmlAttributes={{ role: 'alert' }}\n >\n {message}\n </Typography>\n ))}\n </div>\n <FilledButton onClick={resetUpload}>Try Again</FilledButton>\n </div>\n );\n\n default:\n return undefined;\n }\n };\n\n return (\n <Dropzone\n dropZoneOptions={{\n disabled: uploadData.state === UploadState.Uploading,\n maxFiles: CONFIG.MAX_FILES,\n maxSize: CONFIG.MAX_FILE_SIZE,\n multiple: true,\n onDrop: handleDrop,\n onDropRejected: handleDropRejected,\n onError: handleError,\n }}\n supportedFilesDescription={\n <div className=\"n-text-center n-flex n-flex-col n-gap-y-token-2\">\n <Typography variant=\"body-small\" className=\"n-text-neutral-text-weak\">\n Supports: Text files (.txt, .json) only\n </Typography>\n <Typography variant=\"body-small\" className=\"n-text-neutral-text-weak\">\n Max {CONFIG.MAX_FILES} files •{' '}\n {CONFIG.MAX_FILE_SIZE / (1024 * 1024)}MB per file\n </Typography>\n </div>\n }\n acceptedFileExtensions={CONFIG.ACCEPTED_EXTENSIONS}\n loadingElement={renderStatusContent()}\n rejectedText=\"Error: Please make sure to only upload .json or .txt files\"\n heading=\"Drag & Drop your files\"\n />\n );\n};\n\nexport default Component;\n"]}
|
package/lib/cjs/helpers/index.js
CHANGED
|
@@ -35,4 +35,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
35
35
|
};
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
37
|
__exportStar(require("./debounce"), exports);
|
|
38
|
+
__exportStar(require("./platform"), exports);
|
|
38
39
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;AAEH,6CAA2B","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 */\n\nexport * from './debounce';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;AAEH,6CAA2B;AAC3B,6CAA2B","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 */\n\nexport * from './debounce';\nexport * from './platform';\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.detectOS = detectOS;
|
|
24
|
+
exports.isApplePlatform = isApplePlatform;
|
|
25
|
+
/**
|
|
26
|
+
* `navigator.platform` comes first because it describes the machine the
|
|
27
|
+
* keyboard is attached to, while the user agent and its client hints can be
|
|
28
|
+
* pinned to another platform by the embedder.
|
|
29
|
+
*/
|
|
30
|
+
function getPlatformHint() {
|
|
31
|
+
var _a;
|
|
32
|
+
if (typeof navigator === 'undefined') {
|
|
33
|
+
return '';
|
|
34
|
+
}
|
|
35
|
+
const navigatorWithHints = navigator;
|
|
36
|
+
return (navigator.platform ||
|
|
37
|
+
((_a = navigatorWithHints.userAgentData) === null || _a === void 0 ? void 0 : _a.platform) ||
|
|
38
|
+
navigator.userAgent ||
|
|
39
|
+
'');
|
|
40
|
+
}
|
|
41
|
+
/** Detects the operating system the keyboard is attached to. */
|
|
42
|
+
function detectOS() {
|
|
43
|
+
const platform = getPlatformHint();
|
|
44
|
+
if (/mac|iphone|ipad|ipod/i.test(platform)) {
|
|
45
|
+
return 'mac';
|
|
46
|
+
}
|
|
47
|
+
if (/win/i.test(platform)) {
|
|
48
|
+
return 'windows';
|
|
49
|
+
}
|
|
50
|
+
return 'linux';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Apple platforms take `Cmd` where the rest take `Ctrl`, since `Ctrl` + click
|
|
54
|
+
* is the macOS context menu gesture.
|
|
55
|
+
*/
|
|
56
|
+
function isApplePlatform() {
|
|
57
|
+
return detectOS() === 'mac';
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../../../src/helpers/platform.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;AAyBH,4BASC;AAMD,0CAEC;AAtCD;;;;GAIG;AACH,SAAS,eAAe;;IACtB,IAAI,OAAO,SAAS,KAAK,WAAW,EAAE,CAAC;QACrC,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,kBAAkB,GAAG,SAE1B,CAAC;IACF,OAAO,CACL,SAAS,CAAC,QAAQ;SAClB,MAAA,kBAAkB,CAAC,aAAa,0CAAE,QAAQ,CAAA;QAC1C,SAAS,CAAC,SAAS;QACnB,EAAE,CACH,CAAC;AACJ,CAAC;AAED,gEAAgE;AAChE,SAAgB,QAAQ;IACtB,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,IAAI,uBAAuB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,SAAgB,eAAe;IAC7B,OAAO,QAAQ,EAAE,KAAK,KAAK,CAAC;AAC9B,CAAC","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 */\n\nexport type OperatingSystem = 'mac' | 'windows' | 'linux';\n\n/**\n * `navigator.platform` comes first because it describes the machine the\n * keyboard is attached to, while the user agent and its client hints can be\n * pinned to another platform by the embedder.\n */\nfunction getPlatformHint(): string {\n if (typeof navigator === 'undefined') {\n return '';\n }\n const navigatorWithHints = navigator as Navigator & {\n userAgentData?: { platform?: string };\n };\n return (\n navigator.platform ||\n navigatorWithHints.userAgentData?.platform ||\n navigator.userAgent ||\n ''\n );\n}\n\n/** Detects the operating system the keyboard is attached to. */\nexport function detectOS(): OperatingSystem {\n const platform = getPlatformHint();\n if (/mac|iphone|ipad|ipod/i.test(platform)) {\n return 'mac';\n }\n if (/win/i.test(platform)) {\n return 'windows';\n }\n return 'linux';\n}\n\n/**\n * Apple platforms take `Cmd` where the rest take `Ctrl`, since `Ctrl` + click\n * is the macOS context menu gesture.\n */\nexport function isApplePlatform(): boolean {\n return detectOS() === 'mac';\n}\n"]}
|
package/lib/cjs/kbd/kbd-utils.js
CHANGED
|
@@ -21,32 +21,16 @@
|
|
|
21
21
|
|
|
22
22
|
"use strict";
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.detectOS =
|
|
24
|
+
exports.detectOS = void 0;
|
|
25
25
|
exports.getKbdKeysMap = getKbdKeysMap;
|
|
26
26
|
exports.getKbdKeysLabelMap = getKbdKeysLabelMap;
|
|
27
27
|
exports.getKbdScreenReaderFriendlyText = getKbdScreenReaderFriendlyText;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*/
|
|
31
|
-
function detectOS() {
|
|
32
|
-
if (typeof window === 'undefined') {
|
|
33
|
-
return 'linux';
|
|
34
|
-
}
|
|
35
|
-
const userAgent = window.navigator.userAgent.toLowerCase();
|
|
36
|
-
if (userAgent.includes('mac')) {
|
|
37
|
-
return 'mac';
|
|
38
|
-
}
|
|
39
|
-
else if (userAgent.includes('win')) {
|
|
40
|
-
return 'windows';
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
return 'linux';
|
|
44
|
-
}
|
|
45
|
-
}
|
|
28
|
+
const platform_1 = require("../helpers/platform");
|
|
29
|
+
Object.defineProperty(exports, "detectOS", { enumerable: true, get: function () { return platform_1.detectOS; } });
|
|
46
30
|
/**
|
|
47
31
|
* Returns OS-aware keyboard key symbols
|
|
48
32
|
*/
|
|
49
|
-
function getKbdKeysMap(os = detectOS()) {
|
|
33
|
+
function getKbdKeysMap(os = (0, platform_1.detectOS)()) {
|
|
50
34
|
const baseMap = {
|
|
51
35
|
alt: os === 'mac' ? '⌥' : 'alt',
|
|
52
36
|
capslock: '⇪',
|
|
@@ -73,7 +57,7 @@ function getKbdKeysMap(os = detectOS()) {
|
|
|
73
57
|
/**
|
|
74
58
|
* Returns OS-aware keyboard key labels
|
|
75
59
|
*/
|
|
76
|
-
function getKbdKeysLabelMap(os = detectOS()) {
|
|
60
|
+
function getKbdKeysLabelMap(os = (0, platform_1.detectOS)()) {
|
|
77
61
|
return {
|
|
78
62
|
alt: 'Alt',
|
|
79
63
|
capslock: 'Caps Lock',
|
|
@@ -108,7 +92,7 @@ function resolveKeyLabel(key, labels) {
|
|
|
108
92
|
}
|
|
109
93
|
return '';
|
|
110
94
|
}
|
|
111
|
-
function getKbdScreenReaderFriendlyText(keys, modifierKeys, os = detectOS()) {
|
|
95
|
+
function getKbdScreenReaderFriendlyText(keys, modifierKeys, os = (0, platform_1.detectOS)()) {
|
|
112
96
|
const labels = getKbdKeysLabelMap(os);
|
|
113
97
|
const modStr = (modifierKeys !== null && modifierKeys !== void 0 ? modifierKeys : []).map((key) => labels[key]).join(' + ');
|
|
114
98
|
const keyLabels = (keys !== null && keys !== void 0 ? keys : [])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kbd-utils.js","sourceRoot":"","sources":["../../../src/kbd/kbd-utils.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AAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1E,MAAM,SAAS,GAAG,CAAC,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC;SAC3B,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;SAC1C,MAAM,CAAC,OAAO,CAAC,CAAC;IACnB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;SAAM,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IACD,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1D,OAAO,IAAI,CAAC,CAAC,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACzC,CAAC","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 type { ReactNode } from 'react';\n\nimport { detectOS, type OperatingSystem } from '../helpers/platform';\n\nexport { detectOS, type OperatingSystem };\n\nexport type KbdKey =\n | 'meta'\n | 'shift'\n | 'ctrl'\n | 'enter'\n | 'delete'\n | 'escape'\n | 'tab'\n | 'capslock'\n | 'up'\n | 'right'\n | 'down'\n | 'left'\n | 'pageup'\n | 'pagedown'\n | 'home'\n | 'end'\n | 'space'\n | 'fn'\n | 'alt';\n\n/**\n * Returns OS-aware keyboard key symbols\n */\nexport function getKbdKeysMap(\n os: OperatingSystem = detectOS(),\n): Record<KbdKey, string> {\n const baseMap: Record<KbdKey, string> = {\n alt: os === 'mac' ? '⌥' : 'alt',\n capslock: '⇪',\n ctrl: os === 'mac' ? '⌃' : 'ctrl',\n delete: os === 'mac' ? '⌫' : 'delete',\n down: '↓',\n end: 'end',\n enter: '↵',\n escape: '⎋',\n fn: 'Fn',\n home: 'home',\n left: '←',\n meta: os === 'mac' ? '⌘' : os === 'windows' ? '⊞' : 'meta',\n pagedown: '⇟',\n pageup: '⇞',\n right: '→',\n shift: '⇧',\n space: '␣',\n tab: '⇥',\n up: '↑',\n };\n\n return baseMap;\n}\n\n/**\n * Returns OS-aware keyboard key labels\n */\nexport function getKbdKeysLabelMap(\n os: OperatingSystem = detectOS(),\n): Record<KbdKey, string> {\n return {\n alt: 'Alt',\n capslock: 'Caps Lock',\n ctrl: 'Control',\n delete: 'Delete',\n down: 'Down',\n end: 'End',\n enter: 'Enter',\n escape: 'Escape',\n fn: 'Fn',\n home: 'Home',\n left: 'Left',\n meta: os === 'mac' ? 'Command' : os === 'windows' ? 'Windows' : 'Meta',\n pagedown: 'Page Down',\n pageup: 'Page Up',\n right: 'Right',\n shift: 'Shift',\n space: 'Space',\n tab: 'Tab',\n up: 'Up',\n };\n}\n\nfunction resolveKeyLabel(\n key: KbdKey | ReactNode,\n labels: Record<KbdKey, string>,\n): string {\n if (key === null || key === undefined || typeof key === 'boolean') {\n return '';\n }\n if (typeof key === 'string') {\n return key in labels ? labels[key as KbdKey] : key;\n }\n if (typeof key === 'number') {\n return String(key);\n }\n return '';\n}\n\nexport function getKbdScreenReaderFriendlyText(\n keys: readonly (KbdKey | ReactNode)[] | undefined,\n modifierKeys: readonly KbdKey[] | undefined,\n os: OperatingSystem = detectOS(),\n): string {\n const labels = getKbdKeysLabelMap(os);\n const modStr = (modifierKeys ?? []).map((key) => labels[key]).join(' + ');\n const keyLabels = (keys ?? [])\n .map((key) => resolveKeyLabel(key, labels))\n .filter(Boolean);\n let keyStr = '';\n if (keyLabels.length === 1) {\n keyStr = keyLabels[0];\n } else if (keyLabels.length > 1) {\n keyStr = keyLabels.join(' then ');\n }\n const body = [modStr, keyStr].filter(Boolean).join(' + ');\n return body ? `Shortcut: ${body}` : '';\n}\n"]}
|