@knkcs/anker 2.6.4 → 2.8.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/dist/atoms/index.d.ts +14 -1
- package/dist/atoms/index.js +23 -1
- package/dist/atoms/index.js.map +1 -1
- package/dist/chunk-77EOXDGW.js +49 -0
- package/dist/chunk-77EOXDGW.js.map +1 -0
- package/dist/chunk-7KPPPE4U.js +59 -0
- package/dist/chunk-7KPPPE4U.js.map +1 -0
- package/dist/chunk-CWBQKGL4.js +75 -0
- package/dist/chunk-CWBQKGL4.js.map +1 -0
- package/dist/forms/index.d.ts +12 -9
- package/dist/forms/index.js +5 -21
- package/dist/forms/index.js.map +1 -1
- package/dist/navigation/index.d.ts +26 -0
- package/dist/navigation/index.js +28 -0
- package/dist/navigation/index.js.map +1 -0
- package/dist/primitives/index.js +2 -1
- package/dist/primitives/index.js.map +1 -1
- package/dist/unsaved-changes-guard-kwzxMb6r.d.ts +67 -0
- package/package.json +6 -1
- package/dist/chunk-M5WNB4K6.js +0 -126
- package/dist/chunk-M5WNB4K6.js.map +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Dialog, Portal, ButtonGroup, Button } from '@chakra-ui/react';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
// src/primitives/leave-page-confirmation.tsx
|
|
6
|
+
var LeavePageConfirmation = (props) => {
|
|
7
|
+
const {
|
|
8
|
+
blocked,
|
|
9
|
+
onConfirmLeave,
|
|
10
|
+
onCancelLeave,
|
|
11
|
+
title = "You have unsaved changes",
|
|
12
|
+
message = "Are you sure you want to leave this page? You have unsaved changes.",
|
|
13
|
+
confirmLabel = "Leave",
|
|
14
|
+
cancelLabel = "Stay"
|
|
15
|
+
} = props;
|
|
16
|
+
const cancelRef = useRef(null);
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
Dialog.Root,
|
|
19
|
+
{
|
|
20
|
+
open: blocked,
|
|
21
|
+
initialFocusEl: () => cancelRef.current,
|
|
22
|
+
role: "alertdialog",
|
|
23
|
+
onOpenChange: (e) => {
|
|
24
|
+
if (!e.open) {
|
|
25
|
+
onCancelLeave();
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
children: /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(Dialog.Backdrop, { children: /* @__PURE__ */ jsx(Dialog.Positioner, { children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
|
|
29
|
+
/* @__PURE__ */ jsx(Dialog.Header, { fontSize: "lg", fontWeight: "bold", children: title }),
|
|
30
|
+
/* @__PURE__ */ jsx(Dialog.Body, { children: message }),
|
|
31
|
+
/* @__PURE__ */ jsx(Dialog.Footer, { children: /* @__PURE__ */ jsxs(ButtonGroup, { children: [
|
|
32
|
+
/* @__PURE__ */ jsx(
|
|
33
|
+
Button,
|
|
34
|
+
{
|
|
35
|
+
variant: "solid",
|
|
36
|
+
colorPalette: "primary",
|
|
37
|
+
onClick: onConfirmLeave,
|
|
38
|
+
children: confirmLabel
|
|
39
|
+
}
|
|
40
|
+
),
|
|
41
|
+
/* @__PURE__ */ jsx(
|
|
42
|
+
Button,
|
|
43
|
+
{
|
|
44
|
+
variant: "outline",
|
|
45
|
+
onClick: onCancelLeave,
|
|
46
|
+
ref: cancelRef,
|
|
47
|
+
children: cancelLabel
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
] }) })
|
|
51
|
+
] }) }) }) })
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
LeavePageConfirmation.displayName = "LeavePageConfirmation";
|
|
56
|
+
|
|
57
|
+
export { LeavePageConfirmation };
|
|
58
|
+
//# sourceMappingURL=chunk-7KPPPE4U.js.map
|
|
59
|
+
//# sourceMappingURL=chunk-7KPPPE4U.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../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EAAQ,OAAA;AAAA,cACR,YAAA,EAAa,SAAA;AAAA,cACb,OAAA,EAAS,cAAA;AAAA,cAER,QAAA,EAAA;AAAA;AAAA,WACF;AAAA,0BACA,GAAA;AAAA,YAAC,MAAA;AAAA,YAAA;AAAA,cACA,OAAA,EAAQ,SAAA;AAAA,cACR,OAAA,EAAS,aAAA;AAAA,cACT,GAAA,EAAK,SAAA;AAAA,cAEJ,QAAA,EAAA;AAAA;AAAA;AACF,SAAA,EACD,CAAA,EACD;AAAA,OAAA,EACD,CAAA,EACD,GACD,CAAA,EACD;AAAA;AAAA,GACD;AAEF;AACA,qBAAA,CAAsB,WAAA,GAAc,uBAAA","file":"chunk-7KPPPE4U.js","sourcesContent":["import { Button, ButtonGroup, Dialog, Portal } from \"@chakra-ui/react\";\nimport type React from \"react\";\nimport { useRef } from \"react\";\n\nexport interface LeavePageConfirmationProps {\n\t/** Whether the dialog is currently open (i.e., navigation is blocked). */\n\tblocked: boolean;\n\t/** Called when the user confirms they want to leave. */\n\tonConfirmLeave: () => void;\n\t/** Called when the user cancels and wants to stay. */\n\tonCancelLeave: () => void;\n\t/** Dialog title. Defaults to \"You have unsaved changes\". */\n\ttitle?: string;\n\t/** Dialog message body. Defaults to a generic unsaved-changes prompt. */\n\tmessage?: string;\n\t/** Label for the confirm/leave button. Defaults to \"Leave\". */\n\tconfirmLabel?: string;\n\t/** Label for the cancel/stay button. Defaults to \"Stay\". */\n\tcancelLabel?: string;\n}\n\nexport const LeavePageConfirmation: React.FC<LeavePageConfirmationProps> = (\n\tprops,\n) => {\n\tconst {\n\t\tblocked,\n\t\tonConfirmLeave,\n\t\tonCancelLeave,\n\t\ttitle = \"You have unsaved changes\",\n\t\tmessage = \"Are you sure you want to leave this page? You have unsaved changes.\",\n\t\tconfirmLabel = \"Leave\",\n\t\tcancelLabel = \"Stay\",\n\t} = props;\n\n\tconst cancelRef = useRef<HTMLButtonElement | null>(null);\n\n\treturn (\n\t\t<Dialog.Root\n\t\t\topen={blocked}\n\t\t\tinitialFocusEl={() => cancelRef.current}\n\t\t\trole=\"alertdialog\"\n\t\t\tonOpenChange={(e) => {\n\t\t\t\tif (!e.open) {\n\t\t\t\t\tonCancelLeave();\n\t\t\t\t}\n\t\t\t}}\n\t\t>\n\t\t\t<Portal>\n\t\t\t\t<Dialog.Backdrop>\n\t\t\t\t\t<Dialog.Positioner>\n\t\t\t\t\t\t<Dialog.Content>\n\t\t\t\t\t\t\t<Dialog.Header fontSize=\"lg\" fontWeight=\"bold\">\n\t\t\t\t\t\t\t\t{title}\n\t\t\t\t\t\t\t</Dialog.Header>\n\t\t\t\t\t\t\t<Dialog.Body>{message}</Dialog.Body>\n\t\t\t\t\t\t\t<Dialog.Footer>\n\t\t\t\t\t\t\t\t<ButtonGroup>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\t\t\t\t\tcolorPalette=\"primary\"\n\t\t\t\t\t\t\t\t\t\tonClick={onConfirmLeave}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{confirmLabel}\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\t\t\t\t\tonClick={onCancelLeave}\n\t\t\t\t\t\t\t\t\t\tref={cancelRef}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{cancelLabel}\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t</ButtonGroup>\n\t\t\t\t\t\t\t</Dialog.Footer>\n\t\t\t\t\t\t</Dialog.Content>\n\t\t\t\t\t</Dialog.Positioner>\n\t\t\t\t</Dialog.Backdrop>\n\t\t\t</Portal>\n\t\t</Dialog.Root>\n\t);\n};\nLeavePageConfirmation.displayName = \"LeavePageConfirmation\";\n"]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { NumberInput, RadioGroup as RadioGroup$1, NativeSelect as NativeSelect$1 } from '@chakra-ui/react';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
// src/primitives/native-select.tsx
|
|
5
|
+
var NativeSelect = function NativeSelect2({
|
|
6
|
+
ref,
|
|
7
|
+
...props
|
|
8
|
+
}) {
|
|
9
|
+
const {
|
|
10
|
+
size,
|
|
11
|
+
variant,
|
|
12
|
+
disabled,
|
|
13
|
+
invalid,
|
|
14
|
+
unstyled,
|
|
15
|
+
placeholder,
|
|
16
|
+
children,
|
|
17
|
+
...fieldProps
|
|
18
|
+
} = props;
|
|
19
|
+
return /* @__PURE__ */ jsxs(
|
|
20
|
+
NativeSelect$1.Root,
|
|
21
|
+
{
|
|
22
|
+
size,
|
|
23
|
+
variant,
|
|
24
|
+
disabled,
|
|
25
|
+
invalid,
|
|
26
|
+
unstyled,
|
|
27
|
+
children: [
|
|
28
|
+
/* @__PURE__ */ jsxs(NativeSelect$1.Field, { ref, ...fieldProps, children: [
|
|
29
|
+
placeholder && /* @__PURE__ */ jsx("option", { value: "", disabled: true, children: placeholder }),
|
|
30
|
+
children
|
|
31
|
+
] }),
|
|
32
|
+
/* @__PURE__ */ jsx(NativeSelect$1.Indicator, {})
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
NativeSelect.displayName = "NativeSelect";
|
|
38
|
+
var NumberInputRoot = function NumberInput$1({
|
|
39
|
+
ref,
|
|
40
|
+
...props
|
|
41
|
+
}) {
|
|
42
|
+
const { children, showStepper = true, ...rest } = props;
|
|
43
|
+
return /* @__PURE__ */ jsxs(NumberInput.Root, { ref, variant: "outline", ...rest, children: [
|
|
44
|
+
children,
|
|
45
|
+
showStepper && /* @__PURE__ */ jsxs(NumberInput.Control, { children: [
|
|
46
|
+
/* @__PURE__ */ jsx(NumberInput.IncrementTrigger, {}),
|
|
47
|
+
/* @__PURE__ */ jsx(NumberInput.DecrementTrigger, {})
|
|
48
|
+
] })
|
|
49
|
+
] });
|
|
50
|
+
};
|
|
51
|
+
NumberInputRoot.displayName = "NumberInputRoot";
|
|
52
|
+
var NumberInputField = NumberInput.Input;
|
|
53
|
+
NumberInputField.displayName = "NumberInputField";
|
|
54
|
+
var NumberInputScrubber = NumberInput.Scrubber;
|
|
55
|
+
NumberInputScrubber.displayName = "NumberInputScrubber";
|
|
56
|
+
var NumberInputLabel = NumberInput.Label;
|
|
57
|
+
NumberInputLabel.displayName = "NumberInputLabel";
|
|
58
|
+
var Radio = function Radio2({
|
|
59
|
+
ref,
|
|
60
|
+
...props
|
|
61
|
+
}) {
|
|
62
|
+
const { children, inputProps, rootRef, ...rest } = props;
|
|
63
|
+
return /* @__PURE__ */ jsxs(RadioGroup$1.Item, { ref: rootRef, ...rest, children: [
|
|
64
|
+
/* @__PURE__ */ jsx(RadioGroup$1.ItemHiddenInput, { ref, ...inputProps }),
|
|
65
|
+
/* @__PURE__ */ jsx(RadioGroup$1.ItemIndicator, {}),
|
|
66
|
+
children && /* @__PURE__ */ jsx(RadioGroup$1.ItemText, { children })
|
|
67
|
+
] });
|
|
68
|
+
};
|
|
69
|
+
Radio.displayName = "Radio";
|
|
70
|
+
var RadioGroup = RadioGroup$1.Root;
|
|
71
|
+
RadioGroup.displayName = "RadioGroup";
|
|
72
|
+
|
|
73
|
+
export { NativeSelect, NumberInputField, NumberInputLabel, NumberInputRoot, NumberInputScrubber, Radio, RadioGroup };
|
|
74
|
+
//# sourceMappingURL=chunk-CWBQKGL4.js.map
|
|
75
|
+
//# sourceMappingURL=chunk-CWBQKGL4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/primitives/native-select.tsx","../src/primitives/number-input.tsx","../src/primitives/radio.tsx"],"names":["NativeSelect","ChakraNativeSelect","NumberInput","jsxs","ChakraNumberInput","jsx","Radio","ChakraRadioGroup"],"mappings":";;;;AAmBO,IAAM,YAAA,GAAe,SAASA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AAA,CAAkB,gBAAA,EAAlB,EAAmC,CAAA;AAAA,sBACpCC,GAAAA,CAACD,WAAA,CAAkB,gBAAA,EAAlB,EAAmC;AAAA,KAAA,EACrC;AAAA,GAAA,EAEF,CAAA;AAEF;AACA,eAAA,CAAgB,WAAA,GAAc,iBAAA;AAEvB,IAAM,mBAAmBA,WAAA,CAAkB;AAClD,gBAAA,CAAiB,WAAA,GAAc,kBAAA;AACxB,IAAM,sBAAsBA,WAAA,CAAkB;AACrD,mBAAA,CAAoB,WAAA,GAAc,qBAAA;AAC3B,IAAM,mBAAmBA,WAAA,CAAkB;AAClD,gBAAA,CAAiB,WAAA,GAAc,kBAAA;ACrBxB,IAAM,KAAA,GAAQ,SAASE,MAAAA,CAAM;AAAA,EACnC,GAAA;AAAA,EACA,GAAG;AACJ,CAAA,EAAuD;AACtD,EAAA,MAAM,EAAE,QAAA,EAAU,UAAA,EAAY,OAAA,EAAS,GAAG,MAAK,GAAI,KAAA;AACnD,EAAA,uBACCH,KAACI,YAAA,CAAiB,IAAA,EAAjB,EAAsB,GAAA,EAAK,OAAA,EAAU,GAAG,IAAA,EACxC,QAAA,EAAA;AAAA,oBAAAF,IAACE,YAAA,CAAiB,eAAA,EAAjB,EAAiC,GAAA,EAAW,GAAG,UAAA,EAAY,CAAA;AAAA,oBAC5DF,GAAAA,CAACE,YAAA,CAAiB,aAAA,EAAjB,EAA+B,CAAA;AAAA,IAC/B,4BACAF,GAAAA,CAACE,YAAA,CAAiB,QAAA,EAAjB,EAA2B,QAAA,EAAS;AAAA,GAAA,EAEvC,CAAA;AAEF;AACA,KAAA,CAAM,WAAA,GAAc,OAAA;AAEb,IAAM,aAAaA,YAAA,CAAiB;AAC3C,UAAA,CAAW,WAAA,GAAc,YAAA","file":"chunk-CWBQKGL4.js","sourcesContent":["import {\n\tNativeSelect as ChakraNativeSelect,\n\ttype NativeSelectFieldProps,\n\ttype NativeSelectRootProps,\n} from \"@chakra-ui/react\";\nimport type * as React from \"react\";\n\nexport interface NativeSelectProps\n\textends Omit<NativeSelectFieldProps, \"placeholder\"> {\n\t/** Props forwarded to the root wrapper. */\n\tsize?: NativeSelectRootProps[\"size\"];\n\tvariant?: NativeSelectRootProps[\"variant\"];\n\tdisabled?: NativeSelectRootProps[\"disabled\"];\n\tinvalid?: NativeSelectRootProps[\"invalid\"];\n\tunstyled?: NativeSelectRootProps[\"unstyled\"];\n\t/** Rendered as a disabled first <option> */\n\tplaceholder?: string;\n}\n\nexport const NativeSelect = function NativeSelect({\n\tref,\n\t...props\n}: NativeSelectProps & { ref?: React.Ref<HTMLSelectElement> }) {\n\tconst {\n\t\tsize,\n\t\tvariant,\n\t\tdisabled,\n\t\tinvalid,\n\t\tunstyled,\n\t\tplaceholder,\n\t\tchildren,\n\t\t...fieldProps\n\t} = props;\n\n\treturn (\n\t\t<ChakraNativeSelect.Root\n\t\t\tsize={size}\n\t\t\tvariant={variant}\n\t\t\tdisabled={disabled}\n\t\t\tinvalid={invalid}\n\t\t\tunstyled={unstyled}\n\t\t>\n\t\t\t<ChakraNativeSelect.Field ref={ref} {...fieldProps}>\n\t\t\t\t{placeholder && (\n\t\t\t\t\t<option value=\"\" disabled>\n\t\t\t\t\t\t{placeholder}\n\t\t\t\t\t</option>\n\t\t\t\t)}\n\t\t\t\t{children}\n\t\t\t</ChakraNativeSelect.Field>\n\t\t\t<ChakraNativeSelect.Indicator />\n\t\t</ChakraNativeSelect.Root>\n\t);\n};\nNativeSelect.displayName = \"NativeSelect\";\n","import { NumberInput as ChakraNumberInput } from \"@chakra-ui/react\";\nimport type * as React from \"react\";\n\nexport interface NumberInputProps extends ChakraNumberInput.RootProps {\n\tshowStepper?: boolean;\n}\n\nexport const NumberInputRoot = function NumberInput({\n\tref,\n\t...props\n}: NumberInputProps & { ref?: React.Ref<HTMLDivElement> }) {\n\tconst { children, showStepper = true, ...rest } = props;\n\treturn (\n\t\t<ChakraNumberInput.Root ref={ref} variant=\"outline\" {...rest}>\n\t\t\t{children}\n\t\t\t{showStepper && (\n\t\t\t\t<ChakraNumberInput.Control>\n\t\t\t\t\t<ChakraNumberInput.IncrementTrigger />\n\t\t\t\t\t<ChakraNumberInput.DecrementTrigger />\n\t\t\t\t</ChakraNumberInput.Control>\n\t\t\t)}\n\t\t</ChakraNumberInput.Root>\n\t);\n};\nNumberInputRoot.displayName = \"NumberInputRoot\";\n\nexport const NumberInputField = ChakraNumberInput.Input;\nNumberInputField.displayName = \"NumberInputField\";\nexport const NumberInputScrubber = ChakraNumberInput.Scrubber;\nNumberInputScrubber.displayName = \"NumberInputScrubber\";\nexport const NumberInputLabel = ChakraNumberInput.Label;\nNumberInputLabel.displayName = \"NumberInputLabel\";\n","import { RadioGroup as ChakraRadioGroup } from \"@chakra-ui/react\";\nimport type * as React from \"react\";\n\nexport interface RadioProps extends ChakraRadioGroup.ItemProps {\n\t/** Ref attached to the root element. */\n\trootRef?: React.RefObject<HTMLDivElement | null>;\n\t/** Additional props forwarded to the hidden input element. */\n\tinputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n}\n\nexport const Radio = function Radio({\n\tref,\n\t...props\n}: RadioProps & { ref?: React.Ref<HTMLInputElement> }) {\n\tconst { children, inputProps, rootRef, ...rest } = props;\n\treturn (\n\t\t<ChakraRadioGroup.Item ref={rootRef} {...rest}>\n\t\t\t<ChakraRadioGroup.ItemHiddenInput ref={ref} {...inputProps} />\n\t\t\t<ChakraRadioGroup.ItemIndicator />\n\t\t\t{children && (\n\t\t\t\t<ChakraRadioGroup.ItemText>{children}</ChakraRadioGroup.ItemText>\n\t\t\t)}\n\t\t</ChakraRadioGroup.Item>\n\t);\n};\nRadio.displayName = \"Radio\";\n\nexport const RadioGroup = ChakraRadioGroup.Root;\nRadioGroup.displayName = \"RadioGroup\";\n"]}
|
package/dist/forms/index.d.ts
CHANGED
|
@@ -2,9 +2,11 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { FieldValues, Path, ControllerRenderProps } from 'react-hook-form';
|
|
4
4
|
import { ButtonProps, InputProps, RadioGroupRootProps, StackProps, NativeSelectFieldProps, TextareaProps } from '@chakra-ui/react';
|
|
5
|
+
import { U as UnsavedChangesGuardProps } from '../unsaved-changes-guard-kwzxMb6r.js';
|
|
5
6
|
import { b as NumberInputProps } from '../number-input-D2X0rWOg.js';
|
|
6
7
|
export { S as SearchInput, a as SearchInputProps } from '../search-input-C_Cl2OEx.js';
|
|
7
8
|
import { a as SwitchProps } from '../switch-B0o6G2XE.js';
|
|
9
|
+
import 'react-router-dom';
|
|
8
10
|
|
|
9
11
|
interface FormFieldProps<T extends FieldValues> {
|
|
10
12
|
name: Path<T>;
|
|
@@ -137,16 +139,17 @@ declare namespace DirtyCounter {
|
|
|
137
139
|
var displayName: string;
|
|
138
140
|
}
|
|
139
141
|
|
|
140
|
-
interface DirtyFormGuardProps {
|
|
141
|
-
/** Dialog title. @default "You have unsaved changes" */
|
|
142
|
-
title?: string;
|
|
143
|
-
/** Dialog message body. @default "Are you sure you want to leave this page? You have unsaved changes." */
|
|
144
|
-
message?: string;
|
|
145
|
-
/** Label for the confirm/leave button. @default "Leave" */
|
|
146
|
-
confirmLabel?: string;
|
|
147
|
-
/** Label for the cancel/stay button. @default "Stay" */
|
|
148
|
-
cancelLabel?: string;
|
|
142
|
+
interface DirtyFormGuardProps extends Omit<UnsavedChangesGuardProps, "isDirty"> {
|
|
149
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Form-aware shortcut for `<UnsavedChangesGuard/>`: sources `isDirty` from
|
|
146
|
+
* the surrounding `useFormContext()`. Must be mounted inside a
|
|
147
|
+
* `<FormProvider/>`. For non-form dirty sources (Monaco buffer, custom
|
|
148
|
+
* hook) use `<UnsavedChangesGuard isDirty={…}/>` directly.
|
|
149
|
+
*
|
|
150
|
+
* Pass `safePathPrefix` to exempt sibling tabs of the same detail page
|
|
151
|
+
* from the leave-confirmation modal.
|
|
152
|
+
*/
|
|
150
153
|
declare const DirtyFormGuard: React__default.FC<DirtyFormGuardProps>;
|
|
151
154
|
|
|
152
155
|
type DropzoneOptions = {
|
package/dist/forms/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NumberInputRoot, NumberInputField, RadioGroup, Radio, NativeSelect } from '../chunk-CWBQKGL4.js';
|
|
2
2
|
import { Popover, PopoverTrigger, PopoverContent, PopoverBody, Switch } from '../chunk-MIEUXFSK.js';
|
|
3
3
|
export { SearchInput } from '../chunk-E7KRPPCQ.js';
|
|
4
4
|
import { Textarea } from '../chunk-NFZMG6ZL.js';
|
|
5
5
|
import { text_input_default } from '../chunk-OU6H3KU4.js';
|
|
6
6
|
import { Stack, Grid, GridItem, Text, Box, HStack, Flex } from '../chunk-G4QMIXLC.js';
|
|
7
|
+
import { UnsavedChangesGuard } from '../chunk-77EOXDGW.js';
|
|
8
|
+
import '../chunk-7KPPPE4U.js';
|
|
7
9
|
import { Input, IconButton, ButtonGroup, Button, Field, Checkbox, Square, Editable, useEditableContext } from '@chakra-ui/react';
|
|
8
10
|
import { Trash2, Plus, Upload, Pencil } from 'lucide-react';
|
|
9
11
|
import React, { useId, useCallback, useEffect, useRef } from 'react';
|
|
10
12
|
import { useFormContext, useFieldArray, Controller } from 'react-hook-form';
|
|
11
13
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
12
|
-
import { useBlocker } from 'react-router-dom';
|
|
13
14
|
|
|
14
15
|
function FormField({
|
|
15
16
|
name,
|
|
@@ -487,26 +488,9 @@ function DirtyCounter({
|
|
|
487
488
|
] });
|
|
488
489
|
}
|
|
489
490
|
DirtyCounter.displayName = "DirtyCounter";
|
|
490
|
-
var DirtyFormGuard = ({
|
|
491
|
-
title,
|
|
492
|
-
message,
|
|
493
|
-
confirmLabel,
|
|
494
|
-
cancelLabel
|
|
495
|
-
}) => {
|
|
491
|
+
var DirtyFormGuard = (props) => {
|
|
496
492
|
const { formState } = useFormContext();
|
|
497
|
-
|
|
498
|
-
return /* @__PURE__ */ jsx(
|
|
499
|
-
LeavePageConfirmation,
|
|
500
|
-
{
|
|
501
|
-
blocked: blocker.state === "blocked",
|
|
502
|
-
onConfirmLeave: () => blocker.proceed?.(),
|
|
503
|
-
onCancelLeave: () => blocker.reset?.(),
|
|
504
|
-
title,
|
|
505
|
-
message,
|
|
506
|
-
confirmLabel,
|
|
507
|
-
cancelLabel
|
|
508
|
-
}
|
|
509
|
-
);
|
|
493
|
+
return /* @__PURE__ */ jsx(UnsavedChangesGuard, { isDirty: formState.isDirty, ...props });
|
|
510
494
|
};
|
|
511
495
|
DirtyFormGuard.displayName = "DirtyFormGuard";
|
|
512
496
|
function FileField(props) {
|