@mittwald/flow-react-components 0.2.0-alpha.987 → 0.2.0-alpha.989
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/CHANGELOG.md +10 -0
- package/dist/assets/doc-properties.json +22535 -22449
- package/dist/js/_virtual/_.locale.json@95341064edeb0e38b66d786dbd62955c.mjs +2 -0
- package/dist/js/_virtual/_.locale.json@95341064edeb0e38b66d786dbd62955c.mjs.map +1 -1
- package/dist/js/_virtual/_.locale.json@df0c8534e2e4f7c6c3d4365218df7347.mjs +4 -2
- package/dist/js/_virtual/_.locale.json@df0c8534e2e4f7c6c3d4365218df7347.mjs.map +1 -1
- package/dist/js/packages/components/src/components/ContextualHelp/ContextualHelp.mjs +5 -1
- package/dist/js/packages/components/src/components/ContextualHelp/ContextualHelp.mjs.map +1 -1
- package/dist/js/packages/components/src/components/ContextualHelp/components/ContextualHelpTrigger/ContextualHelpTrigger.mjs +8 -2
- package/dist/js/packages/components/src/components/ContextualHelp/components/ContextualHelpTrigger/ContextualHelpTrigger.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Modal/Modal.mjs +7 -3
- package/dist/js/packages/components/src/components/Modal/Modal.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Modal/components/ConfirmUnsavedChangesModal/ConfirmUnsavedChangesModal.mjs +5 -3
- package/dist/js/packages/components/src/components/Modal/components/ConfirmUnsavedChangesModal/ConfirmUnsavedChangesModal.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Overlay/Overlay.mjs.map +1 -1
- package/dist/js/packages/components/src/components/PasswordCreationField/components/ValidationResultButton/ValidationResultButton.mjs +21 -15
- package/dist/js/packages/components/src/components/PasswordCreationField/components/ValidationResultButton/ValidationResultButton.mjs.map +1 -1
- package/dist/js/packages/components/src/integrations/react-hook-form/components/Form/Form.mjs +25 -26
- package/dist/js/packages/components/src/integrations/react-hook-form/components/Form/Form.mjs.map +1 -1
- package/dist/js/packages/components/src/lib/controller/overlay/OverlayController.mjs +47 -12
- package/dist/js/packages/components/src/lib/controller/overlay/OverlayController.mjs.map +1 -1
- package/dist/types/components/ContextualHelp/ContextualHelp.browser.test.d.ts +2 -0
- package/dist/types/components/ContextualHelp/ContextualHelp.browser.test.d.ts.map +1 -0
- package/dist/types/components/ContextualHelp/ContextualHelp.d.ts.map +1 -1
- package/dist/types/components/ContextualHelp/components/ContextualHelpTrigger/ContextualHelpTrigger.d.ts +15 -2
- package/dist/types/components/ContextualHelp/components/ContextualHelpTrigger/ContextualHelpTrigger.d.ts.map +1 -1
- package/dist/types/components/ContextualHelp/stories/Default.stories.d.ts.map +1 -1
- package/dist/types/components/Modal/Modal.d.ts +5 -0
- package/dist/types/components/Modal/Modal.d.ts.map +1 -1
- package/dist/types/components/Modal/components/ConfirmUnsavedChangesModal/ConfirmUnsavedChangesModal.d.ts +4 -0
- package/dist/types/components/Modal/components/ConfirmUnsavedChangesModal/ConfirmUnsavedChangesModal.d.ts.map +1 -1
- package/dist/types/components/Modal/stories/Default.stories.d.ts +1 -0
- package/dist/types/components/Modal/stories/Default.stories.d.ts.map +1 -1
- package/dist/types/components/Overlay/Overlay.d.ts +2 -0
- package/dist/types/components/Overlay/Overlay.d.ts.map +1 -1
- package/dist/types/components/PasswordCreationField/components/ValidationResultButton/ValidationResultButton.d.ts.map +1 -1
- package/dist/types/integrations/react-hook-form/components/Form/Form.d.ts.map +1 -1
- package/dist/types/lib/controller/overlay/OverlayController.d.ts +23 -1
- package/dist/types/lib/controller/overlay/OverlayController.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -5,6 +5,7 @@ const locales = {"de-DE":{
|
|
|
5
5
|
"button.generate.tooltip.hide": "Passwort verbergen",
|
|
6
6
|
"button.generate.tooltip.show": "Passwort anzeigen",
|
|
7
7
|
"password.requirements.heading": "Anforderungen an dein Passwort",
|
|
8
|
+
"password.requirements.subject": "den Anforderungen an dein Passwort",
|
|
8
9
|
"validation.allowedSpecialCharacters": "Erlaubte Sonderzeichen: #!~%^*_+-=?()<>|.,;$:/",
|
|
9
10
|
"validation.atLeastOneCapitalLetter": "Mindestens ein Großbuchstabe",
|
|
10
11
|
"validation.atLeastOneLowercaseLetter": "Mindestens ein Kleinbuchstabe",
|
|
@@ -45,6 +46,7 @@ const locales = {"de-DE":{
|
|
|
45
46
|
"button.generate.tooltip.hide": "Hide password",
|
|
46
47
|
"button.generate.tooltip.show": "Show password",
|
|
47
48
|
"password.requirements.heading": "Requirements for your password",
|
|
49
|
+
"password.requirements.subject": "your password requirements",
|
|
48
50
|
"validation.allowedSpecialCharacters": "Allowed special characters: #!~%^*_+-=?()<>|.,;$:/",
|
|
49
51
|
"validation.atLeastOneCapitalLetter": "At least one capital letter",
|
|
50
52
|
"validation.atLeastOneLowercaseLetter": "At least one lowercase letter",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_.locale.json@95341064edeb0e38b66d786dbd62955c.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_.locale.json@95341064edeb0e38b66d786dbd62955c.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
3
|
const locales = {"de-DE":{
|
|
4
|
-
"moreInformation": "Weitere Informationen"
|
|
4
|
+
"moreInformation": "Weitere Informationen",
|
|
5
|
+
"moreInformationAbout": "Weitere Informationen zu {subject}"
|
|
5
6
|
}
|
|
6
7
|
,"en-US":{
|
|
7
|
-
"moreInformation": "More information"
|
|
8
|
+
"moreInformation": "More information",
|
|
9
|
+
"moreInformationAbout": "More information about {subject}"
|
|
8
10
|
}
|
|
9
11
|
};
|
|
10
12
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_.locale.json@df0c8534e2e4f7c6c3d4365218df7347.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_.locale.json@df0c8534e2e4f7c6c3d4365218df7347.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
|
@@ -25,8 +25,12 @@ const ContextualHelp = flowComponent("ContextualHelp", (props) => {
|
|
|
25
25
|
});
|
|
26
26
|
const controller = controllerFromProps ?? controllerFromContext;
|
|
27
27
|
const propsContext = {
|
|
28
|
+
// A contextual help holds a single, simple explanation — it does not need
|
|
29
|
+
// its own heading structure. A heading is rendered as a bold text label
|
|
30
|
+
// instead of an actual heading element.
|
|
28
31
|
Heading: {
|
|
29
|
-
level: 5
|
|
32
|
+
level: 5,
|
|
33
|
+
elementType: "span"
|
|
30
34
|
}
|
|
31
35
|
};
|
|
32
36
|
return /* @__PURE__ */ jsx(Popover, { withTip: true, ...rest, controller, children: /* @__PURE__ */ jsx(PropsContextProvider, { props: propsContext, children: /* @__PURE__ */ jsx("div", { className: styles.contextualHelp, children }) }) });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextualHelp.mjs","sources":["../../../../../../../src/components/ContextualHelp/ContextualHelp.tsx"],"sourcesContent":["import type { PopoverProps } from \"@/components/Popover/Popover\";\nimport { Popover } from \"@/components/Popover/Popover\";\nimport styles from \"./ContextualHelp.module.scss\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { useOverlayController } from \"@/lib/controller\";\n\nexport type ContextualHelpProps = Omit<PopoverProps, \"withTip\">;\n\n/** @flr-generate all */\nexport const ContextualHelp = flowComponent(\"ContextualHelp\", (props) => {\n const {\n children,\n controller: controllerFromProps,\n ref: ignoredRef,\n ...rest\n } = props;\n\n const controllerFromContext = useOverlayController(\"ContextualHelp\", {\n reuseControllerFromContext: true,\n });\n\n const controller = controllerFromProps ?? controllerFromContext;\n\n const propsContext: PropsContext = {\n Heading: {\n level: 5,\n },\n };\n\n return (\n <Popover withTip {...rest} controller={controller}>\n <PropsContextProvider props={propsContext}>\n <div className={styles.contextualHelp}>{children}</div>\n </PropsContextProvider>\n </Popover>\n );\n});\n\nexport default ContextualHelp;\n"],"names":[],"mappings":";;;;;;;;;;;;;AAWO,MAAM,cAAA,GAAiB,aAAA,CAAc,gBAAA,EAAkB,CAAC,KAAA,KAAU;AACvE,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,UAAA,EAAY,mBAAA;AAAA,IACZ,GAAA,EAAK,UAAA;AAAA,IACL,GAAG;AAAA,GACL,GAAI,KAAA;AAEJ,EAAA,MAAM,qBAAA,GAAwB,qBAAqB,gBAAA,EAAkB;AAAA,IACnE,0BAAA,EAA4B;AAAA,GAC7B,CAAA;AAED,EAAA,MAAM,aAAa,mBAAA,IAAuB,qBAAA;AAE1C,EAAA,MAAM,YAAA,GAA6B;AAAA,
|
|
1
|
+
{"version":3,"file":"ContextualHelp.mjs","sources":["../../../../../../../src/components/ContextualHelp/ContextualHelp.tsx"],"sourcesContent":["import type { PopoverProps } from \"@/components/Popover/Popover\";\nimport { Popover } from \"@/components/Popover/Popover\";\nimport styles from \"./ContextualHelp.module.scss\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { useOverlayController } from \"@/lib/controller\";\n\nexport type ContextualHelpProps = Omit<PopoverProps, \"withTip\">;\n\n/** @flr-generate all */\nexport const ContextualHelp = flowComponent(\"ContextualHelp\", (props) => {\n const {\n children,\n controller: controllerFromProps,\n ref: ignoredRef,\n ...rest\n } = props;\n\n const controllerFromContext = useOverlayController(\"ContextualHelp\", {\n reuseControllerFromContext: true,\n });\n\n const controller = controllerFromProps ?? controllerFromContext;\n\n const propsContext: PropsContext = {\n // A contextual help holds a single, simple explanation — it does not need\n // its own heading structure. A heading is rendered as a bold text label\n // instead of an actual heading element.\n Heading: {\n level: 5,\n elementType: \"span\",\n },\n };\n\n return (\n <Popover withTip {...rest} controller={controller}>\n <PropsContextProvider props={propsContext}>\n <div className={styles.contextualHelp}>{children}</div>\n </PropsContextProvider>\n </Popover>\n );\n});\n\nexport default ContextualHelp;\n"],"names":[],"mappings":";;;;;;;;;;;;;AAWO,MAAM,cAAA,GAAiB,aAAA,CAAc,gBAAA,EAAkB,CAAC,KAAA,KAAU;AACvE,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,UAAA,EAAY,mBAAA;AAAA,IACZ,GAAA,EAAK,UAAA;AAAA,IACL,GAAG;AAAA,GACL,GAAI,KAAA;AAEJ,EAAA,MAAM,qBAAA,GAAwB,qBAAqB,gBAAA,EAAkB;AAAA,IACnE,0BAAA,EAA4B;AAAA,GAC7B,CAAA;AAED,EAAA,MAAM,aAAa,mBAAA,IAAuB,qBAAA;AAE1C,EAAA,MAAM,YAAA,GAA6B;AAAA;AAAA;AAAA;AAAA,IAIjC,OAAA,EAAS;AAAA,MACP,KAAA,EAAO,CAAA;AAAA,MACP,WAAA,EAAa;AAAA;AACf,GACF;AAEA,EAAA,2BACG,OAAA,EAAA,EAAQ,OAAA,EAAO,MAAE,GAAG,IAAA,EAAM,YACzB,QAAA,kBAAA,GAAA,CAAC,oBAAA,EAAA,EAAqB,KAAA,EAAO,YAAA,EAC3B,8BAAC,KAAA,EAAA,EAAI,SAAA,EAAW,OAAO,cAAA,EAAiB,QAAA,EAAS,GACnD,CAAA,EACF,CAAA;AAEJ,CAAC;;;;"}
|
|
@@ -19,14 +19,20 @@ import { flowComponent } from '../../../../lib/componentFactory/flowComponent.mj
|
|
|
19
19
|
const ContextualHelpTrigger = flowComponent(
|
|
20
20
|
"ContextualHelpTrigger",
|
|
21
21
|
(props) => {
|
|
22
|
-
const {
|
|
22
|
+
const {
|
|
23
|
+
children,
|
|
24
|
+
subject,
|
|
25
|
+
"aria-label": ariaLabelFromProps,
|
|
26
|
+
...triggerProps
|
|
27
|
+
} = props;
|
|
23
28
|
const stringFormatter = useLocalizedStringFormatter(
|
|
24
29
|
locales,
|
|
25
30
|
"ContextualHelpTrigger"
|
|
26
31
|
);
|
|
32
|
+
const ariaLabel = ariaLabelFromProps ?? (subject === void 0 ? stringFormatter.format("moreInformation") : stringFormatter.format("moreInformationAbout", { subject }));
|
|
27
33
|
const propsContext = {
|
|
28
34
|
Button: {
|
|
29
|
-
"aria-label":
|
|
35
|
+
"aria-label": ariaLabel,
|
|
30
36
|
children: /* @__PURE__ */ jsx(IconInfo, {}),
|
|
31
37
|
size: "s",
|
|
32
38
|
variant: "plain",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextualHelpTrigger.mjs","sources":["../../../../../../../../../src/components/ContextualHelp/components/ContextualHelpTrigger/ContextualHelpTrigger.tsx"],"sourcesContent":["import * as Aria from \"react-aria-components\";\nimport type { OverlayTriggerProps } from \"@/components/OverlayTrigger\";\nimport { OverlayTrigger } from \"@/components/OverlayTrigger\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport locales from \"./locales/*.locale.json\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider/useLocalizedStringFormatter\";\nimport { IconInfo } from \"@/components/Icon/components/icons\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\n\nexport
|
|
1
|
+
{"version":3,"file":"ContextualHelpTrigger.mjs","sources":["../../../../../../../../../src/components/ContextualHelp/components/ContextualHelpTrigger/ContextualHelpTrigger.tsx"],"sourcesContent":["import * as Aria from \"react-aria-components\";\nimport type { OverlayTriggerProps } from \"@/components/OverlayTrigger\";\nimport { OverlayTrigger } from \"@/components/OverlayTrigger\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport locales from \"./locales/*.locale.json\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider/useLocalizedStringFormatter\";\nimport { IconInfo } from \"@/components/Icon/components/icons\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\n\nexport interface ContextualHelpTriggerProps extends OverlayTriggerProps {\n /**\n * The subject the contextual help is about — not a complete accessibility\n * label. It is inserted into the localized template \"More information about\n * {subject}\", which becomes the accessibility label of the trigger.\n */\n subject?: string;\n /**\n * A complete accessibility label for the trigger, replacing the label built\n * from `subject`. Prefer `subject`, which stays localized — reach for this\n * only when the template does not fit.\n */\n \"aria-label\"?: string;\n}\n\n/** @flr-generate all */\nexport const ContextualHelpTrigger = flowComponent(\n \"ContextualHelpTrigger\",\n (props) => {\n const {\n children,\n subject,\n \"aria-label\": ariaLabelFromProps,\n ...triggerProps\n } = props;\n const stringFormatter = useLocalizedStringFormatter(\n locales,\n \"ContextualHelpTrigger\",\n );\n\n const ariaLabel =\n ariaLabelFromProps ??\n (subject === undefined\n ? stringFormatter.format(\"moreInformation\")\n : stringFormatter.format(\"moreInformationAbout\", { subject }));\n\n const propsContext: PropsContext = {\n Button: {\n \"aria-label\": ariaLabel,\n children: <IconInfo />,\n size: \"s\",\n variant: \"plain\",\n ariaSlot: null,\n },\n };\n\n return (\n <OverlayTrigger\n overlayType=\"ContextualHelp\"\n {...triggerProps}\n component={Aria.DialogTrigger}\n >\n <PropsContextProvider props={propsContext}>\n {children}\n </PropsContextProvider>\n </OverlayTrigger>\n );\n },\n { type: \"provider\" },\n);\n\nexport default ContextualHelpTrigger;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA0BO,MAAM,qBAAA,GAAwB,aAAA;AAAA,EACnC,uBAAA;AAAA,EACA,CAAC,KAAA,KAAU;AACT,IAAA,MAAM;AAAA,MACJ,QAAA;AAAA,MACA,OAAA;AAAA,MACA,YAAA,EAAc,kBAAA;AAAA,MACd,GAAG;AAAA,KACL,GAAI,KAAA;AACJ,IAAA,MAAM,eAAA,GAAkB,2BAAA;AAAA,MACtB,OAAA;AAAA,MACA;AAAA,KACF;AAEA,IAAA,MAAM,SAAA,GACJ,kBAAA,KACC,OAAA,KAAY,MAAA,GACT,eAAA,CAAgB,MAAA,CAAO,iBAAiB,CAAA,GACxC,eAAA,CAAgB,MAAA,CAAO,sBAAA,EAAwB,EAAE,SAAS,CAAA,CAAA;AAEhE,IAAA,MAAM,YAAA,GAA6B;AAAA,MACjC,MAAA,EAAQ;AAAA,QACN,YAAA,EAAc,SAAA;AAAA,QACd,QAAA,sBAAW,QAAA,EAAA,EAAS,CAAA;AAAA,QACpB,IAAA,EAAM,GAAA;AAAA,QACN,OAAA,EAAS,OAAA;AAAA,QACT,QAAA,EAAU;AAAA;AACZ,KACF;AAEA,IAAA,uBACE,GAAA;AAAA,MAAC,cAAA;AAAA,MAAA;AAAA,QACC,WAAA,EAAY,gBAAA;AAAA,QACX,GAAG,YAAA;AAAA,QACJ,WAAW,IAAA,CAAK,aAAA;AAAA,QAEhB,QAAA,kBAAA,GAAA,CAAC,oBAAA,EAAA,EAAqB,KAAA,EAAO,YAAA,EAC1B,QAAA,EACH;AAAA;AAAA,KACF;AAAA,EAEJ,CAAA;AAAA,EACA,EAAE,MAAM,UAAA;AACV;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import {
|
|
3
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { useId, Suspense } from 'react';
|
|
5
5
|
import styles from './Modal.module.scss.mjs';
|
|
6
6
|
import clsx from 'clsx';
|
|
@@ -24,6 +24,7 @@ import '../../views/IconView.mjs';
|
|
|
24
24
|
import { IconClose } from '../Icon/components/icons/IconClose.mjs';
|
|
25
25
|
import ButtonView from '../../views/ButtonView.mjs';
|
|
26
26
|
import { OffCanvasSuspenseFallback } from './components/OffCanvasSuspenseFallback/OffCanvasSuspenseFallback.mjs';
|
|
27
|
+
import { ConfirmUnsavedChangesModal } from './components/ConfirmUnsavedChangesModal/ConfirmUnsavedChangesModal.mjs';
|
|
27
28
|
import { Wrap } from '../Wrap/Wrap.mjs';
|
|
28
29
|
import { ClearPropsContext } from '../../lib/propsContext/components/ClearPropsContext.mjs';
|
|
29
30
|
import '../TranslationProvider/TranslationProvider.mjs';
|
|
@@ -131,7 +132,7 @@ const Modal = flowComponent("Modal", (props) => {
|
|
|
131
132
|
}
|
|
132
133
|
}
|
|
133
134
|
};
|
|
134
|
-
return /* @__PURE__ */
|
|
135
|
+
return /* @__PURE__ */ jsxs(
|
|
135
136
|
Overlay,
|
|
136
137
|
{
|
|
137
138
|
className: rootClassName,
|
|
@@ -139,7 +140,10 @@ const Modal = flowComponent("Modal", (props) => {
|
|
|
139
140
|
ref,
|
|
140
141
|
"aria-labelledby": generatedId,
|
|
141
142
|
...overlayProps,
|
|
142
|
-
children:
|
|
143
|
+
children: [
|
|
144
|
+
/* @__PURE__ */ jsx(PropsContextProvider, { props: propsContext, children: /* @__PURE__ */ jsx(Wrap, { if: offCanvas, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(OffCanvasSuspenseFallback, {}), children }) }) }),
|
|
145
|
+
/* @__PURE__ */ jsx(ConfirmUnsavedChangesModal, {})
|
|
146
|
+
]
|
|
143
147
|
}
|
|
144
148
|
);
|
|
145
149
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.mjs","sources":["../../../../../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import { type PropsWithChildren, type ReactNode, Suspense, useId } from \"react\";\nimport styles from \"./Modal.module.scss\";\nimport clsx from \"clsx\";\nimport {\n dynamic,\n type PropsContext,\n PropsContextProvider,\n} from \"@/lib/propsContext\";\nimport { OverlayController } from \"@/lib/controller/overlay\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { Overlay, type OverlayProps } from \"@/components/Overlay/Overlay\";\nimport { Action } from \"@/components/Action\";\nimport { IconClose } from \"@/components/Icon/components/icons\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport ButtonView from \"@/views/ButtonView\";\nimport { OffCanvasSuspenseFallback } from \"@/components/Modal/components/OffCanvasSuspenseFallback\";\nimport Wrap from \"@/components/Wrap\";\nimport { ClearPropsContext } from \"@/components/ClearPropsContext/ClearPropsContext\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider\";\nimport { useVirtualKeyboardVisible } from \"@/lib/hooks/dom/useVirtualKeyboardVisible\";\nimport locales from \"./locales/*.locale.json\";\n\ntype SupportedOverlayProps = Pick<\n OverlayProps,\n \"isOpen\" | \"isDefaultOpen\" | \"onOpen\" | \"onClose\" | \"onOpenChange\"\n>;\n\nexport interface ModalProps\n extends\n PropsWithChildren,\n FlowComponentProps,\n PropsWithClassName,\n SupportedOverlayProps {\n /** The size of the modal. @default \"s\" */\n size?: \"s\" | \"m\" | \"l\";\n /** Whether the modal should be displayed as an off canvas. */\n offCanvas?: boolean;\n /**\n * Whether the off canvas should be displayed on the right or left side of the\n * screen. @default \"right\"\n */\n offCanvasOrientation?: \"left\" | \"right\";\n /** An overlay controller to control the modal state. */\n controller?: OverlayController;\n /**\n * Accepts \"actionConfirm\" to use the modal as a confirmation modal for an\n * action.\n */\n slot?: string;\n /** Whether the modal can be closed by clicking outside of it. */\n isDismissable?: boolean;\n /** Whether the close button should be visible */\n showCloseButton?: boolean;\n}\n\nexport const Modal = flowComponent(\"Modal\", (props) => {\n const {\n size = \"s\",\n offCanvas,\n controller,\n children,\n ref,\n className,\n offCanvasOrientation = \"right\",\n showCloseButton,\n ...overlayProps\n } = props;\n\n const stringFormatter = useLocalizedStringFormatter(locales, \"Modal\");\n\n // On mobile the header/footer are docked (sticky) while at rest, but flow\n // normally while the on-screen keyboard is open so the content gets the full\n // available space (see Modal.module.scss). #2423\n const keyboardVisible = useVirtualKeyboardVisible();\n\n const rootClassName = clsx(\n offCanvas ? styles.offCanvas : styles.modal,\n styles[`size-${size}`],\n offCanvasOrientation === \"left\" && styles[\"left\"],\n keyboardVisible && styles.keyboardVisible,\n className,\n );\n\n const generatedId = useId();\n\n const header = (children: ReactNode) => (\n <>\n {children}\n <Action closeModal={{ bypassConfirmation: true }}>\n <ButtonView\n variant=\"plain\"\n color=\"secondary\"\n aria-label={stringFormatter.format(\"close\")}\n className={clsx(\n styles.closeButton,\n showCloseButton === true\n ? styles.alwaysVisible\n : showCloseButton === false\n ? styles.alwaysHidden\n : undefined,\n )}\n >\n <IconClose />\n </ButtonView>\n </Action>\n </>\n );\n\n const nestedHeadingLevel = 3;\n\n const nestedHeadingProps: PropsContext = {\n Heading: { level: nestedHeadingLevel },\n Section: {\n Header: { Heading: { level: nestedHeadingLevel } },\n Heading: { level: nestedHeadingLevel },\n hideSeparator: true,\n },\n Header: { Heading: { level: nestedHeadingLevel } },\n };\n\n const propsContext: PropsContext = {\n Content: {\n ...nestedHeadingProps,\n className: styles.content,\n },\n ColumnLayout: {\n ...nestedHeadingProps,\n l: [2, 1],\n m: [1],\n className: styles.columnLayout,\n AccentBox: { className: styles.accentBox, backgroundColor: \"neutral\" },\n wrapWith: <ClearPropsContext />,\n },\n Heading: {\n className: styles.header,\n level: 2,\n children: dynamic((props) => header(props.children)),\n id: generatedId,\n },\n ActionGroup: {\n className: styles.actionGroup,\n spacing: \"m\",\n Action: {\n closeModal: dynamic((props) => {\n if (props.closeModal === undefined) {\n return;\n }\n if (props.closeModal === true) {\n return { bypassConfirmation: true };\n }\n return {\n bypassConfirmation: true,\n ...props.closeModal,\n };\n }),\n closeOverlay: dynamic((props) => {\n if (props.closeOverlay === undefined) {\n return;\n }\n if (\n props.closeOverlay instanceof OverlayController ||\n typeof props.closeOverlay === \"string\"\n ) {\n return {\n bypassConfirmation: true,\n overlay: props.closeOverlay,\n };\n }\n return {\n bypassConfirmation: true,\n ...props.closeOverlay,\n };\n }),\n },\n },\n };\n\n return (\n <Overlay\n className={rootClassName}\n controller={controller}\n ref={ref}\n aria-labelledby={generatedId}\n {...overlayProps}\n >\n <PropsContextProvider props={propsContext}>\n <Wrap if={offCanvas}>\n <Suspense fallback={<OffCanvasSuspenseFallback />}>\n {children}\n </Suspense>\n </Wrap>\n </PropsContextProvider>\n </Overlay>\n );\n});\n\nexport default Modal;\n"],"names":["children","props"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Modal.mjs","sources":["../../../../../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import { type PropsWithChildren, type ReactNode, Suspense, useId } from \"react\";\nimport styles from \"./Modal.module.scss\";\nimport clsx from \"clsx\";\nimport {\n dynamic,\n type PropsContext,\n PropsContextProvider,\n} from \"@/lib/propsContext\";\nimport { OverlayController } from \"@/lib/controller/overlay\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { Overlay, type OverlayProps } from \"@/components/Overlay/Overlay\";\nimport { Action } from \"@/components/Action\";\nimport { IconClose } from \"@/components/Icon/components/icons\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport ButtonView from \"@/views/ButtonView\";\nimport { OffCanvasSuspenseFallback } from \"@/components/Modal/components/OffCanvasSuspenseFallback\";\nimport { ConfirmUnsavedChangesModal } from \"@/components/Modal/components/ConfirmUnsavedChangesModal/ConfirmUnsavedChangesModal\";\nimport Wrap from \"@/components/Wrap\";\nimport { ClearPropsContext } from \"@/components/ClearPropsContext/ClearPropsContext\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider\";\nimport { useVirtualKeyboardVisible } from \"@/lib/hooks/dom/useVirtualKeyboardVisible\";\nimport locales from \"./locales/*.locale.json\";\n\ntype SupportedOverlayProps = Pick<\n OverlayProps,\n \"isOpen\" | \"isDefaultOpen\" | \"onOpen\" | \"onClose\" | \"onOpenChange\"\n>;\n\nexport interface ModalProps\n extends\n PropsWithChildren,\n FlowComponentProps,\n PropsWithClassName,\n SupportedOverlayProps {\n /** The size of the modal. @default \"s\" */\n size?: \"s\" | \"m\" | \"l\";\n /** Whether the modal should be displayed as an off canvas. */\n offCanvas?: boolean;\n /**\n * Whether the off canvas should be displayed on the right or left side of the\n * screen. @default \"right\"\n */\n offCanvasOrientation?: \"left\" | \"right\";\n /** An overlay controller to control the modal state. */\n controller?: OverlayController;\n /**\n * Accepts \"actionConfirm\" to use the modal as a confirmation modal for an\n * action.\n */\n slot?: string;\n /** Whether the modal can be closed by clicking outside of it. */\n isDismissable?: boolean;\n /** Whether the close button should be visible */\n showCloseButton?: boolean;\n /**\n * Whether closing the modal must be confirmed – use it to protect unsaved\n * changes.\n */\n confirmOnClose?: boolean;\n}\n\nexport const Modal = flowComponent(\"Modal\", (props) => {\n const {\n size = \"s\",\n offCanvas,\n controller,\n children,\n ref,\n className,\n offCanvasOrientation = \"right\",\n showCloseButton,\n ...overlayProps\n } = props;\n\n const stringFormatter = useLocalizedStringFormatter(locales, \"Modal\");\n\n // On mobile the header/footer are docked (sticky) while at rest, but flow\n // normally while the on-screen keyboard is open so the content gets the full\n // available space (see Modal.module.scss). #2423\n const keyboardVisible = useVirtualKeyboardVisible();\n\n const rootClassName = clsx(\n offCanvas ? styles.offCanvas : styles.modal,\n styles[`size-${size}`],\n offCanvasOrientation === \"left\" && styles[\"left\"],\n keyboardVisible && styles.keyboardVisible,\n className,\n );\n\n const generatedId = useId();\n\n const header = (children: ReactNode) => (\n <>\n {children}\n <Action closeModal={{ bypassConfirmation: true }}>\n <ButtonView\n variant=\"plain\"\n color=\"secondary\"\n aria-label={stringFormatter.format(\"close\")}\n className={clsx(\n styles.closeButton,\n showCloseButton === true\n ? styles.alwaysVisible\n : showCloseButton === false\n ? styles.alwaysHidden\n : undefined,\n )}\n >\n <IconClose />\n </ButtonView>\n </Action>\n </>\n );\n\n const nestedHeadingLevel = 3;\n\n const nestedHeadingProps: PropsContext = {\n Heading: { level: nestedHeadingLevel },\n Section: {\n Header: { Heading: { level: nestedHeadingLevel } },\n Heading: { level: nestedHeadingLevel },\n hideSeparator: true,\n },\n Header: { Heading: { level: nestedHeadingLevel } },\n };\n\n const propsContext: PropsContext = {\n Content: {\n ...nestedHeadingProps,\n className: styles.content,\n },\n ColumnLayout: {\n ...nestedHeadingProps,\n l: [2, 1],\n m: [1],\n className: styles.columnLayout,\n AccentBox: { className: styles.accentBox, backgroundColor: \"neutral\" },\n wrapWith: <ClearPropsContext />,\n },\n Heading: {\n className: styles.header,\n level: 2,\n children: dynamic((props) => header(props.children)),\n id: generatedId,\n },\n ActionGroup: {\n className: styles.actionGroup,\n spacing: \"m\",\n Action: {\n closeModal: dynamic((props) => {\n if (props.closeModal === undefined) {\n return;\n }\n if (props.closeModal === true) {\n return { bypassConfirmation: true };\n }\n return {\n bypassConfirmation: true,\n ...props.closeModal,\n };\n }),\n closeOverlay: dynamic((props) => {\n if (props.closeOverlay === undefined) {\n return;\n }\n if (\n props.closeOverlay instanceof OverlayController ||\n typeof props.closeOverlay === \"string\"\n ) {\n return {\n bypassConfirmation: true,\n overlay: props.closeOverlay,\n };\n }\n return {\n bypassConfirmation: true,\n ...props.closeOverlay,\n };\n }),\n },\n },\n };\n\n return (\n <Overlay\n className={rootClassName}\n controller={controller}\n ref={ref}\n aria-labelledby={generatedId}\n {...overlayProps}\n >\n <PropsContextProvider props={propsContext}>\n <Wrap if={offCanvas}>\n <Suspense fallback={<OffCanvasSuspenseFallback />}>\n {children}\n </Suspense>\n </Wrap>\n </PropsContextProvider>\n <ConfirmUnsavedChangesModal />\n </Overlay>\n );\n});\n\nexport default Modal;\n"],"names":["children","props"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DO,MAAM,KAAA,GAAQ,aAAA,CAAc,OAAA,EAAS,CAAC,KAAA,KAAU;AACrD,EAAA,MAAM;AAAA,IACJ,IAAA,GAAO,GAAA;AAAA,IACP,SAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,IACA,GAAA;AAAA,IACA,SAAA;AAAA,IACA,oBAAA,GAAuB,OAAA;AAAA,IACv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K;AAAA,UACpC;AACA,UAAA,OAAO;AAAA,YACL,kBAAA,EAAoB,IAAA;AAAA,YACpB,GAAGA,MAAAA,CAAM;AAAA,WACX;AAAA,QACF,CAAC,CAAA;AAAA,QACD,YAAA,EAAc,OAAA,CAAQ,CAACA,MAAAA,KAAU;AAC/B,UAAA,IAAIA,MAAAA,CAAM,iBAAiB,MAAA,EAAW;AACpC,YAAA;AAAA,UACF;AACA,UAAA,IACEA,OAAM,YAAA,YAAwB,iBAAA,IAC9B,OAAOA,MAAAA,CAAM,iBAAiB,QAAA,EAC9B;AACA,YAAA,OAAO;AAAA,cACL,kBAAA,EAAoB,IAAA;AAAA,cACpB,SAASA,MAAAA,CAAM;AAAA,aACjB;AAAA,UACF;AACA,UAAA,OAAO;AAAA,YACL,kBAAA,EAAoB,IAAA;AAAA,YACpB,GAAGA,MAAAA,CAAM;AAAA,WACX;AAAA,QACF,CAAC;AAAA;AACH;AACF,GACF;AAEA,EAAA,uBACE,IAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,aAAA;AAAA,MACX,UAAA;AAAA,MACA,GAAA;AAAA,MACA,iBAAA,EAAiB,WAAA;AAAA,MAChB,GAAG,YAAA;AAAA,MAEJ,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,oBAAA,EAAA,EAAqB,KAAA,EAAO,YAAA,EAC3B,QAAA,kBAAA,GAAA,CAAC,QAAK,EAAA,EAAI,SAAA,EACR,QAAA,kBAAA,GAAA,CAAC,QAAA,EAAA,EAAS,0BAAU,GAAA,CAAC,yBAAA,EAAA,EAA0B,CAAA,EAC5C,QAAA,EACH,GACF,CAAA,EACF,CAAA;AAAA,4BACC,0BAAA,EAAA,EAA2B;AAAA;AAAA;AAAA,GAC9B;AAEJ,CAAC;;;;"}
|
|
@@ -18,8 +18,10 @@ import '../../../../lib/controller/overlay/context.mjs';
|
|
|
18
18
|
|
|
19
19
|
const ConfirmUnsavedChangesModal = () => {
|
|
20
20
|
const stringFormatter = useLocalizedStringFormatter(locales, "Modal");
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const modalController = useModalController();
|
|
22
|
+
const confirmOnCloseEnabled = modalController.useConfirmOnCloseEnabled();
|
|
23
|
+
const closeConfirmationController = modalController.useConfirmationController();
|
|
24
|
+
if (confirmOnCloseEnabled && closeConfirmationController) {
|
|
23
25
|
const { controller, confirm, cancel } = closeConfirmationController;
|
|
24
26
|
return /* @__PURE__ */ jsxs(Modal, { controller, children: [
|
|
25
27
|
/* @__PURE__ */ jsx(HeadingView, { children: stringFormatter.format("unsavedChangesConfirmationModal.heading") }),
|
|
@@ -36,5 +38,5 @@ const ConfirmUnsavedChangesModal = () => {
|
|
|
36
38
|
}
|
|
37
39
|
};
|
|
38
40
|
|
|
39
|
-
export { ConfirmUnsavedChangesModal
|
|
41
|
+
export { ConfirmUnsavedChangesModal };
|
|
40
42
|
//# sourceMappingURL=ConfirmUnsavedChangesModal.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmUnsavedChangesModal.mjs","sources":["../../../../../../../../../src/components/Modal/components/ConfirmUnsavedChangesModal/ConfirmUnsavedChangesModal.tsx"],"sourcesContent":["import ContentView from \"@/views/ContentView\";\nimport HeadingView from \"@/views/HeadingView\";\nimport type { FC } from \"react\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider/useLocalizedStringFormatter\";\nimport locales from \"../../locales/*.locale.json\";\nimport Modal from \"@/components/Modal/Modal\";\nimport TextView from \"@/views/TextView\";\nimport ActionGroupView from \"@/views/ActionGroupView\";\nimport Action from \"@/components/Action\";\nimport ButtonView from \"@/views/ButtonView\";\nimport { useModalController } from \"@/lib/controller\";\n\nexport const ConfirmUnsavedChangesModal: FC = () => {\n const stringFormatter = useLocalizedStringFormatter(locales, \"Modal\");\n const closeConfirmationController =\n
|
|
1
|
+
{"version":3,"file":"ConfirmUnsavedChangesModal.mjs","sources":["../../../../../../../../../src/components/Modal/components/ConfirmUnsavedChangesModal/ConfirmUnsavedChangesModal.tsx"],"sourcesContent":["import ContentView from \"@/views/ContentView\";\nimport HeadingView from \"@/views/HeadingView\";\nimport type { FC } from \"react\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider/useLocalizedStringFormatter\";\nimport locales from \"../../locales/*.locale.json\";\nimport Modal from \"@/components/Modal/Modal\";\nimport TextView from \"@/views/TextView\";\nimport ActionGroupView from \"@/views/ActionGroupView\";\nimport Action from \"@/components/Action\";\nimport ButtonView from \"@/views/ButtonView\";\nimport { useModalController } from \"@/lib/controller\";\n\n/**\n * Rendered by every `Modal` and only becomes active once something requires the\n * close to be confirmed – the `confirmOnClose` prop or a dirty `Form`.\n */\nexport const ConfirmUnsavedChangesModal: FC = () => {\n const stringFormatter = useLocalizedStringFormatter(locales, \"Modal\");\n const modalController = useModalController();\n const confirmOnCloseEnabled = modalController.useConfirmOnCloseEnabled();\n const closeConfirmationController =\n modalController.useConfirmationController();\n\n if (confirmOnCloseEnabled && closeConfirmationController) {\n const { controller, confirm, cancel } = closeConfirmationController;\n\n return (\n <Modal controller={controller}>\n <HeadingView>\n {stringFormatter.format(\"unsavedChangesConfirmationModal.heading\")}\n </HeadingView>\n <ContentView>\n <TextView>\n {stringFormatter.format(\"unsavedChangesConfirmationModal.text\")}\n </TextView>\n </ContentView>\n <ActionGroupView>\n <Action closeModal>\n <Action onAction={confirm}>\n <ButtonView color=\"danger\">\n {stringFormatter.format(\n \"unsavedChangesConfirmationModal.close\",\n )}\n </ButtonView>\n </Action>\n <Action onAction={cancel}>\n <ButtonView color=\"secondary\" variant=\"soft\">\n {stringFormatter.format(\n \"unsavedChangesConfirmationModal.keepOpen\",\n )}\n </ButtonView>\n </Action>\n </Action>\n </ActionGroupView>\n </Modal>\n );\n }\n};\n\nexport default ConfirmUnsavedChangesModal;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAgBO,MAAM,6BAAiC,MAAM;AAClD,EAAA,MAAM,eAAA,GAAkB,2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../../src/components/Overlay/Overlay.tsx"],"sourcesContent":["import type { FC, PropsWithChildren, Ref } from \"react\";\nimport styles from \"./Overlay.module.scss\";\nimport clsx from \"clsx\";\nimport type { OverlayController } from \"@/lib/controller\";\nimport { useOverlayController } from \"@/lib/controller\";\nimport OverlayContextProvider from \"@/lib/controller/overlay/OverlayContextProvider\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport OverlayContentView from \"@/views/OverlayContentView\";\nimport type {\n OverlayCloseHandler,\n OverlayOpenHandler,\n OverlayOpenStateHandler,\n} from \"@/lib/controller/overlay/OverlayController\";\nimport type * as Aria from \"react-aria-components\";\n\nexport interface OverlayProps\n extends\n PropsWithChildren,\n PropsWithClassName,\n Pick<Aria.DialogProps, \"aria-labelledby\"> {\n ref?: Ref<HTMLDivElement>;\n /** The controller to control the overlay state. */\n controller?: OverlayController;\n /** Whether the overlay can be closed by clicking outside of it. */\n isDismissable?: boolean;\n /** Whether the overlay is a modal or a light box. */\n overlayType?: \"Modal\" | \"LightBox\";\n isOpen?: boolean;\n isDefaultOpen?: boolean;\n onOpen?: OverlayOpenHandler;\n onClose?: OverlayCloseHandler;\n onOpenChange?: OverlayOpenStateHandler;\n}\n\nexport const Overlay: FC<OverlayProps> = (props) => {\n const {\n controller: controllerFromProps,\n children,\n isDismissable = true,\n className,\n overlayType = \"Modal\",\n isDefaultOpen,\n isOpen: isOpenFromProps,\n ref,\n \"aria-labelledby\": ariaLabelledBy,\n ...controllerOptions\n } = props;\n\n const controllerFromContext = useOverlayController(overlayType, {\n reuseControllerFromContext: true,\n isDefaultOpen,\n });\n\n const controller = controllerFromProps ?? controllerFromContext;\n controller.useUpdateOptions(controllerOptions);\n\n const isOpen = isOpenFromProps ?? controller.useIsOpen();\n\n const rootClassName = clsx(styles.overlay, className);\n\n return (\n <OverlayContentView\n onOpenChange={controller.setOpen}\n isOpen={isOpen}\n ref={ref}\n isDismissable={isDismissable}\n className={rootClassName}\n aria-labelledby={ariaLabelledBy}\n >\n <OverlayContextProvider type=\"Modal\" controller={controller}>\n {children}\n </OverlayContextProvider>\n </OverlayContentView>\n );\n};\n\nexport default Overlay;\n"],"names":[],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Overlay.mjs","sources":["../../../../../../../src/components/Overlay/Overlay.tsx"],"sourcesContent":["import type { FC, PropsWithChildren, Ref } from \"react\";\nimport styles from \"./Overlay.module.scss\";\nimport clsx from \"clsx\";\nimport type { OverlayController } from \"@/lib/controller\";\nimport { useOverlayController } from \"@/lib/controller\";\nimport OverlayContextProvider from \"@/lib/controller/overlay/OverlayContextProvider\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\nimport OverlayContentView from \"@/views/OverlayContentView\";\nimport type {\n OverlayCloseHandler,\n OverlayOpenHandler,\n OverlayOpenStateHandler,\n} from \"@/lib/controller/overlay/OverlayController\";\nimport type * as Aria from \"react-aria-components\";\n\nexport interface OverlayProps\n extends\n PropsWithChildren,\n PropsWithClassName,\n Pick<Aria.DialogProps, \"aria-labelledby\"> {\n ref?: Ref<HTMLDivElement>;\n /** The controller to control the overlay state. */\n controller?: OverlayController;\n /** Whether the overlay can be closed by clicking outside of it. */\n isDismissable?: boolean;\n /** Whether the overlay is a modal or a light box. */\n overlayType?: \"Modal\" | \"LightBox\";\n isOpen?: boolean;\n isDefaultOpen?: boolean;\n onOpen?: OverlayOpenHandler;\n onClose?: OverlayCloseHandler;\n onOpenChange?: OverlayOpenStateHandler;\n /** Whether closing the overlay must be confirmed. */\n confirmOnClose?: boolean;\n}\n\nexport const Overlay: FC<OverlayProps> = (props) => {\n const {\n controller: controllerFromProps,\n children,\n isDismissable = true,\n className,\n overlayType = \"Modal\",\n isDefaultOpen,\n isOpen: isOpenFromProps,\n ref,\n \"aria-labelledby\": ariaLabelledBy,\n ...controllerOptions\n } = props;\n\n const controllerFromContext = useOverlayController(overlayType, {\n reuseControllerFromContext: true,\n isDefaultOpen,\n });\n\n const controller = controllerFromProps ?? controllerFromContext;\n controller.useUpdateOptions(controllerOptions);\n\n const isOpen = isOpenFromProps ?? controller.useIsOpen();\n\n const rootClassName = clsx(styles.overlay, className);\n\n return (\n <OverlayContentView\n onOpenChange={controller.setOpen}\n isOpen={isOpen}\n ref={ref}\n isDismissable={isDismissable}\n className={rootClassName}\n aria-labelledby={ariaLabelledBy}\n >\n <OverlayContextProvider type=\"Modal\" controller={controller}>\n {children}\n </OverlayContextProvider>\n </OverlayContentView>\n );\n};\n\nexport default Overlay;\n"],"names":[],"mappings":";;;;;;;;;;;;;AAoCO,MAAM,OAAA,GAA4B,CAAC,KAAA,KAAU;AAClD,EAAA,MAAM;AAAA,IACJ,UAAA,EAAY,mBAAA;AAAA,IACZ,QAAA;AAAA,IACA,aAAA,GAAgB,IAAA;AAAA,IAChB,SAAA;AAAA,IACA,WAAA,GAAc,OAAA;AAAA,IACd,aAAA;AAAA,IACA,MAAA,EAAQ,eAAA;AAAA,IACR,GAAA;AAAA,IACA,iBAAA,EAAmB,cAAA;AAAA,IACnB,GAAG;AAAA,GACL,GAAI,KAAA;AAEJ,EAAA,MAAM,qBAAA,GAAwB,qBAAqB,WAAA,EAAa;AAAA,IAC9D,0BAAA,EAA4B,IAAA;AAAA,IAC5B;AAAA,GACD,CAAA;AAED,EAAA,MAAM,aAAa,mBAAA,IAAuB,qBAAA;AAC1C,EAAA,UAAA,CAAW,iBAAiB,iBAAiB,CAAA;AAE7C,EAAA,MAAM,MAAA,GAAS,eAAA,IAAmB,UAAA,CAAW,SAAA,EAAU;AAEvD,EAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,MAAA,CAAO,OAAA,EAAS,SAAS,CAAA;AAEpD,EAAA,uBACE,GAAA;AAAA,IAAC,kBAAA;AAAA,IAAA;AAAA,MACC,cAAc,UAAA,CAAW,OAAA;AAAA,MACzB,MAAA;AAAA,MACA,GAAA;AAAA,MACA,aAAA;AAAA,MACA,SAAA,EAAW,aAAA;AAAA,MACX,iBAAA,EAAiB,cAAA;AAAA,MAEjB,QAAA,kBAAA,GAAA,CAAC,sBAAA,EAAA,EAAuB,IAAA,EAAK,OAAA,EAAQ,YAClC,QAAA,EACH;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -31,21 +31,27 @@ const ValidationResultButton = (props) => {
|
|
|
31
31
|
`${result.identifier}-${index}`
|
|
32
32
|
);
|
|
33
33
|
}) ?? [];
|
|
34
|
-
return /* @__PURE__ */ jsxs(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
34
|
+
return /* @__PURE__ */ jsxs(
|
|
35
|
+
ContextualHelpTrigger,
|
|
36
|
+
{
|
|
37
|
+
subject: translate.format("password.requirements.subject"),
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ jsx(
|
|
40
|
+
Button,
|
|
41
|
+
{
|
|
42
|
+
"data-component": "showPasswordRules",
|
|
43
|
+
isDisabled,
|
|
44
|
+
className
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
/* @__PURE__ */ jsxs(ContextualHelp, { children: [
|
|
48
|
+
/* @__PURE__ */ jsx(Heading, { children: translate.format("password.requirements.heading") }),
|
|
49
|
+
validationResultComponents.length === 0 && /* @__PURE__ */ jsx(ValidationResultEntry, { result: { isValid: true }, unspecifiedRules: true }),
|
|
50
|
+
validationResultComponents
|
|
51
|
+
] })
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
);
|
|
49
55
|
};
|
|
50
56
|
|
|
51
57
|
export { ValidationResultButton };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationResultButton.mjs","sources":["../../../../../../../../../src/components/PasswordCreationField/components/ValidationResultButton/ValidationResultButton.tsx"],"sourcesContent":["import { type FC } from \"react\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider/useLocalizedStringFormatter\";\n\nimport locales from \"./../../locales/*.locale.json\";\nimport type { ResolvedPolicyValidationResult } from \"@/components/PasswordCreationField/PasswordCreationField\";\nimport ValidationResultEntry from \"@/components/PasswordCreationField/components/ValidationResultEntry/ValidationResultEntry\";\nimport { Button } from \"@/components/Button\";\nimport {\n ContextualHelp,\n ContextualHelpTrigger,\n} from \"@/components/ContextualHelp\";\nimport { Heading } from \"@/components/Heading\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\n\ninterface Props extends PropsWithClassName {\n policyValidationResult?: ResolvedPolicyValidationResult;\n isDisabled?: boolean;\n isEmptyValue: boolean;\n}\n\nexport const ValidationResultButton: FC<Props> = (props) => {\n const { policyValidationResult, isDisabled, isEmptyValue, className } = props;\n\n const translate = useLocalizedStringFormatter(\n locales,\n \"PasswordCreationField\",\n );\n\n let validationResults = policyValidationResult?.ruleResults?.filter((r) => {\n return isEmptyValue ? !r.isValid : true;\n });\n if (validationResults && validationResults.length === 0 && isEmptyValue) {\n // if we have no rules to show on first info - just list them all\n validationResults = policyValidationResult?.ruleResults;\n }\n\n const validationResultComponents =\n validationResults?.map((result, index) => {\n return (\n <ValidationResultEntry\n key={`${result.identifier}-${index}`}\n result={result}\n />\n );\n }) ?? [];\n\n return (\n <ContextualHelpTrigger>\n <Button\n data-component=\"showPasswordRules\"\n isDisabled={isDisabled}\n className={className}\n />\n <ContextualHelp>\n <Heading>{translate.format(\"password.requirements.heading\")}</Heading>\n {validationResultComponents.length === 0 && (\n <ValidationResultEntry result={{ isValid: true }} unspecifiedRules />\n )}\n {validationResultComponents}\n </ContextualHelp>\n </ContextualHelpTrigger>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AAoBO,MAAM,sBAAA,GAAoC,CAAC,KAAA,KAAU;AAC1D,EAAA,MAAM,EAAE,sBAAA,EAAwB,UAAA,EAAY,YAAA,EAAc,WAAU,GAAI,KAAA;AAExE,EAAA,MAAM,SAAA,GAAY,2BAAA;AAAA,IAChB,OAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,IAAI,iBAAA,GAAoB,sBAAA,EAAwB,WAAA,EAAa,MAAA,CAAO,CAAC,CAAA,KAAM;AACzE,IAAA,OAAO,YAAA,GAAe,CAAC,CAAA,CAAE,OAAA,GAAU,IAAA;AAAA,EACrC,CAAC,CAAA;AACD,EAAA,IAAI,iBAAA,IAAqB,iBAAA,CAAkB,MAAA,KAAW,CAAA,IAAK,YAAA,EAAc;AAEvE,IAAA,iBAAA,GAAoB,sBAAA,EAAwB,WAAA;AAAA,EAC9C;AAEA,EAAA,MAAM,0BAAA,GACJ,iBAAA,EAAmB,GAAA,CAAI,CAAC,QAAQ,KAAA,KAAU;AACxC,IAAA,uBACE,GAAA;AAAA,MAAC,qBAAA;AAAA,MAAA;AAAA,QAEC;AAAA,OAAA;AAAA,MADK,CAAA,EAAG,MAAA,CAAO,UAAU,CAAA,CAAA,EAAI,KAAK,CAAA;AAAA,KAEpC;AAAA,EAEJ,CAAC,KAAK,EAAC;AAET,EAAA,
|
|
1
|
+
{"version":3,"file":"ValidationResultButton.mjs","sources":["../../../../../../../../../src/components/PasswordCreationField/components/ValidationResultButton/ValidationResultButton.tsx"],"sourcesContent":["import { type FC } from \"react\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider/useLocalizedStringFormatter\";\n\nimport locales from \"./../../locales/*.locale.json\";\nimport type { ResolvedPolicyValidationResult } from \"@/components/PasswordCreationField/PasswordCreationField\";\nimport ValidationResultEntry from \"@/components/PasswordCreationField/components/ValidationResultEntry/ValidationResultEntry\";\nimport { Button } from \"@/components/Button\";\nimport {\n ContextualHelp,\n ContextualHelpTrigger,\n} from \"@/components/ContextualHelp\";\nimport { Heading } from \"@/components/Heading\";\nimport type { PropsWithClassName } from \"@/lib/types/props\";\n\ninterface Props extends PropsWithClassName {\n policyValidationResult?: ResolvedPolicyValidationResult;\n isDisabled?: boolean;\n isEmptyValue: boolean;\n}\n\nexport const ValidationResultButton: FC<Props> = (props) => {\n const { policyValidationResult, isDisabled, isEmptyValue, className } = props;\n\n const translate = useLocalizedStringFormatter(\n locales,\n \"PasswordCreationField\",\n );\n\n let validationResults = policyValidationResult?.ruleResults?.filter((r) => {\n return isEmptyValue ? !r.isValid : true;\n });\n if (validationResults && validationResults.length === 0 && isEmptyValue) {\n // if we have no rules to show on first info - just list them all\n validationResults = policyValidationResult?.ruleResults;\n }\n\n const validationResultComponents =\n validationResults?.map((result, index) => {\n return (\n <ValidationResultEntry\n key={`${result.identifier}-${index}`}\n result={result}\n />\n );\n }) ?? [];\n\n return (\n <ContextualHelpTrigger\n subject={translate.format(\"password.requirements.subject\")}\n >\n <Button\n data-component=\"showPasswordRules\"\n isDisabled={isDisabled}\n className={className}\n />\n <ContextualHelp>\n <Heading>{translate.format(\"password.requirements.heading\")}</Heading>\n {validationResultComponents.length === 0 && (\n <ValidationResultEntry result={{ isValid: true }} unspecifiedRules />\n )}\n {validationResultComponents}\n </ContextualHelp>\n </ContextualHelpTrigger>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AAoBO,MAAM,sBAAA,GAAoC,CAAC,KAAA,KAAU;AAC1D,EAAA,MAAM,EAAE,sBAAA,EAAwB,UAAA,EAAY,YAAA,EAAc,WAAU,GAAI,KAAA;AAExE,EAAA,MAAM,SAAA,GAAY,2BAAA;AAAA,IAChB,OAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,IAAI,iBAAA,GAAoB,sBAAA,EAAwB,WAAA,EAAa,MAAA,CAAO,CAAC,CAAA,KAAM;AACzE,IAAA,OAAO,YAAA,GAAe,CAAC,CAAA,CAAE,OAAA,GAAU,IAAA;AAAA,EACrC,CAAC,CAAA;AACD,EAAA,IAAI,iBAAA,IAAqB,iBAAA,CAAkB,MAAA,KAAW,CAAA,IAAK,YAAA,EAAc;AAEvE,IAAA,iBAAA,GAAoB,sBAAA,EAAwB,WAAA;AAAA,EAC9C;AAEA,EAAA,MAAM,0BAAA,GACJ,iBAAA,EAAmB,GAAA,CAAI,CAAC,QAAQ,KAAA,KAAU;AACxC,IAAA,uBACE,GAAA;AAAA,MAAC,qBAAA;AAAA,MAAA;AAAA,QAEC;AAAA,OAAA;AAAA,MADK,CAAA,EAAG,MAAA,CAAO,UAAU,CAAA,CAAA,EAAI,KAAK,CAAA;AAAA,KAEpC;AAAA,EAEJ,CAAC,KAAK,EAAC;AAET,EAAA,uBACE,IAAA;AAAA,IAAC,qBAAA;AAAA,IAAA;AAAA,MACC,OAAA,EAAS,SAAA,CAAU,MAAA,CAAO,+BAA+B,CAAA;AAAA,MAEzD,QAAA,EAAA;AAAA,wBAAA,GAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,gBAAA,EAAe,mBAAA;AAAA,YACf,UAAA;AAAA,YACA;AAAA;AAAA,SACF;AAAA,6BACC,cAAA,EAAA,EACC,QAAA,EAAA;AAAA,0BAAA,GAAA,CAAC,OAAA,EAAA,EAAS,QAAA,EAAA,SAAA,CAAU,MAAA,CAAO,+BAA+B,CAAA,EAAE,CAAA;AAAA,UAC3D,0BAAA,CAA2B,MAAA,KAAW,CAAA,oBACrC,GAAA,CAAC,qBAAA,EAAA,EAAsB,MAAA,EAAQ,EAAE,OAAA,EAAS,IAAA,EAAK,EAAG,gBAAA,EAAgB,IAAA,EAAC,CAAA;AAAA,UAEpE;AAAA,SAAA,EACH;AAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
|
package/dist/js/packages/components/src/integrations/react-hook-form/components/Form/Form.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import {
|
|
4
|
-
import { ConfirmUnsavedChangesModal } from '../../../../components/Modal/components/ConfirmUnsavedChangesModal/ConfirmUnsavedChangesModal.mjs';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
4
|
import { FormContextProvider } from '../FormContextProvider/FormContextProvider.mjs';
|
|
6
5
|
import { flags } from '../../../../flags.mjs';
|
|
7
6
|
import 'mobx';
|
|
@@ -40,7 +39,10 @@ function Form(props) {
|
|
|
40
39
|
const autoResetOptions = typeof autoReset === "boolean" ? { onAfterModalClose: autoReset } : autoReset;
|
|
41
40
|
const modalController = useModalController();
|
|
42
41
|
modalController.useUpdateOptions({
|
|
43
|
-
|
|
42
|
+
// Only contribute to the surrounding Modal's close confirmation while the
|
|
43
|
+
// flag is enabled – otherwise a `<Modal confirmOnClose>` around this Form
|
|
44
|
+
// would be overruled. The Modal renders the confirmation dialog itself.
|
|
45
|
+
confirmOnClose: flags.requireCloseModalConfirmationOnUnsavedChanges ? isDirty : void 0
|
|
44
46
|
});
|
|
45
47
|
modalController.useOnClosed(() => {
|
|
46
48
|
if (autoResetOptions?.onAfterModalClose) {
|
|
@@ -78,29 +80,26 @@ function Form(props) {
|
|
|
78
80
|
ref,
|
|
79
81
|
submitController
|
|
80
82
|
});
|
|
81
|
-
return /* @__PURE__ */
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
),
|
|
102
|
-
/* @__PURE__ */ jsx(ConfirmUnsavedChangesModal, {})
|
|
103
|
-
] });
|
|
83
|
+
return /* @__PURE__ */ jsx(FormProvider, { ...form, children: /* @__PURE__ */ jsx(
|
|
84
|
+
FormContextProvider,
|
|
85
|
+
{
|
|
86
|
+
form,
|
|
87
|
+
isReadOnly,
|
|
88
|
+
id: formId,
|
|
89
|
+
onAfterSuccessFeedback,
|
|
90
|
+
rootErrorController,
|
|
91
|
+
children: /* @__PURE__ */ jsx(
|
|
92
|
+
FormComponent,
|
|
93
|
+
{
|
|
94
|
+
...formProps,
|
|
95
|
+
ref: refWithHotkeySubmit,
|
|
96
|
+
id: formId,
|
|
97
|
+
onSubmit: handleSubmit,
|
|
98
|
+
children
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
) });
|
|
104
103
|
}
|
|
105
104
|
|
|
106
105
|
export { Form };
|
package/dist/js/packages/components/src/integrations/react-hook-form/components/Form/Form.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.mjs","sources":["../../../../../../../../../src/integrations/react-hook-form/components/Form/Form.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"Form.mjs","sources":["../../../../../../../../../src/integrations/react-hook-form/components/Form/Form.tsx"],"sourcesContent":["import { FormContextProvider } from \"@/integrations/react-hook-form/components/FormContextProvider/FormContextProvider\";\nimport { flags } from \"@/flags\";\nimport { useModalController } from \"@/lib/controller\";\nimport {\n type BaseSyntheticEvent,\n type ComponentProps,\n type FC,\n type PropsWithChildren,\n type Ref,\n type SubmitEventHandler,\n useId,\n useMemo,\n useRef,\n} from \"react\";\nimport type {\n FieldValues,\n Path,\n SubmitHandler,\n UseFormReturn,\n} from \"react-hook-form\";\nimport { FormProvider as RhfFormContextProvider } from \"react-hook-form\";\nimport { useFormRootErrorController } from \"../FormRootError/useFormRootErrorController\";\nimport { FormRootError } from \"../../lib/FormRootError\";\nimport { useFormSettings } from \"../FormSettingsProvider/FormSettingsProvider\";\nimport {\n useFormSubmitController,\n type WithFormSubmitControllerProps,\n} from \"@/integrations/react-hook-form/components/Form/hooks/useFormSubmitController\";\nimport { useHotkeySubmit } from \"@/integrations/react-hook-form/components/Form/hooks/useHotkeySubmit\";\n\nexport type FormOnSubmitHandler<F extends FieldValues> = SubmitHandler<F>;\n\nexport type AfterFormSubmitCallback = (...unknownArgs: unknown[]) => unknown;\n\nexport interface FormAutoResetOptions {\n onAfterModalClose?: boolean;\n}\n\ntype FormComponentType = FC<\n PropsWithChildren<{\n id: string;\n onSubmit?: SubmitEventHandler | FormOnSubmitHandler<never>;\n ref?: Ref<HTMLFormElement>;\n }>\n>;\n\nexport interface FormProps<F extends FieldValues>\n extends\n Omit<ComponentProps<\"form\">, \"onSubmit\">,\n PropsWithChildren,\n WithFormSubmitControllerProps {\n form: UseFormReturn<F>;\n onSubmit: FormOnSubmitHandler<F>;\n formComponent?: FC<Omit<FormComponentType, \"ref\">>;\n isReadOnly?: boolean;\n autoReset?: FormAutoResetOptions | boolean;\n}\n\nconst DefaultFormComponent: FormComponentType = (p) => <form {...p} />;\n\nexport function Form<F extends FieldValues>(props: FormProps<F>) {\n const {\n form,\n children,\n onSubmit: onSubmitProp,\n formComponent = DefaultFormComponent,\n isReadOnly,\n ref,\n id: idProp,\n autoReset = true,\n submitController: submitControllerFromProps,\n ...formProps\n } = props;\n\n const newFormId = useId();\n const formId = idProp ?? newFormId;\n const FormComponent = useMemo(() => formComponent, [formId]);\n const afterSubmitCallback = useRef<AfterFormSubmitCallback>(undefined);\n const { isDirty } = form.formState;\n const rootErrorController = useFormRootErrorController();\n\n const defaultSubmitController = useFormSubmitController();\n const submitController = submitControllerFromProps\n ? submitControllerFromProps.submit.extend(defaultSubmitController)\n : defaultSubmitController;\n\n const autoResetOptions =\n typeof autoReset === \"boolean\"\n ? { onAfterModalClose: autoReset }\n : autoReset;\n\n const modalController = useModalController();\n modalController.useUpdateOptions({\n // Only contribute to the surrounding Modal's close confirmation while the\n // flag is enabled – otherwise a `<Modal confirmOnClose>` around this Form\n // would be overruled. The Modal renders the confirmation dialog itself.\n confirmOnClose: flags.requireCloseModalConfirmationOnUnsavedChanges\n ? isDirty\n : undefined,\n });\n modalController.useOnClosed(() => {\n if (autoResetOptions?.onAfterModalClose) {\n form.reset();\n }\n });\n\n const { submitInterceptor } = useFormSettings();\n const onSubmit = submitInterceptor\n ? (values: F) => submitInterceptor<F>(onSubmitProp, values, { form })\n : onSubmitProp;\n\n const handleSubmitResult = (result: unknown) => {\n if (typeof result === \"function\") {\n afterSubmitCallback.current = result as AfterFormSubmitCallback;\n }\n const rootError = form.getFieldState(\"root\" as Path<F>)?.error;\n if (rootError && !rootErrorController.errorComponentMounted) {\n throw new FormRootError(rootError);\n }\n };\n\n const handleSubmit = (e?: BaseSyntheticEvent | F) => {\n const formEvent =\n e && \"nativeEvent\" in e ? (e as BaseSyntheticEvent) : undefined;\n formEvent?.stopPropagation();\n\n return form.handleSubmit((values, event) => {\n modalController.confirmClose();\n\n const submitResult = onSubmit(values, event);\n if (submitResult instanceof Promise) {\n return submitResult.then(handleSubmitResult);\n }\n handleSubmitResult(submitResult);\n })(formEvent);\n };\n submitController.submit.set(handleSubmit);\n\n const onAfterSuccessFeedback = () => {\n afterSubmitCallback.current?.();\n };\n\n const refWithHotkeySubmit = useHotkeySubmit({\n ref,\n submitController,\n });\n\n return (\n <RhfFormContextProvider {...form}>\n <FormContextProvider\n form={form as UseFormReturn}\n isReadOnly={isReadOnly}\n id={formId}\n onAfterSuccessFeedback={onAfterSuccessFeedback}\n rootErrorController={rootErrorController}\n >\n <FormComponent\n {...formProps}\n ref={refWithHotkeySubmit}\n id={formId}\n onSubmit={handleSubmit}\n >\n {children}\n </FormComponent>\n </FormContextProvider>\n </RhfFormContextProvider>\n );\n}\n\nexport default Form;\n"],"names":["RhfFormContextProvider"],"mappings":";;;;;;;;;;;;;;AA0DA,MAAM,uBAA0C,CAAC,CAAA,qBAAM,GAAA,CAAC,MAAA,EAAA,EAAM,GAAG,CAAA,EAAG,CAAA;AAE7D,SAAS,KAA4B,KAAA,EAAqB;AAC/D,EAAA,MAAM;AAAA,IACJ,IAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA,EAAU,YAAA;AAAA,IACV,aAAA,GAAgB,oBAAA;AAAA,IAChB,UAAA;AAAA,IACA,GAAA;AAAA,IACA,EAAA,EAAI,MAAA;AAAA,IACJ,SAAA,GAAY,IAAA;AAAA,IACZ,gBAAA,EAAkB,yBAAA;AAAA,IAClB,GAAG;AAAA,GACL,GAAI,KAAA;AAEJ,EAAA,MAAM,YAAY,KAAA,EAAM;AACxB,E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AAG,SAAA;AAAA,UACJ,GAAA,EAAK,mBAAA;AAAA,UACL,EAAA,EAAI,MAAA;AAAA,UACJ,QAAA,EAAU,YAAA;AAAA,UAET;AAAA;AAAA;AACH;AAAA,GACF,EACF,CAAA;AAEJ;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import { makeObservable, action,
|
|
3
|
+
import { observable, makeObservable, action, computed, runInAction } from 'mobx';
|
|
4
4
|
import useSelector from '../../mobx/useSelector.mjs';
|
|
5
5
|
import { useStatic } from '../../hooks/useStatic.mjs';
|
|
6
|
-
import {
|
|
6
|
+
import { useEffect, useRef } from 'react';
|
|
7
7
|
import { useCloseOverlayConfirmationController } from './useCloseOverlayConfirmationController.mjs';
|
|
8
8
|
|
|
9
9
|
class OverlayController {
|
|
@@ -14,30 +14,41 @@ class OverlayController {
|
|
|
14
14
|
onOpenChangeHandlers = /* @__PURE__ */ new Set();
|
|
15
15
|
showConfirmationModal = false;
|
|
16
16
|
closeIsConfirmed = false;
|
|
17
|
-
|
|
17
|
+
confirmOnCloseFromOptions;
|
|
18
|
+
/**
|
|
19
|
+
* Every mounted component that has an opinion on close confirmation
|
|
20
|
+
* contributes one entry here – e.g. a `Modal` with a `confirmOnClose` prop
|
|
21
|
+
* and a `Form` tracking its dirty state. Combining them instead of assigning
|
|
22
|
+
* a single flag keeps them from overwriting each other.
|
|
23
|
+
*/
|
|
24
|
+
confirmOnCloseSources = observable.map();
|
|
18
25
|
constructor(options = {}) {
|
|
19
26
|
makeObservable(this, {
|
|
20
27
|
isOpen: observable,
|
|
21
28
|
isContentSuspended: observable,
|
|
22
29
|
showConfirmationModal: observable,
|
|
30
|
+
confirmOnCloseEnabled: computed,
|
|
23
31
|
open: action.bound,
|
|
24
32
|
close: action.bound,
|
|
25
33
|
toggle: action.bound,
|
|
26
34
|
setOpen: action.bound,
|
|
27
35
|
setIsContentSuspended: action.bound,
|
|
28
|
-
confirmClose: action.bound
|
|
36
|
+
confirmClose: action.bound,
|
|
37
|
+
cancelConfirmation: action.bound
|
|
29
38
|
});
|
|
30
39
|
const { isDefaultOpen = false, confirmOnClose = false } = options;
|
|
31
40
|
this.isOpen = isDefaultOpen;
|
|
32
|
-
this.
|
|
41
|
+
this.confirmOnCloseFromOptions = confirmOnClose;
|
|
42
|
+
}
|
|
43
|
+
/** Whether closing this overlay currently requires a confirmation. */
|
|
44
|
+
get confirmOnCloseEnabled() {
|
|
45
|
+
if (this.confirmOnCloseSources.size === 0) {
|
|
46
|
+
return this.confirmOnCloseFromOptions;
|
|
47
|
+
}
|
|
48
|
+
return Array.from(this.confirmOnCloseSources.values()).some(Boolean);
|
|
33
49
|
}
|
|
34
50
|
useUpdateOptions(options = {}) {
|
|
35
|
-
const {
|
|
36
|
-
onOpen,
|
|
37
|
-
onClose,
|
|
38
|
-
onOpenChange,
|
|
39
|
-
confirmOnClose = this.confirmOnCloseEnabled
|
|
40
|
-
} = options;
|
|
51
|
+
const { onOpen, onClose, onOpenChange, confirmOnClose } = options;
|
|
41
52
|
this.useOnHandler(
|
|
42
53
|
onOpen,
|
|
43
54
|
(h) => this.addOpenStateHandler(h, this.onOpenHandlers)
|
|
@@ -50,7 +61,28 @@ class OverlayController {
|
|
|
50
61
|
onOpenChange,
|
|
51
62
|
(h) => this.addOpenStateHandler(h, this.onOpenChangeHandlers)
|
|
52
63
|
);
|
|
53
|
-
this.
|
|
64
|
+
this.useConfirmOnCloseSource(confirmOnClose);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Registers the calling component as a close confirmation source for as long
|
|
68
|
+
* as it is mounted. `undefined` contributes nothing at all.
|
|
69
|
+
*/
|
|
70
|
+
useConfirmOnCloseSource(confirmOnClose) {
|
|
71
|
+
const source = useStatic(() => ({}));
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (confirmOnClose === void 0) {
|
|
74
|
+
this.removeConfirmOnCloseSource(source);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.setConfirmOnCloseSource(source, confirmOnClose);
|
|
78
|
+
return () => this.removeConfirmOnCloseSource(source);
|
|
79
|
+
}, [this, source, confirmOnClose]);
|
|
80
|
+
}
|
|
81
|
+
setConfirmOnCloseSource(source, confirmOnClose) {
|
|
82
|
+
runInAction(() => this.confirmOnCloseSources.set(source, confirmOnClose));
|
|
83
|
+
}
|
|
84
|
+
removeConfirmOnCloseSource(source) {
|
|
85
|
+
runInAction(() => this.confirmOnCloseSources.delete(source));
|
|
54
86
|
}
|
|
55
87
|
/**
|
|
56
88
|
* Can be used to execute a callback when the Overlay has unmounted – means
|
|
@@ -161,6 +193,9 @@ class OverlayController {
|
|
|
161
193
|
useShowConfirmationModal() {
|
|
162
194
|
return useSelector(() => this.showConfirmationModal);
|
|
163
195
|
}
|
|
196
|
+
useConfirmOnCloseEnabled() {
|
|
197
|
+
return useSelector(() => this.confirmOnCloseEnabled);
|
|
198
|
+
}
|
|
164
199
|
useConfirmationController() {
|
|
165
200
|
return useCloseOverlayConfirmationController(this);
|
|
166
201
|
}
|