@sentry/scraps 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/alert/alert.js +0 -3
- package/dist/badge/badge.js +1 -2
- package/dist/badge/tag.js +0 -2
- package/dist/button/index.d.ts +0 -1
- package/dist/button/index.js +0 -1
- package/dist/clipboard/copyToClipboardButton.d.ts +15 -0
- package/dist/clipboard/copyToClipboardButton.js +32 -0
- package/dist/clipboard/index.d.ts +1 -0
- package/dist/clipboard/index.js +1 -0
- package/dist/code/index.d.ts +1 -0
- package/dist/code/index.js +1 -0
- package/dist/codeBlock/codeBlock.d.ts +68 -0
- package/dist/codeBlock/codeBlock.js +242 -0
- package/dist/codeBlock/index.d.ts +2 -0
- package/dist/codeBlock/index.js +2 -0
- package/dist/codeBlock/prism.d.ts +11 -0
- package/dist/codeBlock/prism.js +101 -0
- package/dist/codeBlock/styles.d.ts +2 -0
- package/dist/codeBlock/styles.js +133 -0
- package/dist/compactSelect/compactSelect.d.ts +21 -0
- package/dist/compactSelect/compactSelect.js +150 -0
- package/dist/compactSelect/composite.d.ts +54 -0
- package/dist/compactSelect/composite.js +101 -0
- package/dist/compactSelect/control.d.ts +112 -0
- package/dist/compactSelect/control.js +354 -0
- package/dist/compactSelect/fzf.d.ts +8 -0
- package/dist/compactSelect/fzf.js +151 -0
- package/dist/compactSelect/gridList/index.d.ts +46 -0
- package/dist/compactSelect/gridList/index.js +102 -0
- package/dist/compactSelect/gridList/option.d.ts +15 -0
- package/dist/compactSelect/gridList/option.js +111 -0
- package/dist/compactSelect/gridList/section.d.ts +15 -0
- package/dist/compactSelect/gridList/section.js +58 -0
- package/dist/compactSelect/highlightText.d.ts +6 -0
- package/dist/compactSelect/highlightText.js +33 -0
- package/dist/compactSelect/index.d.ts +9 -0
- package/dist/compactSelect/index.js +8 -0
- package/dist/compactSelect/list.d.ts +94 -0
- package/dist/compactSelect/list.js +167 -0
- package/dist/compactSelect/listBox/index.d.ts +84 -0
- package/dist/compactSelect/listBox/index.js +175 -0
- package/dist/compactSelect/listBox/option.d.ts +19 -0
- package/dist/compactSelect/listBox/option.js +101 -0
- package/dist/compactSelect/listBox/section.d.ts +21 -0
- package/dist/compactSelect/listBox/section.js +58 -0
- package/dist/compactSelect/menuComponents.d.ts +89 -0
- package/dist/compactSelect/menuComponents.js +117 -0
- package/dist/compactSelect/selectFilterContext.d.ts +2 -0
- package/dist/compactSelect/selectFilterContext.js +3 -0
- package/dist/compactSelect/styles.d.ts +39 -0
- package/dist/compactSelect/styles.js +155 -0
- package/dist/compactSelect/types.d.ts +1 -0
- package/dist/compactSelect/types.js +0 -0
- package/dist/compactSelect/useVirtualizedItems.d.ts +52 -0
- package/dist/compactSelect/useVirtualizedItems.js +74 -0
- package/dist/compactSelect/utils.d.ts +80 -0
- package/dist/compactSelect/utils.js +268 -0
- package/dist/confirm/index.d.ts +153 -0
- package/dist/confirm/index.js +132 -0
- package/dist/descriptionList/descriptionList.js +4 -3
- package/dist/disclosure/disclosure.js +2 -2
- package/dist/dragHandle/dragHandle.d.ts +3 -1
- package/dist/dragHandle/dragHandle.js +8 -5
- package/dist/drawer/components.d.ts +46 -0
- package/dist/drawer/components.js +265 -0
- package/dist/drawer/globalDrawer.d.ts +106 -0
- package/dist/drawer/globalDrawer.js +173 -0
- package/dist/drawer/index.d.ts +3 -0
- package/dist/drawer/index.js +2 -0
- package/dist/drawer/useDrawerResizing.d.ts +19 -0
- package/dist/drawer/useDrawerResizing.js +111 -0
- package/dist/drawer/useDrawerWidth.d.ts +1 -0
- package/dist/drawer/useDrawerWidth.js +42 -0
- package/dist/dropdownMenu/content.d.ts +1 -0
- package/dist/dropdownMenu/content.js +1 -0
- package/dist/dropdownMenu/context.d.ts +24 -0
- package/dist/dropdownMenu/context.js +3 -0
- package/dist/dropdownMenu/dropdownMenu.d.ts +70 -0
- package/dist/dropdownMenu/dropdownMenu.js +103 -0
- package/dist/dropdownMenu/index.d.ts +2 -0
- package/dist/dropdownMenu/index.js +1 -0
- package/dist/dropdownMenu/item.d.ts +136 -0
- package/dist/dropdownMenu/item.js +182 -0
- package/dist/dropdownMenu/list.d.ts +59 -0
- package/dist/dropdownMenu/list.js +410 -0
- package/dist/dropdownMenu/search.d.ts +16 -0
- package/dist/dropdownMenu/search.js +16 -0
- package/dist/dropdownMenu/section.d.ts +21 -0
- package/dist/dropdownMenu/section.js +40 -0
- package/dist/dropdownMenu/separator.d.ts +7 -0
- package/dist/dropdownMenu/separator.js +15 -0
- package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +260 -0
- package/dist/dropdownMenu/useDropdownMenuKeyboard.js +55 -0
- package/dist/dropdownMenu/useDropdownMenuRowLayout.d.ts +29 -0
- package/dist/dropdownMenu/useDropdownMenuRowLayout.js +64 -0
- package/dist/dropdownMenu/useSafetyTriangle.d.ts +12 -0
- package/dist/dropdownMenu/useSafetyTriangle.js +119 -0
- package/dist/dropdownMenu/utils.d.ts +21 -0
- package/dist/dropdownMenu/utils.js +57 -0
- package/dist/form/FormSearch.d.ts +19 -0
- package/dist/form/FormSearch.js +4 -0
- package/dist/form/autoSaveForm.d.ts +110 -0
- package/dist/form/autoSaveForm.js +100 -0
- package/dist/{formPresentation → form}/displayField.js +2 -2
- package/dist/form/field/baseField.d.ts +23 -0
- package/dist/form/field/baseField.js +116 -0
- package/dist/form/field/checkboxField.d.ts +11 -0
- package/dist/form/field/checkboxField.js +42 -0
- package/dist/form/field/checkboxGroupField.d.ts +16 -0
- package/dist/form/field/checkboxGroupField.js +80 -0
- package/dist/form/field/compactSelectField.d.ts +19 -0
- package/dist/form/field/compactSelectField.js +77 -0
- package/dist/{formPresentation → form/field}/fieldIds.js +1 -1
- package/dist/form/field/inputField.d.ts +19 -0
- package/dist/form/field/inputField.js +31 -0
- package/dist/{formPresentation → form/field}/meta.js +6 -6
- package/dist/form/field/numberField.d.ts +5 -0
- package/dist/form/field/numberField.js +11 -0
- package/dist/form/field/passwordField.d.ts +3 -0
- package/dist/form/field/passwordField.js +27 -0
- package/dist/form/field/radioGroupField.d.ts +16 -0
- package/dist/form/field/radioGroupField.js +92 -0
- package/dist/form/field/rangeField.d.ts +8 -0
- package/dist/form/field/rangeField.js +34 -0
- package/dist/form/field/selectAsyncField.d.ts +31 -0
- package/dist/form/field/selectAsyncField.js +22 -0
- package/dist/form/field/selectField.d.ts +9 -0
- package/dist/form/field/selectField.js +72 -0
- package/dist/form/field/switchField.d.ts +7 -0
- package/dist/form/field/switchField.js +37 -0
- package/dist/form/field/textAreaField.d.ts +7 -0
- package/dist/form/field/textAreaField.js +25 -0
- package/dist/{formPresentation → form}/formContext.js +1 -1
- package/dist/form/formErrorContext/index.d.ts +9 -0
- package/dist/form/formErrorContext/index.js +7 -0
- package/dist/form/index.d.ts +9 -0
- package/dist/form/index.js +8 -0
- package/dist/{formPresentation → form/layout}/base.d.ts +1 -1
- package/dist/{formPresentation → form/layout}/base.js +1 -1
- package/dist/form/layout/fieldGroup.d.ts +6 -0
- package/dist/form/layout/fieldGroup.js +60 -0
- package/dist/{formPresentation/fieldLayout.d.ts → form/layout/index.d.ts} +1 -1
- package/dist/{formPresentation/fieldLayout.js → form/layout/index.js} +3 -3
- package/dist/{formPresentation → form/layout}/useStackedLayout.js +1 -1
- package/dist/form/scrapsForm.d.ts +220 -0
- package/dist/form/scrapsForm.js +126 -0
- package/dist/hotkey/hotkey.d.ts +9 -8
- package/dist/hotkey/hotkey.js +13 -6
- package/dist/hotkey/index.d.ts +2 -1
- package/dist/hotkey/index.js +2 -1
- package/dist/hotkey/keyMappings.d.ts +1 -15
- package/dist/hotkey/keyMappings.js +29 -174
- package/dist/hotkey/useHotkeys.d.ts +3 -47
- package/dist/hotkey/useHotkeys.js +8 -42
- package/dist/image/image.js +2 -1
- package/dist/info/infoTip.d.ts +1 -1
- package/dist/info/infoTip.js +4 -3
- package/dist/input/index.d.ts +0 -3
- package/dist/input/index.js +0 -2
- package/dist/input/input.d.ts +2 -0
- package/dist/input/input.js +2 -0
- package/dist/input/passwordManagerIgnoreProps.d.ts +11 -0
- package/dist/input/passwordManagerIgnoreProps.js +8 -0
- package/dist/layout/index.d.ts +2 -2
- package/dist/layout/index.js +1 -1
- package/dist/link/link.js +4 -3
- package/dist/link/linkBehaviorContext.d.ts +2 -0
- package/dist/link/linkBehaviorContext.js +17 -10
- package/dist/menu/index.d.ts +1 -1
- package/dist/menu/index.js +1 -1
- package/dist/menu/menu.d.ts +14 -6
- package/dist/menu/menu.js +160 -56
- package/dist/modal/components.d.ts +19 -0
- package/dist/modal/components.js +99 -0
- package/dist/modal/errorBoundary.d.ts +2 -0
- package/dist/modal/errorBoundary.js +35 -0
- package/dist/modal/index.d.ts +33 -0
- package/dist/modal/index.js +260 -0
- package/dist/modal/portal.d.ts +1 -0
- package/dist/modal/portal.js +10 -0
- package/dist/modal/state.d.ts +17 -0
- package/dist/modal/state.js +41 -0
- package/dist/modal/types.d.ts +75 -0
- package/dist/modal/types.js +0 -0
- package/dist/numberInput/index.d.ts +3 -0
- package/dist/numberInput/index.js +2 -0
- package/dist/{input → numberInput}/numberDragInput.d.ts +1 -1
- package/dist/{input → numberInput}/numberDragInput.js +1 -1
- package/dist/{input → numberInput}/numberInput.d.ts +1 -1
- package/dist/{input → numberInput}/numberInput.js +1 -1
- package/dist/overlayContext.d.ts +29 -0
- package/dist/overlayContext.js +7 -0
- package/dist/pagination/index.d.ts +1 -0
- package/dist/pagination/index.js +1 -0
- package/dist/pagination/pagination.d.ts +24 -0
- package/dist/pagination/pagination.js +63 -0
- package/dist/pictureInPicture/index.d.ts +2 -0
- package/dist/pictureInPicture/index.js +2 -0
- package/dist/pictureInPicture/pictureInPicture.d.ts +47 -0
- package/dist/pictureInPicture/pictureInPicture.js +100 -0
- package/dist/pictureInPicture/pictureInPicturePortal.d.ts +16 -0
- package/dist/pictureInPicture/pictureInPicturePortal.js +46 -0
- package/dist/pictureInPicture/portalContext.d.ts +2 -0
- package/dist/pictureInPicture/portalContext.js +3 -0
- package/dist/revealOnHover/revealOnHover.js +1 -1
- package/dist/segmentedControl/segmentedControl.js +1 -1
- package/dist/select/filter.d.ts +4 -0
- package/dist/select/filter.js +12 -0
- package/dist/select/index.d.ts +3 -0
- package/dist/select/index.js +2 -0
- package/dist/select/option.d.ts +16 -0
- package/dist/select/option.js +81 -0
- package/dist/select/reactSelectWrapper.d.ts +8 -0
- package/dist/select/reactSelectWrapper.js +25 -0
- package/dist/select/select.d.ts +79 -0
- package/dist/select/select.js +454 -0
- package/dist/select/styles.d.ts +9 -0
- package/dist/select/styles.js +27 -0
- package/dist/select/types.d.ts +60 -0
- package/dist/select/types.js +0 -0
- package/dist/select/virtualizedMenuList.d.ts +24 -0
- package/dist/select/virtualizedMenuList.js +123 -0
- package/dist/slideOverPanel.d.ts +20 -0
- package/dist/slideOverPanel.js +141 -0
- package/dist/splitPanel/splitPanel.d.ts +3 -1
- package/dist/splitPanel/splitPanel.js +2 -1
- package/dist/table/table.d.ts +1 -1
- package/dist/table/table.js +39 -20
- package/dist/table/useColumnResize.d.ts +6 -5
- package/dist/table/useColumnResize.js +5 -4
- package/dist/tabs/index.d.ts +4 -0
- package/dist/tabs/index.js +3 -0
- package/dist/tabs/item.d.ts +13 -0
- package/dist/tabs/item.js +4 -0
- package/dist/tabs/tab.d.ts +22 -0
- package/dist/tabs/tab.js +205 -0
- package/dist/tabs/tabList.d.ts +18 -0
- package/dist/tabs/tabList.js +256 -0
- package/dist/tabs/tabPanels.d.ts +14 -0
- package/dist/tabs/tabPanels.js +62 -0
- package/dist/tabs/tabs.d.ts +38 -0
- package/dist/tabs/tabs.js +56 -0
- package/dist/tabs/utils.d.ts +3 -0
- package/dist/tabs/utils.js +6 -0
- package/dist/text/heading.d.ts +1 -1
- package/dist/text/heading.js +1 -1
- package/dist/text/styles.js +1 -1
- package/dist/text/text.d.ts +1 -1
- package/dist/text/text.js +1 -1
- package/dist/theme/dark.js +9 -9
- package/dist/theme/light.js +9 -9
- package/dist/tooltip/tooltip.js +2 -5
- package/dist/useMedia.d.ts +15 -0
- package/dist/useMedia.js +24 -0
- package/dist/useOnClickOutside.d.ts +2 -0
- package/dist/useOnClickOutside.js +22 -0
- package/dist/useOverlay.d.ts +1 -0
- package/dist/useOverlay.js +1 -0
- package/dist/useVirtualCollection.d.ts +154 -0
- package/dist/useVirtualCollection.js +143 -0
- package/dist/useVirtualRows.d.ts +26 -0
- package/dist/useVirtualRows.js +26 -0
- package/dist/virtualCollectionLayout.d.ts +51 -0
- package/dist/virtualCollectionLayout.js +49 -0
- package/package.json +115 -16
- package/dist/formPresentation/index.d.ts +0 -8
- package/dist/formPresentation/index.js +0 -8
- package/dist/interactionStateLayer/index.d.ts +0 -1
- package/dist/interactionStateLayer/index.js +0 -1
- package/dist/interactionStateLayer/interactionStateLayer.d.ts +0 -23
- package/dist/interactionStateLayer/interactionStateLayer.js +0 -67
- package/dist/unreachable.d.ts +0 -1
- package/dist/unreachable.js +0 -4
- /package/dist/{formPresentation → form}/autoSaveContext.d.ts +0 -0
- /package/dist/{formPresentation → form}/autoSaveContext.js +0 -0
- /package/dist/{formPresentation → form}/displayField.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/fieldIds.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/groupContext.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/groupContext.js +0 -0
- /package/dist/{formPresentation → form/field}/meta.d.ts +0 -0
- /package/dist/{formPresentation → form}/formContext.d.ts +0 -0
- /package/dist/{formPresentation → form}/icons.d.ts +0 -0
- /package/dist/{formPresentation → form}/icons.js +0 -0
- /package/dist/{formPresentation → form/layout}/useStackedLayout.d.ts +0 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { formOptions, type AnyFormApi, type DeepKeys } from '@tanstack/react-form';
|
|
3
|
+
import { type ButtonProps } from '../button/index.js';
|
|
4
|
+
import { BaseField } from './field/baseField.js';
|
|
5
|
+
import { CheckboxField } from './field/checkboxField.js';
|
|
6
|
+
import { FieldMeta } from './field/meta.js';
|
|
7
|
+
import { FieldLayout } from './layout/index.js';
|
|
8
|
+
import { FieldGroup } from './layout/fieldGroup.js';
|
|
9
|
+
import { CompactSelectField } from './field/compactSelectField.js';
|
|
10
|
+
import { InputField } from './field/inputField.js';
|
|
11
|
+
import { NumberField } from './field/numberField.js';
|
|
12
|
+
import { PasswordField } from './field/passwordField.js';
|
|
13
|
+
import { RangeField } from './field/rangeField.js';
|
|
14
|
+
import { SelectAsyncField } from './field/selectAsyncField.js';
|
|
15
|
+
import { SelectField } from './field/selectField.js';
|
|
16
|
+
import { SwitchField } from './field/switchField.js';
|
|
17
|
+
import { TextAreaField } from './field/textAreaField.js';
|
|
18
|
+
export declare const defaultFormOptions: {
|
|
19
|
+
onSubmitInvalid({ formApi, }: {
|
|
20
|
+
formApi: {
|
|
21
|
+
formId: string;
|
|
22
|
+
validateSync: (cause: "submit") => unknown;
|
|
23
|
+
};
|
|
24
|
+
}): void;
|
|
25
|
+
validationLogic: import("@tanstack/react-form").ValidationLogicFn;
|
|
26
|
+
};
|
|
27
|
+
declare const fieldComponents: {
|
|
28
|
+
readonly Base: typeof BaseField;
|
|
29
|
+
readonly Checkbox: typeof CheckboxField;
|
|
30
|
+
readonly CheckboxGroup: <T extends string>(props: import("./field/checkboxGroupField.js").CheckboxGroupProps<T>) => React.JSX.Element;
|
|
31
|
+
readonly CompactSelect: typeof CompactSelectField;
|
|
32
|
+
readonly Input: typeof InputField;
|
|
33
|
+
readonly Number: typeof NumberField;
|
|
34
|
+
readonly Password: typeof PasswordField;
|
|
35
|
+
readonly RadioGroup: <T extends string>(props: import("./field/radioGroupField.js").RadioGroupProps<T>) => React.JSX.Element;
|
|
36
|
+
readonly Range: typeof RangeField;
|
|
37
|
+
readonly Select: typeof SelectField;
|
|
38
|
+
readonly SelectAsync: typeof SelectAsyncField;
|
|
39
|
+
readonly Switch: typeof SwitchField;
|
|
40
|
+
readonly TextArea: typeof TextAreaField;
|
|
41
|
+
readonly Meta: typeof FieldMeta;
|
|
42
|
+
readonly Layout: typeof FieldLayout;
|
|
43
|
+
};
|
|
44
|
+
export type BoundFieldComponents = typeof fieldComponents;
|
|
45
|
+
declare const withFieldGroup: <TFieldGroupData, TSubmitMeta, TRenderProps extends object = {}>({ render, props, defaultValues, }: import("@tanstack/react-form").WithFieldGroupProps<TFieldGroupData, {
|
|
46
|
+
readonly Base: typeof BaseField;
|
|
47
|
+
readonly Checkbox: typeof CheckboxField;
|
|
48
|
+
readonly CheckboxGroup: <T extends string>(props: import("./field/checkboxGroupField.js").CheckboxGroupProps<T>) => React.JSX.Element;
|
|
49
|
+
readonly CompactSelect: typeof CompactSelectField;
|
|
50
|
+
readonly Input: typeof InputField;
|
|
51
|
+
readonly Number: typeof NumberField;
|
|
52
|
+
readonly Password: typeof PasswordField;
|
|
53
|
+
readonly RadioGroup: <T extends string>(props: import("./field/radioGroupField.js").RadioGroupProps<T>) => React.JSX.Element;
|
|
54
|
+
readonly Range: typeof RangeField;
|
|
55
|
+
readonly Select: typeof SelectField;
|
|
56
|
+
readonly SelectAsync: typeof SelectAsyncField;
|
|
57
|
+
readonly Switch: typeof SwitchField;
|
|
58
|
+
readonly TextArea: typeof TextAreaField;
|
|
59
|
+
readonly Meta: typeof FieldMeta;
|
|
60
|
+
readonly Layout: typeof FieldLayout;
|
|
61
|
+
}, {
|
|
62
|
+
readonly FieldGroup: typeof FieldGroup;
|
|
63
|
+
readonly SubmitButton: typeof SubmitButton;
|
|
64
|
+
readonly ResetButton: typeof ResetButton;
|
|
65
|
+
readonly AppForm: typeof AppForm;
|
|
66
|
+
}, TSubmitMeta, TRenderProps>) => <TFormData, TFields extends import("@tanstack/react-form").DeepKeysOfType<TFormData, TFieldGroupData | null | undefined> | import("@tanstack/react-form").FieldsMap<TFormData, TFieldGroupData>, TOnMount extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnChange extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnChangeAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnBlur extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnBlurAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnSubmit extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnSubmitAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnDynamic extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnDynamicAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnServer extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TFormSubmitMeta>(params: React.PropsWithChildren<NoInfer<TRenderProps> & {
|
|
67
|
+
form: import("@tanstack/react-form").AppFieldExtendedReactFormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, unknown extends TSubmitMeta ? TFormSubmitMeta : TSubmitMeta, {
|
|
68
|
+
readonly Base: typeof BaseField;
|
|
69
|
+
readonly Checkbox: typeof CheckboxField;
|
|
70
|
+
readonly CheckboxGroup: <T extends string>(props: import("./field/checkboxGroupField.js").CheckboxGroupProps<T>) => React.JSX.Element;
|
|
71
|
+
readonly CompactSelect: typeof CompactSelectField;
|
|
72
|
+
readonly Input: typeof InputField;
|
|
73
|
+
readonly Number: typeof NumberField;
|
|
74
|
+
readonly Password: typeof PasswordField;
|
|
75
|
+
readonly RadioGroup: <T extends string>(props: import("./field/radioGroupField.js").RadioGroupProps<T>) => React.JSX.Element;
|
|
76
|
+
readonly Range: typeof RangeField;
|
|
77
|
+
readonly Select: typeof SelectField;
|
|
78
|
+
readonly SelectAsync: typeof SelectAsyncField;
|
|
79
|
+
readonly Switch: typeof SwitchField;
|
|
80
|
+
readonly TextArea: typeof TextAreaField;
|
|
81
|
+
readonly Meta: typeof FieldMeta;
|
|
82
|
+
readonly Layout: typeof FieldLayout;
|
|
83
|
+
}, {
|
|
84
|
+
readonly FieldGroup: typeof FieldGroup;
|
|
85
|
+
readonly SubmitButton: typeof SubmitButton;
|
|
86
|
+
readonly ResetButton: typeof ResetButton;
|
|
87
|
+
readonly AppForm: typeof AppForm;
|
|
88
|
+
}> | import("@tanstack/react-form").AppFieldExtendedReactFieldGroupApi<unknown, TFormData, string | import("@tanstack/react-form").FieldsMap<unknown, TFormData>, any, any, any, any, any, any, any, any, any, any, unknown extends TSubmitMeta ? TFormSubmitMeta : TSubmitMeta, {
|
|
89
|
+
readonly Base: typeof BaseField;
|
|
90
|
+
readonly Checkbox: typeof CheckboxField;
|
|
91
|
+
readonly CheckboxGroup: <T extends string>(props: import("./field/checkboxGroupField.js").CheckboxGroupProps<T>) => React.JSX.Element;
|
|
92
|
+
readonly CompactSelect: typeof CompactSelectField;
|
|
93
|
+
readonly Input: typeof InputField;
|
|
94
|
+
readonly Number: typeof NumberField;
|
|
95
|
+
readonly Password: typeof PasswordField;
|
|
96
|
+
readonly RadioGroup: <T extends string>(props: import("./field/radioGroupField.js").RadioGroupProps<T>) => React.JSX.Element;
|
|
97
|
+
readonly Range: typeof RangeField;
|
|
98
|
+
readonly Select: typeof SelectField;
|
|
99
|
+
readonly SelectAsync: typeof SelectAsyncField;
|
|
100
|
+
readonly Switch: typeof SwitchField;
|
|
101
|
+
readonly TextArea: typeof TextAreaField;
|
|
102
|
+
readonly Meta: typeof FieldMeta;
|
|
103
|
+
readonly Layout: typeof FieldLayout;
|
|
104
|
+
}, {
|
|
105
|
+
readonly FieldGroup: typeof FieldGroup;
|
|
106
|
+
readonly SubmitButton: typeof SubmitButton;
|
|
107
|
+
readonly ResetButton: typeof ResetButton;
|
|
108
|
+
readonly AppForm: typeof AppForm;
|
|
109
|
+
}>;
|
|
110
|
+
fields: TFields;
|
|
111
|
+
}>) => ReturnType<React.FunctionComponent>, withForm: <TFormData, TOnMount extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnChange extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnChangeAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnBlur extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnBlurAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnSubmit extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnSubmitAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnDynamic extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnDynamicAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnServer extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TSubmitMeta, TRenderProps extends object = {}>({ render, props, }: import("@tanstack/react-form").WithFormProps<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
|
|
112
|
+
readonly Base: typeof BaseField;
|
|
113
|
+
readonly Checkbox: typeof CheckboxField;
|
|
114
|
+
readonly CheckboxGroup: <T extends string>(props: import("./field/checkboxGroupField.js").CheckboxGroupProps<T>) => React.JSX.Element;
|
|
115
|
+
readonly CompactSelect: typeof CompactSelectField;
|
|
116
|
+
readonly Input: typeof InputField;
|
|
117
|
+
readonly Number: typeof NumberField;
|
|
118
|
+
readonly Password: typeof PasswordField;
|
|
119
|
+
readonly RadioGroup: <T extends string>(props: import("./field/radioGroupField.js").RadioGroupProps<T>) => React.JSX.Element;
|
|
120
|
+
readonly Range: typeof RangeField;
|
|
121
|
+
readonly Select: typeof SelectField;
|
|
122
|
+
readonly SelectAsync: typeof SelectAsyncField;
|
|
123
|
+
readonly Switch: typeof SwitchField;
|
|
124
|
+
readonly TextArea: typeof TextAreaField;
|
|
125
|
+
readonly Meta: typeof FieldMeta;
|
|
126
|
+
readonly Layout: typeof FieldLayout;
|
|
127
|
+
}, {
|
|
128
|
+
readonly FieldGroup: typeof FieldGroup;
|
|
129
|
+
readonly SubmitButton: typeof SubmitButton;
|
|
130
|
+
readonly ResetButton: typeof ResetButton;
|
|
131
|
+
readonly AppForm: typeof AppForm;
|
|
132
|
+
}, TRenderProps>) => React.FunctionComponent<React.PropsWithChildren<NoInfer<[unknown] extends [TRenderProps] ? any : TRenderProps> & {
|
|
133
|
+
form: import("@tanstack/react-form").AppFieldExtendedReactFormApi<[unknown] extends [TFormData] ? any : TFormData, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnMount] ? [TOnMount] extends [TOnMount & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnMount : TOnMount, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnChange] ? [TOnChange] extends [TOnChange & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnChange : TOnChange, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnChangeAsync] ? [TOnChangeAsync] extends [TOnChangeAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnChangeAsync : TOnChangeAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnBlur] ? [TOnBlur] extends [TOnBlur & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnBlur : TOnBlur, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnBlurAsync] ? [TOnBlurAsync] extends [TOnBlurAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnBlurAsync : TOnBlurAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnSubmit] ? [TOnSubmit] extends [TOnSubmit & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnSubmit : TOnSubmit, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnSubmitAsync] ? [TOnSubmitAsync] extends [TOnSubmitAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnSubmitAsync : TOnSubmitAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnDynamic] ? [TOnDynamic] extends [TOnDynamic & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnDynamic : TOnDynamic, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnDynamicAsync] ? [TOnDynamicAsync] extends [TOnDynamicAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnDynamicAsync : TOnDynamicAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnServer] ? [TOnServer] extends [TOnServer & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnServer : TOnServer, [unknown] extends [TSubmitMeta] ? any : TSubmitMeta, {
|
|
134
|
+
readonly Base: typeof BaseField;
|
|
135
|
+
readonly Checkbox: typeof CheckboxField;
|
|
136
|
+
readonly CheckboxGroup: <T extends string>(props: import("./field/checkboxGroupField.js").CheckboxGroupProps<T>) => React.JSX.Element;
|
|
137
|
+
readonly CompactSelect: typeof CompactSelectField;
|
|
138
|
+
readonly Input: typeof InputField;
|
|
139
|
+
readonly Number: typeof NumberField;
|
|
140
|
+
readonly Password: typeof PasswordField;
|
|
141
|
+
readonly RadioGroup: <T extends string>(props: import("./field/radioGroupField.js").RadioGroupProps<T>) => React.JSX.Element;
|
|
142
|
+
readonly Range: typeof RangeField;
|
|
143
|
+
readonly Select: typeof SelectField;
|
|
144
|
+
readonly SelectAsync: typeof SelectAsyncField;
|
|
145
|
+
readonly Switch: typeof SwitchField;
|
|
146
|
+
readonly TextArea: typeof TextAreaField;
|
|
147
|
+
readonly Meta: typeof FieldMeta;
|
|
148
|
+
readonly Layout: typeof FieldLayout;
|
|
149
|
+
}, {
|
|
150
|
+
readonly FieldGroup: typeof FieldGroup;
|
|
151
|
+
readonly SubmitButton: typeof SubmitButton;
|
|
152
|
+
readonly ResetButton: typeof ResetButton;
|
|
153
|
+
readonly AppForm: typeof AppForm;
|
|
154
|
+
}>;
|
|
155
|
+
}>>;
|
|
156
|
+
declare function SubmitButton(props: ButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
157
|
+
declare function ResetButton(props: ButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
158
|
+
declare function AppForm({ children, form }: {
|
|
159
|
+
children: React.ReactNode;
|
|
160
|
+
form: AnyFormApi;
|
|
161
|
+
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
162
|
+
export declare const useScrapsForm: <TFormData, TOnMount extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnChange extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnChangeAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnBlur extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnBlurAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnSubmit extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnSubmitAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnDynamic extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnDynamicAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnServer extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TSubmitMeta>(props: import("@tanstack/react-form").FormOptions<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta>) => import("@tanstack/react-form").AppFieldExtendedReactFormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
|
|
163
|
+
readonly Base: typeof BaseField;
|
|
164
|
+
readonly Checkbox: typeof CheckboxField;
|
|
165
|
+
readonly CheckboxGroup: <T extends string>(props: import("./field/checkboxGroupField.js").CheckboxGroupProps<T>) => React.JSX.Element;
|
|
166
|
+
readonly CompactSelect: typeof CompactSelectField;
|
|
167
|
+
readonly Input: typeof InputField;
|
|
168
|
+
readonly Number: typeof NumberField;
|
|
169
|
+
readonly Password: typeof PasswordField;
|
|
170
|
+
readonly RadioGroup: <T extends string>(props: import("./field/radioGroupField.js").RadioGroupProps<T>) => React.JSX.Element;
|
|
171
|
+
readonly Range: typeof RangeField;
|
|
172
|
+
readonly Select: typeof SelectField;
|
|
173
|
+
readonly SelectAsync: typeof SelectAsyncField;
|
|
174
|
+
readonly Switch: typeof SwitchField;
|
|
175
|
+
readonly TextArea: typeof TextAreaField;
|
|
176
|
+
readonly Meta: typeof FieldMeta;
|
|
177
|
+
readonly Layout: typeof FieldLayout;
|
|
178
|
+
}, {
|
|
179
|
+
readonly FieldGroup: typeof FieldGroup;
|
|
180
|
+
readonly SubmitButton: typeof SubmitButton;
|
|
181
|
+
readonly ResetButton: typeof ResetButton;
|
|
182
|
+
readonly AppForm: typeof AppForm;
|
|
183
|
+
}>;
|
|
184
|
+
/** @public */
|
|
185
|
+
export { formOptions, withFieldGroup, withForm };
|
|
186
|
+
/**
|
|
187
|
+
* Type for field errors that can be set after form submission (e.g., from backend validation).
|
|
188
|
+
* Keys are constrained to valid field paths (including nested paths like 'address.city').
|
|
189
|
+
*/
|
|
190
|
+
export type FieldErrors<TFormData> = Partial<Record<DeepKeys<TFormData>, {
|
|
191
|
+
message: string;
|
|
192
|
+
}>>;
|
|
193
|
+
/**
|
|
194
|
+
* Infers the form data type from a form API instance.
|
|
195
|
+
*/
|
|
196
|
+
type InferFormData<T> = T extends {
|
|
197
|
+
state: {
|
|
198
|
+
values: infer D;
|
|
199
|
+
};
|
|
200
|
+
} ? D : never;
|
|
201
|
+
/**
|
|
202
|
+
* Sets field errors on a form after submission (e.g., from backend validation).
|
|
203
|
+
* This provides a type-safe way to set errors on specific fields.
|
|
204
|
+
*
|
|
205
|
+
* @returns `true` if field errors were set, or `false` if the object was empty.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```tsx
|
|
209
|
+
* setFieldErrors(formApi, {
|
|
210
|
+
* firstName: { message: 'This name is already taken' },
|
|
211
|
+
* 'address.city': { message: 'City not found' },
|
|
212
|
+
* });
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
export declare function setFieldErrors<TForm extends {
|
|
216
|
+
setErrorMap: (...args: any[]) => unknown;
|
|
217
|
+
state: {
|
|
218
|
+
values: unknown;
|
|
219
|
+
};
|
|
220
|
+
}>(formApi: TForm, errors: FieldErrors<InferFormData<TForm>>): boolean;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { createFormHook, formOptions, revalidateLogic } from "@tanstack/react-form";
|
|
3
|
+
import { Button } from "../button/index.js";
|
|
4
|
+
import { BaseField } from "./field/baseField.js";
|
|
5
|
+
import { CheckboxField } from "./field/checkboxField.js";
|
|
6
|
+
import { FieldMeta } from "./field/meta.js";
|
|
7
|
+
import { FormElementContext, fieldContext, formContext, useFormContext, useIsInsideFormElement } from "./formContext.js";
|
|
8
|
+
import { FieldLayout } from "./layout/index.js";
|
|
9
|
+
import { FieldGroup } from "./layout/fieldGroup.js";
|
|
10
|
+
import { CheckboxGroupField } from "./field/checkboxGroupField.js";
|
|
11
|
+
import { CompactSelectField } from "./field/compactSelectField.js";
|
|
12
|
+
import { InputField } from "./field/inputField.js";
|
|
13
|
+
import { NumberField } from "./field/numberField.js";
|
|
14
|
+
import { PasswordField } from "./field/passwordField.js";
|
|
15
|
+
import { RadioGroupField } from "./field/radioGroupField.js";
|
|
16
|
+
import { RangeField } from "./field/rangeField.js";
|
|
17
|
+
import { SelectAsyncField } from "./field/selectAsyncField.js";
|
|
18
|
+
import { SelectField } from "./field/selectField.js";
|
|
19
|
+
import { SwitchField } from "./field/switchField.js";
|
|
20
|
+
import { TextAreaField } from "./field/textAreaField.js";
|
|
21
|
+
const defaultFormOptions = formOptions({
|
|
22
|
+
onSubmitInvalid ({ formApi }) {
|
|
23
|
+
formApi.validateSync('submit');
|
|
24
|
+
const InvalidInput = document.querySelector(`#${CSS.escape(formApi.formId)} [aria-invalid="true"]`);
|
|
25
|
+
InvalidInput?.focus();
|
|
26
|
+
},
|
|
27
|
+
validationLogic: revalidateLogic({
|
|
28
|
+
mode: 'submit',
|
|
29
|
+
modeAfterSubmission: 'change'
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
const fieldComponents = {
|
|
33
|
+
Base: BaseField,
|
|
34
|
+
Checkbox: CheckboxField,
|
|
35
|
+
CheckboxGroup: CheckboxGroupField,
|
|
36
|
+
CompactSelect: CompactSelectField,
|
|
37
|
+
Input: InputField,
|
|
38
|
+
Number: NumberField,
|
|
39
|
+
Password: PasswordField,
|
|
40
|
+
RadioGroup: RadioGroupField,
|
|
41
|
+
Range: RangeField,
|
|
42
|
+
Select: SelectField,
|
|
43
|
+
SelectAsync: SelectAsyncField,
|
|
44
|
+
Switch: SwitchField,
|
|
45
|
+
TextArea: TextAreaField,
|
|
46
|
+
Meta: FieldMeta,
|
|
47
|
+
Layout: FieldLayout
|
|
48
|
+
};
|
|
49
|
+
const { useAppForm, withFieldGroup, withForm } = createFormHook({
|
|
50
|
+
fieldComponents,
|
|
51
|
+
formComponents: {
|
|
52
|
+
FieldGroup: FieldGroup,
|
|
53
|
+
SubmitButton,
|
|
54
|
+
ResetButton,
|
|
55
|
+
AppForm
|
|
56
|
+
},
|
|
57
|
+
fieldContext: fieldContext,
|
|
58
|
+
formContext: formContext
|
|
59
|
+
});
|
|
60
|
+
function SubmitButton(props) {
|
|
61
|
+
const form = useFormContext();
|
|
62
|
+
const isInsideForm = useIsInsideFormElement();
|
|
63
|
+
return /*#__PURE__*/ jsx(form.Subscribe, {
|
|
64
|
+
selector: (state)=>state.isSubmitting,
|
|
65
|
+
children: (isSubmitting)=>/*#__PURE__*/ jsx(Button, {
|
|
66
|
+
variant: "primary",
|
|
67
|
+
...props,
|
|
68
|
+
type: "submit",
|
|
69
|
+
form: isInsideForm ? void 0 : form.formId,
|
|
70
|
+
busy: isSubmitting || props.busy,
|
|
71
|
+
disabled: isSubmitting || props.disabled
|
|
72
|
+
})
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function ResetButton(props) {
|
|
76
|
+
const form = useFormContext();
|
|
77
|
+
return /*#__PURE__*/ jsx(form.Subscribe, {
|
|
78
|
+
selector: (state)=>state.isPristine,
|
|
79
|
+
children: (isPristine)=>/*#__PURE__*/ jsx(Button, {
|
|
80
|
+
...props,
|
|
81
|
+
disabled: props.disabled || isPristine,
|
|
82
|
+
onClick: (e)=>{
|
|
83
|
+
form.reset();
|
|
84
|
+
props.onClick?.(e);
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function AppForm({ children, form }) {
|
|
90
|
+
return /*#__PURE__*/ jsx(formContext.Provider, {
|
|
91
|
+
value: form,
|
|
92
|
+
children: /*#__PURE__*/ jsx(FormWrapper, {
|
|
93
|
+
children: children
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function FormWrapper({ children }) {
|
|
98
|
+
const form = useFormContext();
|
|
99
|
+
return /*#__PURE__*/ jsx("form", {
|
|
100
|
+
noValidate: true,
|
|
101
|
+
"data-test-id": form.formId,
|
|
102
|
+
id: form.formId,
|
|
103
|
+
style: {
|
|
104
|
+
width: '100%'
|
|
105
|
+
},
|
|
106
|
+
onSubmit: (e)=>{
|
|
107
|
+
e.preventDefault();
|
|
108
|
+
form.handleSubmit();
|
|
109
|
+
},
|
|
110
|
+
children: /*#__PURE__*/ jsx(FormElementContext.Provider, {
|
|
111
|
+
value: true,
|
|
112
|
+
children: children
|
|
113
|
+
})
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
const useScrapsForm = useAppForm;
|
|
117
|
+
function setFieldErrors(formApi, errors) {
|
|
118
|
+
if (0 === Object.keys(errors).length) return false;
|
|
119
|
+
formApi.setErrorMap({
|
|
120
|
+
onSubmit: {
|
|
121
|
+
fields: errors
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
export { defaultFormOptions, formOptions, setFieldErrors, useScrapsForm, withFieldGroup, withForm };
|
package/dist/hotkey/hotkey.d.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
+
import { type CanonicalModifier, type HotkeyChord } from '@tanstack/react-hotkeys';
|
|
1
2
|
interface HotkeyProps {
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
4
|
+
* Shortcuts in TanStack's native syntax, such as `"Mod+K"` or `"Shift+Enter"`.
|
|
5
|
+
* A single modifier can also be displayed, such as `"Mod"` or `"Shift"`.
|
|
5
6
|
*
|
|
6
7
|
* Platform modifiers are mapped automatically:
|
|
7
|
-
* - `
|
|
8
|
-
* - `
|
|
9
|
-
* - `
|
|
8
|
+
* - `Mod` renders as `⌘` on Mac, `Ctrl` on other platforms
|
|
9
|
+
* - `Control` renders as `⌃` on Mac, `Ctrl` on other platforms
|
|
10
|
+
* - `Alt` renders as `⌥` on Mac, `Alt` on other platforms
|
|
10
11
|
*
|
|
11
12
|
* Pass an array only when the actual keys differ across platforms
|
|
12
|
-
* (not just modifier names). The first
|
|
13
|
+
* (not just modifier names). The first combo is displayed:
|
|
13
14
|
*
|
|
14
15
|
* ```tsx
|
|
15
|
-
* <Hotkey value={['
|
|
16
|
+
* <Hotkey value={['Mod+Backspace', 'Delete']} />
|
|
16
17
|
* ```
|
|
17
18
|
*/
|
|
18
|
-
value:
|
|
19
|
+
value: HotkeyChord | CanonicalModifier | 'Mod' | readonly HotkeyChord[];
|
|
19
20
|
variant?: 'embossed' | 'debossed';
|
|
20
21
|
}
|
|
21
22
|
export declare function Hotkey({ value, variant }: HotkeyProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
|
package/dist/hotkey/hotkey.js
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import styled from "@emotion/styled";
|
|
3
|
+
import { isMac } from "@react-aria/utils";
|
|
4
|
+
import { formatForDisplay } from "@tanstack/react-hotkeys";
|
|
3
5
|
import { Kbd } from "./kbd.js";
|
|
4
6
|
import { resolveKeyGlyph } from "./keyMappings.js";
|
|
5
7
|
function Hotkey({ value, variant }) {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const hotkey = 'string' == typeof value ? value : value[0];
|
|
9
|
+
if (!hotkey) return null;
|
|
10
|
+
const finalKeys = formatForDisplay(hotkey, {
|
|
11
|
+
platform: isMac() ? 'mac' : 'linux',
|
|
12
|
+
parts: true,
|
|
13
|
+
keyLabels: {
|
|
14
|
+
Delete: 'Del',
|
|
15
|
+
Tab: 'Tab',
|
|
16
|
+
Space: 'Space'
|
|
17
|
+
}
|
|
18
|
+
}).map(resolveKeyGlyph);
|
|
12
19
|
return /*#__PURE__*/ jsx(WrapperKbd, {
|
|
13
20
|
variant: variant,
|
|
14
21
|
children: finalKeys.map((glyph, i)=>'icon' in glyph ? /*#__PURE__*/ jsx(StyledKbd, {
|
package/dist/hotkey/index.d.ts
CHANGED
package/dist/hotkey/index.js
CHANGED
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
import type * as React from 'react';
|
|
2
|
-
export declare function canonicalize(keyName: string): string;
|
|
3
|
-
export declare const MODIFIER_KEYS: readonly ["command", "shift", "control", "alt"];
|
|
4
|
-
/**
|
|
5
|
-
* Tests whether a single key name from a hotkey match string is currently
|
|
6
|
-
* pressed in the given keyboard event. Layout-aware: matches against
|
|
7
|
-
* `event.key` (so an AZERTY user pressing the K-labeled key fires `'k'`
|
|
8
|
-
* shortcuts) with `event.code` as a physical-position fallback (so
|
|
9
|
-
* `shift+1` works even though `event.key === '!'` on US QWERTY).
|
|
10
|
-
*/
|
|
11
|
-
export declare function matchesKey(name: string, event: KeyboardEvent): boolean;
|
|
12
2
|
type KeyGlyph = {
|
|
13
3
|
icon: React.ReactNode;
|
|
14
4
|
label: string;
|
|
15
5
|
} | {
|
|
16
6
|
label: string;
|
|
17
7
|
};
|
|
18
|
-
|
|
19
|
-
* Resolve a key name to its display glyph for the given platform.
|
|
20
|
-
* Non-special keys fall through to title-cased text (e.g. `'k'` → `'K'`).
|
|
21
|
-
*/
|
|
22
|
-
export declare function resolveKeyGlyph(keyName: string): KeyGlyph;
|
|
8
|
+
export declare function resolveKeyGlyph(label: string): KeyGlyph;
|
|
23
9
|
export {};
|