@digigov/ui 2.0.0-76ec20a0 → 2.0.0-7d765d3c
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/app/Footer/__stories__/Default.d.ts +1 -1
- package/app/Loader/Loader.stories.d.ts +45 -1
- package/app/Loader/__stories__/AccessibilityLoader.d.ts +3 -0
- package/app/Loader/__stories__/FullPageLoader.d.ts +1 -0
- package/app/Loader/__stories__/Secondary.d.ts +3 -0
- package/app/Loader/__stories__/Sizes.d.ts +3 -0
- package/app/Loader/index.native.d.ts +2 -2
- package/app/Loader/index.native.js.map +2 -2
- package/app/Loader/index.web/index.js +17 -1
- package/app/Loader/index.web.d.ts +19 -1
- package/app/Loader/index.web.js.map +3 -3
- package/app/Masthead/Masthead.stories.d.ts +28 -1
- package/app/Modal/Modal.stories.d.ts +20 -1
- package/app/Modal/hooks/index.js +2 -6
- package/app/Modal/hooks.d.ts +2 -2
- package/app/Modal/hooks.js.map +2 -2
- package/app/Modal/index.web/index.js +5 -5
- package/app/Modal/index.web.js.map +2 -2
- package/app/NotFound/__stories__/Default.d.ts +1 -1
- package/app/OutdatedBrowserBanner/index.d.ts +1 -0
- package/app/OutdatedBrowserBanner/index.js.map +2 -2
- package/app/PhaseBannerHeader/index.d.ts +1 -1
- package/app/PhaseBannerHeader/index.js.map +2 -2
- package/app/Skeleton/__stories__/Button.d.ts +1 -1
- package/app/Skeleton/__stories__/Default.d.ts +1 -1
- package/app/Skeleton/__stories__/NoAnimation.d.ts +1 -1
- package/app/hooks/useNotificationArea/index.js +76 -0
- package/app/hooks/useNotificationArea/package.json +6 -0
- package/app/hooks/useNotificationArea.d.ts +1 -0
- package/app/hooks/useNotificationArea.js.map +7 -0
- package/cjs/app/Loader/index.native.js.map +2 -2
- package/cjs/app/Loader/index.web/index.js +33 -2
- package/cjs/app/Loader/index.web.js.map +3 -3
- package/cjs/app/Modal/hooks/index.js +2 -6
- package/cjs/app/Modal/hooks.js.map +2 -2
- package/cjs/app/Modal/index.web/index.js +5 -5
- package/cjs/app/Modal/index.web.js.map +2 -2
- package/cjs/app/OutdatedBrowserBanner/index.js.map +2 -2
- package/cjs/app/PhaseBannerHeader/index.js.map +2 -2
- package/cjs/app/hooks/useNotificationArea/index.js +99 -0
- package/cjs/app/hooks/useNotificationArea.js.map +7 -0
- package/cjs/content/Accordion/hooks.js.map +1 -1
- package/cjs/form/AutoComplete/Status/index.js.map +2 -2
- package/cjs/form/AutoComplete/index.js +32 -19
- package/cjs/form/AutoComplete/index.js.map +2 -2
- package/cjs/i18n/locales/el/index.js +51 -23
- package/cjs/i18n/locales/el.js.map +2 -2
- package/cjs/i18n/locales/en/index.js +36 -8
- package/cjs/i18n/locales/en.js.map +2 -2
- package/cjs/layouts/Hidden/index.js +19 -0
- package/cjs/layouts/Hidden/index.js.map +3 -3
- package/cjs/lazy.js +1 -1
- package/cjs/lazy.js.map +2 -2
- package/cjs/navigation/Drawer/hooks/index.js +2 -6
- package/cjs/navigation/Drawer/hooks.js.map +2 -2
- package/cjs/navigation/Pagination/hooks/index.js +2 -2
- package/cjs/navigation/Pagination/hooks.js.map +2 -2
- package/cjs/navigation/Tabs/hooks.js.map +1 -1
- package/cjs/registry.js +50 -48
- package/cjs/registry.js.map +2 -2
- package/cjs/typography/CodeBlock/index.js +1 -2
- package/cjs/typography/CodeBlock/index.js.map +2 -2
- package/cjs/utils/hooks/useDebounce/index.js +1 -1
- package/cjs/utils/hooks/useDebounce.js.map +2 -2
- package/content/Accordion/Accordion.stories.d.ts +27 -16
- package/content/Accordion/hooks.js.map +1 -1
- package/content/Chip/__stories__/Default.d.ts +1 -1
- package/content/SummaryList/SummaryList.stories.d.ts +4 -1
- package/feedback/NotificationBanner/NotificationBanner.stories.d.ts +14 -13
- package/feedback/NotificationBanner/__stories__/Expanded.d.ts +3 -0
- package/feedback/PhaseBanner/PhaseBanner.stories.d.ts +1 -1
- package/form/AutoComplete/AutoComplete.stories.d.ts +57 -16
- package/form/AutoComplete/Status/index.d.ts +1 -1
- package/form/AutoComplete/Status/index.js.map +2 -2
- package/form/AutoComplete/__stories__/WithCustomValue.d.ts +3 -0
- package/form/AutoComplete/__stories__/WithHint.d.ts +3 -0
- package/form/AutoComplete/index.d.ts +4 -3
- package/form/AutoComplete/index.js +32 -18
- package/form/AutoComplete/index.js.map +2 -2
- package/form/Button/__stories__/ThemeToggle.d.ts +1 -1
- package/form/FileUpload/FileUpload.stories.d.ts +1 -0
- package/form/FileUpload/__stories__/WithVariantLink.d.ts +3 -0
- package/i18n/locales/el/index.js +51 -23
- package/i18n/locales/el.d.ts +33 -5
- package/i18n/locales/el.js.map +2 -2
- package/i18n/locales/en/index.js +36 -8
- package/i18n/locales/en.d.ts +32 -4
- package/i18n/locales/en.js.map +2 -2
- package/index.js +1 -1
- package/layouts/Grid/Grid.stories.d.ts +82 -0
- package/layouts/Hidden/Hidden.stories.d.ts +115 -0
- package/layouts/Hidden/index.d.ts +2 -0
- package/layouts/Hidden/index.js +5 -0
- package/layouts/Hidden/index.js.map +2 -2
- package/layouts/Stack/Stack.stories.d.ts +76 -0
- package/lazy/index.js +1 -1
- package/navigation/BackToTopLink/BackToTopLink.stories.d.ts +2 -0
- package/navigation/Drawer/hooks/index.js +2 -6
- package/navigation/Drawer/hooks.js.map +2 -2
- package/navigation/Dropdown/Dropdown.stories.d.ts +75 -1
- package/navigation/Pagination/hooks/index.js +2 -2
- package/navigation/Pagination/hooks.js.map +2 -2
- package/navigation/SkipLink/SkipLink.stories.d.ts +2 -0
- package/navigation/Tabs/hooks.d.ts +1 -1
- package/navigation/Tabs/hooks.js.map +1 -1
- package/package.json +7 -7
- package/registry/index.js +50 -48
- package/src/app/BannerContainer/__stories__/CookiesBanner.tsx +1 -21
- package/src/app/Footer/__stories__/Default.tsx +1 -1
- package/src/app/Header/doc.mdx +3 -3
- package/src/app/Loader/Loader.stories.jsx +54 -0
- package/src/app/Loader/__stories__/AccessibilityLoader.tsx +27 -0
- package/src/app/Loader/__stories__/FullPageLoader.tsx +9 -5
- package/src/app/Loader/__stories__/Secondary.tsx +11 -0
- package/src/app/Loader/__stories__/Sizes.tsx +18 -0
- package/src/app/Loader/doc.mdx +39 -0
- package/src/app/Loader/index.native.tsx +2 -2
- package/src/app/Loader/index.test.tsx +12 -0
- package/src/app/Loader/index.web.tsx +39 -1
- package/src/app/Masthead/Masthead.stories.jsx +66 -0
- package/src/app/Masthead/doc.mdx +3 -3
- package/src/app/Modal/Modal.stories.jsx +64 -0
- package/src/app/Modal/__stories__/AlertDialog.tsx +1 -1
- package/src/app/Modal/__stories__/Auto.tsx +1 -1
- package/src/app/Modal/__stories__/Default.tsx +1 -1
- package/src/app/Modal/__stories__/Dense.tsx +1 -1
- package/src/app/Modal/__stories__/WithHooks.tsx +1 -1
- package/src/app/Modal/__stories__/WithoutModalGaps.tsx +1 -1
- package/src/app/Modal/hooks.ts +8 -8
- package/src/app/Modal/index.web.tsx +5 -7
- package/src/app/NotFound/__stories__/Default.tsx +1 -1
- package/src/app/OutdatedBrowserBanner/index.tsx +1 -1
- package/src/app/PhaseBannerHeader/index.tsx +1 -1
- package/src/app/Skeleton/__stories__/Button.tsx +1 -1
- package/src/app/Skeleton/__stories__/Default.tsx +1 -1
- package/src/app/Skeleton/__stories__/NoAnimation.tsx +1 -1
- package/src/app/hooks/useNotificationArea.tsx +105 -0
- package/src/content/Accordion/Accordion.stories.jsx +9 -1
- package/src/content/Accordion/doc.mdx +1 -2
- package/src/content/Accordion/hooks.ts +1 -1
- package/src/content/Card/doc.mdx +11 -11
- package/src/content/Chip/__stories__/Default.tsx +1 -1
- package/src/content/Chip/doc.mdx +4 -4
- package/src/content/List/__snapshots__/index.spec.tsx.snap +13 -3
- package/src/content/List/doc.mdx +3 -3
- package/src/content/SummaryList/SummaryList.stories.js +5 -1
- package/src/content/TaskList/doc.mdx +1 -1
- package/src/content/Timeline/doc.mdx +1 -1
- package/src/feedback/CopyToClipboard/doc.mdx +1 -1
- package/src/feedback/ErrorSummary/__snapshots__/index.spec.tsx.snap +13 -3
- package/src/feedback/ErrorSummary/doc.mdx +1 -1
- package/src/feedback/NotificationBanner/NotificationBanner.stories.js +10 -9
- package/src/feedback/NotificationBanner/__snapshots__/index.spec.tsx.snap +24 -14
- package/src/feedback/NotificationBanner/__stories__/Expanded.tsx +27 -0
- package/src/feedback/NotificationBanner/doc.mdx +15 -6
- package/src/feedback/NotificationBanner/index.test.tsx +4 -0
- package/src/feedback/PhaseBanner/PhaseBanner.stories.jsx +1 -1
- package/src/feedback/WarningText/__snapshots__/index.spec.tsx.snap +13 -3
- package/src/form/AutoComplete/AutoComplete.stories.jsx +19 -4
- package/src/form/AutoComplete/Status/index.tsx +1 -1
- package/src/form/AutoComplete/__stories__/WithAutoSelect.tsx +1 -17
- package/src/form/AutoComplete/__stories__/WithCustomValue.tsx +28 -0
- package/src/form/AutoComplete/__stories__/WithDefaultValue.tsx +1 -6
- package/src/form/AutoComplete/__stories__/WithHint.tsx +16 -0
- package/src/form/AutoComplete/doc.mdx +14 -13
- package/src/form/AutoComplete/index.test.tsx +8 -0
- package/src/form/AutoComplete/index.tsx +38 -25
- package/src/form/Button/__stories__/ThemeToggle.tsx +1 -1
- package/src/form/Button/doc.mdx +25 -14
- package/src/form/Checkbox/doc.mdx +1 -1
- package/src/form/FileUpload/FileUpload.stories.js +1 -0
- package/src/form/FileUpload/__stories__/WithVariantLink.tsx +24 -0
- package/src/form/FileUpload/index.test.tsx +4 -0
- package/src/form/RadioContainer/doc.mdx +4 -4
- package/src/i18n/locales/el.ts +73 -22
- package/src/i18n/locales/en.ts +43 -7
- package/src/layouts/Basic/doc.mdx +0 -2
- package/src/layouts/Grid/Grid.stories.jsx +143 -0
- package/src/layouts/Hidden/Hidden.stories.jsx +62 -0
- package/src/layouts/Hidden/index.tsx +3 -0
- package/src/layouts/Stack/Stack.stories.jsx +104 -0
- package/src/lazy.js +1 -1
- package/src/navigation/BackToTopLink/BackToTopLink.stories.js +4 -0
- package/src/navigation/BackToTopLink/doc.mdx +22 -0
- package/src/navigation/Breadcrumbs/doc.mdx +4 -0
- package/src/navigation/Drawer/hooks.ts +6 -6
- package/src/navigation/Dropdown/Dropdown.stories.jsx +118 -0
- package/src/navigation/Dropdown/doc.mdx +24 -2
- package/src/navigation/NavList/__snapshots__/index.spec.tsx.snap +13 -3
- package/src/navigation/NavList/doc.mdx +1 -1
- package/src/navigation/Pagination/doc.mdx +5 -1
- package/src/navigation/Pagination/hooks.ts +2 -2
- package/src/navigation/SkipLink/SkipLink.stories.js +4 -0
- package/src/navigation/SkipLink/doc.mdx +19 -0
- package/src/navigation/Tabs/hooks.ts +2 -2
- package/src/registry.js +50 -48
- package/src/typography/CodeBlock/CodeBlock.stories.js +24 -0
- package/src/typography/CodeBlock/index.tsx +14 -12
- package/src/typography/Heading/Heading.stories.js +12 -0
- package/src/typography/HeadingCaption/HeadingCaption.stories.js +9 -0
- package/src/typography/Hint/Hint.stories.js +11 -0
- package/src/typography/Hint/__stories__/Default.tsx +1 -1
- package/src/typography/Hint/__stories__/FontSizes.tsx +4 -4
- package/src/typography/NormalText/NormalText.stories.js +10 -0
- package/src/typography/NormalText/__stories__/Default.tsx +1 -1
- package/src/typography/Paragraph/Paragraph.stories.js +23 -0
- package/src/typography/Paragraph/__stories__/Default.tsx +1 -1
- package/src/typography/Paragraph/__stories__/LeadVariant.tsx +3 -1
- package/src/typography/Paragraph/__stories__/SmallVariant.tsx +3 -1
- package/src/utils/hooks/useDebounce.ts +1 -1
- package/stories-registry/index.js +170 -154
- package/typography/CodeBlock/CodeBlock.stories.d.ts +11 -0
- package/typography/CodeBlock/index.d.ts +1 -1
- package/typography/CodeBlock/index.js +1 -2
- package/typography/CodeBlock/index.js.map +2 -2
- package/typography/Heading/Heading.stories.d.ts +10 -0
- package/typography/HeadingCaption/HeadingCaption.stories.d.ts +8 -0
- package/typography/Hint/Hint.stories.d.ts +9 -0
- package/typography/Hint/__stories__/Default.d.ts +1 -1
- package/typography/NormalText/NormalText.stories.d.ts +8 -0
- package/typography/NormalText/__stories__/Default.d.ts +1 -1
- package/typography/Paragraph/Paragraph.stories.d.ts +37 -0
- package/typography/Paragraph/__stories__/Default.d.ts +1 -1
- package/typography/Paragraph/__stories__/LeadVariant.d.ts +1 -1
- package/typography/Paragraph/__stories__/SmallVariant.d.ts +1 -1
- package/utils/hooks/useDebounce/index.js +1 -1
- package/utils/hooks/useDebounce.js.map +2 -2
- package/utils/hooks/useLatest.d.ts +1 -1
- package/src/app/Loader/Loader.stories.js +0 -8
- package/src/app/Masthead/Masthead.stories.js +0 -17
- package/src/app/Modal/Modal.stories.js +0 -18
- package/src/layouts/Grid/Grid.stories.js +0 -12
- package/src/layouts/Stack/Stack.stories.js +0 -15
- package/src/navigation/Dropdown/Dropdown.stories.js +0 -23
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
5
11
|
var __copyProps = (to, from, except, desc) => {
|
|
6
12
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
13
|
for (let key of __getOwnPropNames(from))
|
|
@@ -11,12 +17,37 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
11
17
|
return to;
|
|
12
18
|
};
|
|
13
19
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
14
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
29
|
var index_web_exports = {};
|
|
30
|
+
__export(index_web_exports, {
|
|
31
|
+
CircularProgress: () => CircularProgress,
|
|
32
|
+
default: () => index_web_default
|
|
33
|
+
});
|
|
16
34
|
module.exports = __toCommonJS(index_web_exports);
|
|
17
|
-
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
__reExport(index_web_exports, require("@digigov/react-core/CircularProgressBase"), module.exports);
|
|
37
|
+
var import_CircularProgressBase = __toESM(require("@digigov/react-core/CircularProgressBase"));
|
|
38
|
+
var import_useNotificationArea = require("@digigov/ui/app/hooks/useNotificationArea");
|
|
39
|
+
const CircularProgress = import_react.default.forwardRef(function CircularProgress2({
|
|
40
|
+
loadingText = "\u0393\u03AF\u03BD\u03B5\u03C4\u03B1\u03B9 \u03C6\u03CC\u03C1\u03C4\u03C9\u03C3\u03B7...",
|
|
41
|
+
loadingFinishedText = "\u0397 \u03C6\u03CC\u03C1\u03C4\u03C9\u03C3\u03B7 \u03BF\u03BB\u03BF\u03BA\u03BB\u03B7\u03C1\u03CE\u03B8\u03B7\u03BA\u03B5.",
|
|
42
|
+
...props
|
|
43
|
+
}, ref) {
|
|
44
|
+
(0, import_useNotificationArea.useNotificationArea)(loadingText, loadingFinishedText);
|
|
45
|
+
return /* @__PURE__ */ import_react.default.createElement(import_CircularProgressBase.default, { ref, ...props });
|
|
46
|
+
});
|
|
47
|
+
var index_web_default = CircularProgress;
|
|
18
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
19
49
|
0 && (module.exports = {
|
|
20
|
-
|
|
50
|
+
CircularProgress,
|
|
51
|
+
...require("@digigov/react-core/CircularProgressBase")
|
|
21
52
|
});
|
|
22
53
|
//# sourceMappingURL=index.web.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/app/Loader/index.web.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nexport * from '@digigov/react-core/CircularProgressBase';\nimport CircularProgressBase, {\n CircularProgressBaseProps,\n} from '@digigov/react-core/CircularProgressBase';\nimport { useNotificationArea } from '@digigov/ui/app/hooks/useNotificationArea';\n\nexport interface CircularProgressProps extends CircularProgressBaseProps {\n /**\n * loadingText prop is optional\n * Text for screen readers when loading starts\n * @default \"\u0393\u03AF\u03BD\u03B5\u03C4\u03B1\u03B9 \u03C6\u03CC\u03C1\u03C4\u03C9\u03C3\u03B7...\"\n */\n loadingText?: string;\n /**\n * loadingFinishedText prop is optional\n * Text for screen readers when loading finishes\n * @default \"\u0397 \u03C6\u03CC\u03C1\u03C4\u03C9\u03C3\u03B7 \u03BF\u03BB\u03BF\u03BA\u03BB\u03B7\u03C1\u03CE\u03B8\u03B7\u03BA\u03B5.\"\n */\n loadingFinishedText?: string;\n}\n\nexport const CircularProgress = React.forwardRef<\n SVGElement,\n CircularProgressProps\n>(function CircularProgress(\n {\n loadingText = '\u0393\u03AF\u03BD\u03B5\u03C4\u03B1\u03B9 \u03C6\u03CC\u03C1\u03C4\u03C9\u03C3\u03B7...',\n loadingFinishedText = '\u0397 \u03C6\u03CC\u03C1\u03C4\u03C9\u03C3\u03B7 \u03BF\u03BB\u03BF\u03BA\u03BB\u03B7\u03C1\u03CE\u03B8\u03B7\u03BA\u03B5.',\n ...props\n },\n ref\n) {\n useNotificationArea(loadingText, loadingFinishedText);\n\n return <CircularProgressBase ref={ref} {...props} />;\n});\n\nexport default CircularProgress;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,8BAAc,qDADd;AAEA,kCAEO;AACP,iCAAoC;AAiB7B,MAAM,mBAAmB,aAAAA,QAAM,WAGpC,SAASC,kBACT;AAAA,EACE,cAAc;AAAA,EACd,sBAAsB;AAAA,EACtB,GAAG;AACL,GACA,KACA;AACA,sDAAoB,aAAa,mBAAmB;AAEpD,SAAO,6BAAAD,QAAA,cAAC,4BAAAE,SAAA,EAAqB,KAAW,GAAG,OAAO;AACpD,CAAC;AAED,IAAO,oBAAQ;",
|
|
6
|
+
"names": ["React", "CircularProgress", "CircularProgressBase"]
|
|
7
7
|
}
|
|
@@ -33,12 +33,8 @@ module.exports = __toCommonJS(hooks_exports);
|
|
|
33
33
|
var import_react = __toESM(require("react"));
|
|
34
34
|
const useModal = () => {
|
|
35
35
|
const [currentOpen, setCurrentOpen] = (0, import_react.useState)(null);
|
|
36
|
-
const modalsRef = (0, import_react.useRef)(
|
|
37
|
-
|
|
38
|
-
);
|
|
39
|
-
const buttonsRef = (0, import_react.useRef)(
|
|
40
|
-
/* @__PURE__ */ new Map()
|
|
41
|
-
);
|
|
36
|
+
const modalsRef = (0, import_react.useRef)(/* @__PURE__ */ new Map());
|
|
37
|
+
const buttonsRef = (0, import_react.useRef)(/* @__PURE__ */ new Map());
|
|
42
38
|
const open = (0, import_react.useCallback)((id) => {
|
|
43
39
|
setCurrentOpen(id);
|
|
44
40
|
}, []);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/app/Modal/hooks.ts"],
|
|
4
|
-
"sourcesContent": ["import React, { useState, useRef, useCallback } from 'react';\n\nexport type ModalId = string | number;\n\nexport interface UseModalReturn {\n open: (id: ModalId) => void;\n close: () => void;\n currentOpen: ModalId | null;\n registerModal: (\n id: ModalId,\n options?: {\n clickOutside?: boolean;\n closeOnEscape?: boolean;\n }\n ) => {\n open: boolean;\n role: string;\n id: string;\n 'aria-modal': boolean;\n 'aria-labelledby': string;\n ref?: React.RefObject<HTMLDivElement>;\n };\n registerAction: (\n id: ModalId,\n type: 'open' | 'close',\n options?: {\n variant?: string;\n color?: string;\n }\n ) => {\n onClick: () => void;\n ref?: React.RefObject<HTMLButtonElement>;\n };\n}\n\nexport const useModal = (): UseModalReturn => {\n const [currentOpen, setCurrentOpen] = useState<ModalId | null>(null);\n const modalsRef = useRef
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqD;AAmC9C,MAAM,WAAW,MAAsB;AAC5C,QAAM,CAAC,aAAa,cAAc,QAAI,uBAAyB,IAAI;AACnE,QAAM,gBAAY
|
|
4
|
+
"sourcesContent": ["import React, { useState, useRef, useCallback } from 'react';\n\nexport type ModalId = string | number;\n\nexport interface UseModalReturn {\n open: (id: ModalId) => void;\n close: () => void;\n currentOpen: ModalId | null;\n registerModal: (\n id: ModalId,\n options?: {\n clickOutside?: boolean;\n closeOnEscape?: boolean;\n }\n ) => {\n open: boolean;\n role: string;\n id: string;\n 'aria-modal': boolean;\n 'aria-labelledby': string;\n ref?: React.RefObject<HTMLDivElement | null>;\n };\n registerAction: (\n id: ModalId,\n type: 'open' | 'close',\n options?: {\n variant?: string;\n color?: string;\n }\n ) => {\n onClick: () => void;\n ref?: React.RefObject<HTMLButtonElement | null>;\n };\n}\n\nexport const useModal = (): UseModalReturn => {\n const [currentOpen, setCurrentOpen] = useState<ModalId | null>(null);\n const modalsRef = useRef<\n Map<ModalId, React.RefObject<HTMLDivElement | null>>\n >(new Map());\n const buttonsRef = useRef<\n Map<ModalId, React.RefObject<HTMLButtonElement | null>>\n >(new Map());\n const open = useCallback((id: ModalId) => {\n setCurrentOpen(id);\n }, []);\n\n const close = useCallback(() => {\n setCurrentOpen(null);\n }, []);\n\n const registerModal = useCallback(\n (id, options) => {\n const modalId = `modal-${id}`;\n if (!modalsRef.current.get(id)?.current) {\n modalsRef.current.set(id, React.createRef());\n if (options?.clickOutside && currentOpen === id) {\n const handleOutsideClick = (event: MouseEvent) => {\n const modalContainer = document.getElementById(modalId);\n if (modalContainer === event.target) {\n close();\n }\n };\n window.addEventListener('mousedown', handleOutsideClick);\n }\n }\n return {\n open: currentOpen === id,\n role: 'dialog',\n id: modalId,\n onEscape: options?.closeOnEscape ? close : null,\n 'aria-modal': true,\n 'aria-labelledby': `modal-heading-${id}`,\n ref: modalsRef.current.get(id as string),\n };\n },\n [currentOpen]\n );\n\n const registerAction = useCallback(\n (id: ModalId, type: 'open' | 'close', options) => {\n if (!buttonsRef.current.has(id)) {\n buttonsRef.current.set(id, React.createRef());\n }\n return {\n onClick: () => (type === 'open' ? open(id) : close()),\n ref: buttonsRef.current.get(id),\n ...options,\n };\n },\n [currentOpen]\n );\n\n return {\n open,\n close,\n currentOpen,\n registerAction,\n registerModal,\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqD;AAmC9C,MAAM,WAAW,MAAsB;AAC5C,QAAM,CAAC,aAAa,cAAc,QAAI,uBAAyB,IAAI;AACnE,QAAM,gBAAY,qBAEhB,oBAAI,IAAI,CAAC;AACX,QAAM,iBAAa,qBAEjB,oBAAI,IAAI,CAAC;AACX,QAAM,WAAO,0BAAY,CAAC,OAAgB;AACxC,mBAAe,EAAE;AAAA,EACnB,GAAG,CAAC,CAAC;AAEL,QAAM,YAAQ,0BAAY,MAAM;AAC9B,mBAAe,IAAI;AAAA,EACrB,GAAG,CAAC,CAAC;AAEL,QAAM,oBAAgB;AAAA,IACpB,CAAC,IAAI,YAAY;AACf,YAAM,UAAU,SAAS,EAAE;AAC3B,UAAI,CAAC,UAAU,QAAQ,IAAI,EAAE,GAAG,SAAS;AACvC,kBAAU,QAAQ,IAAI,IAAI,aAAAA,QAAM,UAAU,CAAC;AAC3C,YAAI,SAAS,gBAAgB,gBAAgB,IAAI;AAC/C,gBAAM,qBAAqB,CAAC,UAAsB;AAChD,kBAAM,iBAAiB,SAAS,eAAe,OAAO;AACtD,gBAAI,mBAAmB,MAAM,QAAQ;AACnC,oBAAM;AAAA,YACR;AAAA,UACF;AACA,iBAAO,iBAAiB,aAAa,kBAAkB;AAAA,QACzD;AAAA,MACF;AACA,aAAO;AAAA,QACL,MAAM,gBAAgB;AAAA,QACtB,MAAM;AAAA,QACN,IAAI;AAAA,QACJ,UAAU,SAAS,gBAAgB,QAAQ;AAAA,QAC3C,cAAc;AAAA,QACd,mBAAmB,iBAAiB,EAAE;AAAA,QACtC,KAAK,UAAU,QAAQ,IAAI,EAAY;AAAA,MACzC;AAAA,IACF;AAAA,IACA,CAAC,WAAW;AAAA,EACd;AAEA,QAAM,qBAAiB;AAAA,IACrB,CAAC,IAAa,MAAwB,YAAY;AAChD,UAAI,CAAC,WAAW,QAAQ,IAAI,EAAE,GAAG;AAC/B,mBAAW,QAAQ,IAAI,IAAI,aAAAA,QAAM,UAAU,CAAC;AAAA,MAC9C;AACA,aAAO;AAAA,QACL,SAAS,MAAO,SAAS,SAAS,KAAK,EAAE,IAAI,MAAM;AAAA,QACnD,KAAK,WAAW,QAAQ,IAAI,EAAE;AAAA,QAC9B,GAAG;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,WAAW;AAAA,EACd;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -46,18 +46,18 @@ const Modal = import_react.default.forwardRef(
|
|
|
46
46
|
);
|
|
47
47
|
const ModalBase = import_react.default.forwardRef(
|
|
48
48
|
function ModalBase2({ open, children, onEscape, ...props }, ref) {
|
|
49
|
-
const firstModalElement = (0, import_react.useRef)();
|
|
50
|
-
const lastModalElement = (0, import_react.useRef)();
|
|
49
|
+
const firstModalElement = (0, import_react.useRef)(null);
|
|
50
|
+
const lastModalElement = (0, import_react.useRef)(null);
|
|
51
51
|
const handleFocus = (0, import_react.useCallback)(() => {
|
|
52
|
-
firstModalElement.current
|
|
52
|
+
firstModalElement.current?.focus();
|
|
53
53
|
}, []);
|
|
54
54
|
(0, import_useKeypress.default)("Escape", onEscape);
|
|
55
55
|
(0, import_react.useEffect)(() => {
|
|
56
56
|
const lastModalElementInstance = lastModalElement.current;
|
|
57
57
|
handleFocus();
|
|
58
|
-
lastModalElementInstance
|
|
58
|
+
lastModalElementInstance?.addEventListener("focus", handleFocus);
|
|
59
59
|
return () => {
|
|
60
|
-
lastModalElementInstance
|
|
60
|
+
lastModalElementInstance?.removeEventListener("focus", handleFocus);
|
|
61
61
|
};
|
|
62
62
|
}, []);
|
|
63
63
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/app/Modal/index.web.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useCallback, useEffect, useRef } from 'react';\nimport ModalContainer, {\n ModalContainerProps,\n} from '@digigov/react-core/ModalContainer';\nimport useKeypress from '@digigov/ui/utils/hooks/useKeypress';\n\nexport interface ModalProps extends ModalContainerProps {\n onEscape?: () => void;\n}\n\nexport const Modal = React.forwardRef<HTMLDivElement, ModalProps>(\n function Modal({ ...props }, ref) {\n if (props.open) {\n return <ModalBase {...props} ref={ref} />;\n } else {\n return null;\n }\n }\n);\n\nexport const ModalBase = React.forwardRef<HTMLDivElement, ModalProps>(\n function ModalBase({ open, children, onEscape, ...props }, ref) {\n const firstModalElement
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsD;AACtD,4BAEO;AACP,yBAAwB;AAMjB,MAAM,QAAQ,aAAAA,QAAM;AAAA,EACzB,SAASC,OAAM,EAAE,GAAG,MAAM,GAAG,KAAK;AAChC,QAAI,MAAM,MAAM;AACd,aAAO,6BAAAD,QAAA,cAAC,aAAW,GAAG,OAAO,KAAU;AAAA,IACzC,OAAO;AACL,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,MAAM,YAAY,aAAAA,QAAM;AAAA,EAC7B,SAASE,WAAU,EAAE,MAAM,UAAU,UAAU,GAAG,MAAM,GAAG,KAAK;AAC9D,UAAM,
|
|
4
|
+
"sourcesContent": ["import React, { useCallback, useEffect, useRef } from 'react';\nimport ModalContainer, {\n ModalContainerProps,\n} from '@digigov/react-core/ModalContainer';\nimport useKeypress from '@digigov/ui/utils/hooks/useKeypress';\n\nexport interface ModalProps extends ModalContainerProps {\n onEscape?: () => void;\n}\n\nexport const Modal = React.forwardRef<HTMLDivElement, ModalProps>(\n function Modal({ ...props }, ref) {\n if (props.open) {\n return <ModalBase {...props} ref={ref} />;\n } else {\n return null;\n }\n }\n);\n\nexport const ModalBase = React.forwardRef<HTMLDivElement, ModalProps>(\n function ModalBase({ open, children, onEscape, ...props }, ref) {\n const firstModalElement = useRef<HTMLSpanElement>(null);\n const lastModalElement = useRef<HTMLSpanElement>(null);\n const handleFocus = useCallback(() => {\n firstModalElement.current?.focus();\n }, []);\n useKeypress('Escape', onEscape);\n useEffect(() => {\n const lastModalElementInstance = lastModalElement.current;\n handleFocus();\n lastModalElementInstance?.addEventListener('focus', handleFocus);\n return () => {\n lastModalElementInstance?.removeEventListener('focus', handleFocus);\n };\n }, []);\n return (\n <ModalContainer\n open={open}\n role=\"dialog\"\n ref={ref}\n aria-hidden=\"false\"\n aria-modal=\"true\"\n {...props}\n >\n <span tabIndex={-1} ref={firstModalElement} aria-hidden=\"true\" />\n {open && children}\n <span tabIndex={0} ref={lastModalElement} aria-hidden=\"true\" />\n </ModalContainer>\n );\n }\n);\n\nexport default Modal;\n"],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
6
6
|
"names": ["React", "Modal", "ModalBase", "useKeypress", "ModalContainer"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/app/OutdatedBrowserBanner/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { isMobile } from '@digigov/ui/app/OutdatedBrowserBanner/hooks/evaluateBrowserVersion';\nimport useOutdatedBrowserCheck from '@digigov/ui/app/OutdatedBrowserBanner/hooks/useOutdatedBrowserCheck';\nimport { WarningText } from '@digigov/ui/feedback/WarningText';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport Link from '@digigov/ui/navigation/Link';\nimport Paragraph from '@digigov/ui/typography/Paragraph';\n\nexport default function OutdatedBrowserBanner(): JSX.Element {\n const mob = isMobile;\n const [shouldUpdate, updateLink] = useOutdatedBrowserCheck();\n const { t } = useTranslation();\n return (\n <WarningText>\n {shouldUpdate ? (\n <>\n {mob.any() ? (\n <>\n <Paragraph>{t('outdated.mobile')}</Paragraph>\n </>\n ) : (\n <>\n <Paragraph>\n {t('outdated.web')}\n <Link href={updateLink} target=\"_blank\">\n {updateLink}{' '}\n </Link>\n </Paragraph>\n </>\n )}\n </>\n ) : (\n <></>\n )}\n </WarningText>\n );\n}\n\nexport * from '@digigov/ui/app/OutdatedBrowserBanner/hooks/useOutdatedBrowserCheck';\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import React, { type JSX } from 'react';\nimport { isMobile } from '@digigov/ui/app/OutdatedBrowserBanner/hooks/evaluateBrowserVersion';\nimport useOutdatedBrowserCheck from '@digigov/ui/app/OutdatedBrowserBanner/hooks/useOutdatedBrowserCheck';\nimport { WarningText } from '@digigov/ui/feedback/WarningText';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport Link from '@digigov/ui/navigation/Link';\nimport Paragraph from '@digigov/ui/typography/Paragraph';\n\nexport default function OutdatedBrowserBanner(): JSX.Element {\n const mob = isMobile;\n const [shouldUpdate, updateLink] = useOutdatedBrowserCheck();\n const { t } = useTranslation();\n return (\n <WarningText>\n {shouldUpdate ? (\n <>\n {mob.any() ? (\n <>\n <Paragraph>{t('outdated.mobile')}</Paragraph>\n </>\n ) : (\n <>\n <Paragraph>\n {t('outdated.web')}\n <Link href={updateLink} target=\"_blank\">\n {updateLink}{' '}\n </Link>\n </Paragraph>\n </>\n )}\n </>\n ) : (\n <></>\n )}\n </WarningText>\n );\n}\n\nexport * from '@digigov/ui/app/OutdatedBrowserBanner/hooks/useOutdatedBrowserCheck';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgC;AAChC,oCAAyB;AACzB,qCAAoC;AACpC,yBAA4B;AAC5B,kBAA+B;AAC/B,kBAAiB;AACjB,uBAAsB;AAgCtB,0CAAc,gFAtCd;AAQe,SAAR,wBAAsD;AAC3D,QAAM,MAAM;AACZ,QAAM,CAAC,cAAc,UAAU,QAAI,+BAAAA,SAAwB;AAC3D,QAAM,EAAE,EAAE,QAAI,4BAAe;AAC7B,SACE,6BAAAC,QAAA,cAAC,sCACE,eACC,6BAAAA,QAAA,2BAAAA,QAAA,gBACG,IAAI,IAAI,IACP,6BAAAA,QAAA,2BAAAA,QAAA,gBACE,6BAAAA,QAAA,cAAC,iBAAAC,SAAA,MAAW,EAAE,iBAAiB,CAAE,CACnC,IAEA,6BAAAD,QAAA,2BAAAA,QAAA,gBACE,6BAAAA,QAAA,cAAC,iBAAAC,SAAA,MACE,EAAE,cAAc,GACjB,6BAAAD,QAAA,cAAC,YAAAE,SAAA,EAAK,MAAM,YAAY,QAAO,YAC5B,YAAY,GACf,CACF,CACF,CAEJ,IAEA,6BAAAF,QAAA,2BAAAA,QAAA,cAAE,CAEN;AAEJ;",
|
|
6
6
|
"names": ["useOutdatedBrowserCheck", "React", "Paragraph", "Link"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/app/PhaseBannerHeader/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport HeaderContent from '@digigov/react-core/HeaderContent';\nimport PhaseBanner from '@digigov/react-core/PhaseBanner';\nimport PhaseBannerHeaderContainer from '@digigov/react-core/PhaseBannerHeaderContainer';\nimport PhaseBannerTag from '@digigov/react-core/PhaseBannerTag';\nimport PhaseBannerText from '@digigov/react-core/PhaseBannerText';\n\ntype DivElementAttributes = JSX.IntrinsicElements['div'];\nexport interface PhaseBannerHeaderProps extends DivElementAttributes {\n tag?: string;\n text?: string;\n}\n\nexport const PhaseBannerHeader = React.forwardRef<\n HTMLDivElement,\n PhaseBannerHeaderProps\n>(function PhaseBannerHeader({ text, tag, ...props }, ref) {\n return (\n <PhaseBannerHeaderContainer {...props} ref={ref}>\n <HeaderContent>\n <PhaseBanner>\n <PhaseBannerTag>{tag}</PhaseBannerTag>\n <PhaseBannerText>{text}</PhaseBannerText>\n </PhaseBanner>\n </HeaderContent>\n </PhaseBannerHeaderContainer>\n );\n});\n\nexport default PhaseBannerHeader;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import React, { type JSX } from 'react';\nimport HeaderContent from '@digigov/react-core/HeaderContent';\nimport PhaseBanner from '@digigov/react-core/PhaseBanner';\nimport PhaseBannerHeaderContainer from '@digigov/react-core/PhaseBannerHeaderContainer';\nimport PhaseBannerTag from '@digigov/react-core/PhaseBannerTag';\nimport PhaseBannerText from '@digigov/react-core/PhaseBannerText';\n\ntype DivElementAttributes = JSX.IntrinsicElements['div'];\nexport interface PhaseBannerHeaderProps extends DivElementAttributes {\n tag?: string;\n text?: string;\n}\n\nexport const PhaseBannerHeader = React.forwardRef<\n HTMLDivElement,\n PhaseBannerHeaderProps\n>(function PhaseBannerHeader({ text, tag, ...props }, ref) {\n return (\n <PhaseBannerHeaderContainer {...props} ref={ref}>\n <HeaderContent>\n <PhaseBanner>\n <PhaseBannerTag>{tag}</PhaseBannerTag>\n <PhaseBannerText>{text}</PhaseBannerText>\n </PhaseBanner>\n </HeaderContent>\n </PhaseBannerHeaderContainer>\n );\n});\n\nexport default PhaseBannerHeader;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgC;AAChC,2BAA0B;AAC1B,yBAAwB;AACxB,wCAAuC;AACvC,4BAA2B;AAC3B,6BAA4B;AAQrB,MAAM,oBAAoB,aAAAA,QAAM,WAGrC,SAASC,mBAAkB,EAAE,MAAM,KAAK,GAAG,MAAM,GAAG,KAAK;AACzD,SACE,6BAAAD,QAAA,cAAC,kCAAAE,SAAA,EAA4B,GAAG,OAAO,OACrC,6BAAAF,QAAA,cAAC,qBAAAG,SAAA,MACC,6BAAAH,QAAA,cAAC,mBAAAI,SAAA,MACC,6BAAAJ,QAAA,cAAC,sBAAAK,SAAA,MAAgB,GAAI,GACrB,6BAAAL,QAAA,cAAC,uBAAAM,SAAA,MAAiB,IAAK,CACzB,CACF,CACF;AAEJ,CAAC;AAED,IAAO,4BAAQ;",
|
|
6
6
|
"names": ["React", "PhaseBannerHeader", "PhaseBannerHeaderContainer", "HeaderContent", "PhaseBanner", "PhaseBannerTag", "PhaseBannerText"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var useNotificationArea_exports = {};
|
|
19
|
+
__export(useNotificationArea_exports, {
|
|
20
|
+
useNotificationArea: () => useNotificationArea
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(useNotificationArea_exports);
|
|
23
|
+
var import_react = require("react");
|
|
24
|
+
const notificationAreaId = "loader-notification-area";
|
|
25
|
+
const activeSpinnersAttr = "data-active-spinners";
|
|
26
|
+
function generateUniqueId() {
|
|
27
|
+
return `spinner-${Math.random().toString(36).substring(2, 9)}`;
|
|
28
|
+
}
|
|
29
|
+
const getOrCreateNotificationArea = () => {
|
|
30
|
+
let element = document.getElementById(notificationAreaId);
|
|
31
|
+
if (!element) {
|
|
32
|
+
element = document.createElement("div");
|
|
33
|
+
element.id = notificationAreaId;
|
|
34
|
+
element.setAttribute("role", "status");
|
|
35
|
+
element.setAttribute("aria-live", "polite");
|
|
36
|
+
element.className = "ds-visually-hidden";
|
|
37
|
+
document.body.appendChild(element);
|
|
38
|
+
}
|
|
39
|
+
return element;
|
|
40
|
+
};
|
|
41
|
+
const useNotificationArea = (loadingText = "\u0393\u03AF\u03BD\u03B5\u03C4\u03B1\u03B9 \u03C6\u03CC\u03C1\u03C4\u03C9\u03C3\u03B7...", finishedText = "\u0397 \u03C6\u03CC\u03C1\u03C4\u03C9\u03C3\u03B7 \u03BF\u03BB\u03BF\u03BA\u03BB\u03B7\u03C1\u03CE\u03B8\u03B7\u03BA\u03B5.") => {
|
|
42
|
+
const spinnerId = (0, import_react.useRef)(generateUniqueId());
|
|
43
|
+
const notificationRef = (0, import_react.useRef)(null);
|
|
44
|
+
const getActiveIds = (0, import_react.useCallback)(() => {
|
|
45
|
+
const current = notificationRef.current;
|
|
46
|
+
const value = current?.getAttribute(activeSpinnersAttr) || "";
|
|
47
|
+
return value.split(",").filter(Boolean);
|
|
48
|
+
}, [notificationRef]);
|
|
49
|
+
const setActiveSpinnerId = (0, import_react.useCallback)(() => {
|
|
50
|
+
const current = notificationRef.current;
|
|
51
|
+
if (current) {
|
|
52
|
+
const ids = new Set(getActiveIds());
|
|
53
|
+
ids.add(spinnerId.current);
|
|
54
|
+
current.setAttribute(activeSpinnersAttr, Array.from(ids).join(","));
|
|
55
|
+
}
|
|
56
|
+
}, [notificationRef, getActiveIds, spinnerId]);
|
|
57
|
+
const unsetActiveSpinnerId = (0, import_react.useCallback)(() => {
|
|
58
|
+
const current = notificationRef.current;
|
|
59
|
+
if (current) {
|
|
60
|
+
const ids = getActiveIds().filter((id) => id !== spinnerId.current);
|
|
61
|
+
current.setAttribute(activeSpinnersAttr, ids.join(","));
|
|
62
|
+
}
|
|
63
|
+
}, [notificationRef, getActiveIds, spinnerId]);
|
|
64
|
+
const setTextContent = (text) => {
|
|
65
|
+
if (notificationRef.current) {
|
|
66
|
+
notificationRef.current.textContent = text;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
(0, import_react.useEffect)(() => {
|
|
70
|
+
if (typeof document === "undefined") return;
|
|
71
|
+
notificationRef.current = getOrCreateNotificationArea();
|
|
72
|
+
setActiveSpinnerId();
|
|
73
|
+
setTextContent(loadingText);
|
|
74
|
+
return () => {
|
|
75
|
+
unsetActiveSpinnerId();
|
|
76
|
+
if (getActiveIds().length === 0) {
|
|
77
|
+
setTextContent(finishedText);
|
|
78
|
+
setTimeout(() => {
|
|
79
|
+
const el = notificationRef.current;
|
|
80
|
+
if (el && getActiveIds().length === 0) {
|
|
81
|
+
el.removeAttribute(activeSpinnersAttr);
|
|
82
|
+
el.textContent = "";
|
|
83
|
+
}
|
|
84
|
+
}, 1e3);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}, [
|
|
88
|
+
loadingText,
|
|
89
|
+
finishedText,
|
|
90
|
+
setActiveSpinnerId,
|
|
91
|
+
unsetActiveSpinnerId,
|
|
92
|
+
getActiveIds
|
|
93
|
+
]);
|
|
94
|
+
};
|
|
95
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
96
|
+
0 && (module.exports = {
|
|
97
|
+
useNotificationArea
|
|
98
|
+
});
|
|
99
|
+
//# sourceMappingURL=useNotificationArea.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/app/hooks/useNotificationArea.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useRef } from 'react';\n\n// Unique ID for the aria-live notification area element.\nconst notificationAreaId = 'loader-notification-area';\n// Custom attribute to track active spinners\nconst activeSpinnersAttr = 'data-active-spinners';\n\n// Generates a random unique ID for each spinner instance.\nfunction generateUniqueId() {\n return `spinner-${Math.random().toString(36).substring(2, 9)}`;\n}\n\n// Finds or creates the notification area element in the DOM.\nconst getOrCreateNotificationArea = (): HTMLElement => {\n let element = document.getElementById(notificationAreaId);\n\n // Create and append it to the DOM.\n if (!element) {\n element = document.createElement('div');\n element.id = notificationAreaId;\n element.setAttribute('role', 'status');\n element.setAttribute('aria-live', 'polite');\n element.className = 'ds-visually-hidden';\n document.body.appendChild(element);\n }\n\n return element;\n};\n\nexport const useNotificationArea = (\n loadingText = '\u0393\u03AF\u03BD\u03B5\u03C4\u03B1\u03B9 \u03C6\u03CC\u03C1\u03C4\u03C9\u03C3\u03B7...',\n finishedText = '\u0397 \u03C6\u03CC\u03C1\u03C4\u03C9\u03C3\u03B7 \u03BF\u03BB\u03BF\u03BA\u03BB\u03B7\u03C1\u03CE\u03B8\u03B7\u03BA\u03B5.'\n) => {\n // Unique ID for this spinner.\n const spinnerId = useRef(generateUniqueId());\n // Reference to the notification area DOM element.\n const notificationRef = useRef<HTMLElement | null>(null);\n\n // Returns an array of active spinner IDs.\n const getActiveIds = useCallback(() => {\n const current = notificationRef.current;\n const value = current?.getAttribute(activeSpinnersAttr) || '';\n return value.split(',').filter(Boolean);\n }, [notificationRef]);\n\n // Adds this spinner's ID to the active list.\n const setActiveSpinnerId = useCallback(() => {\n const current = notificationRef.current;\n if (current) {\n const ids = new Set(getActiveIds());\n ids.add(spinnerId.current);\n current.setAttribute(activeSpinnersAttr, Array.from(ids).join(','));\n }\n }, [notificationRef, getActiveIds, spinnerId]);\n\n // Removes this spinner's ID from the active list.\n const unsetActiveSpinnerId = useCallback(() => {\n const current = notificationRef.current;\n if (current) {\n const ids = getActiveIds().filter((id) => id !== spinnerId.current);\n current.setAttribute(activeSpinnersAttr, ids.join(','));\n }\n }, [notificationRef, getActiveIds, spinnerId]);\n\n // Updates the text content of the aria-live region.\n const setTextContent = (text: string) => {\n if (notificationRef.current) {\n notificationRef.current.textContent = text;\n }\n };\n\n useEffect(() => {\n if (typeof document === 'undefined') return;\n\n // Set up notification area and mark this spinner as active.\n notificationRef.current = getOrCreateNotificationArea();\n setActiveSpinnerId();\n setTextContent(loadingText);\n\n // Cleanup when component unmounts.\n return () => {\n unsetActiveSpinnerId();\n\n // If no active spinners remain, announce \"finished\" and clear the text.\n if (getActiveIds().length === 0) {\n setTextContent(finishedText);\n\n // Give screen readers a chance to announce \"finished\" before clearing.\n setTimeout(() => {\n const el = notificationRef.current;\n if (el && getActiveIds().length === 0) {\n el.removeAttribute(activeSpinnersAttr);\n el.textContent = '';\n }\n }, 1000);\n }\n };\n }, [\n loadingText,\n finishedText,\n setActiveSpinnerId,\n unsetActiveSpinnerId,\n getActiveIds,\n ]);\n};\n"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AE,OAAO,CAAC,OAAO,OAAO,UAAU,OAAO;AAClE,cAAQ,aAAa,oBAAoB,IAAI,KAAK,GAAG,CAAC;AAAA,IACxD;AAAA,EACF,GAAG,CAAC,iBAAiB,cAAc,SAAS,CAAC;AAG7C,QAAM,iBAAiB,CAAC,SAAiB;AACvC,QAAI,gBAAgB,SAAS;AAC3B,sBAAgB,QAAQ,cAAc;AAAA,IACxC;AAAA,EACF;AAEA,8BAAU,MAAM;AACd,QAAI,OAAO,aAAa,YAAa;AAGrC,oBAAgB,UAAU,4BAA4B;AACtD,uBAAmB;AACnB,mBAAe,WAAW;AAG1B,WAAO,MAAM;AACX,2BAAqB;AAGrB,UAAI,aAAa,EAAE,WAAW,GAAG;AAC/B,uBAAe,YAAY;AAG3B,mBAAW,MAAM;AACf,gBAAM,KAAK,gBAAgB;AAC3B,cAAI,MAAM,aAAa,EAAE,WAAW,GAAG;AACrC,eAAG,gBAAgB,kBAAkB;AACrC,eAAG,cAAc;AAAA,UACnB;AAAA,QACF,GAAG,GAAI;AAAA,MACT;AAAA,IACF;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/content/Accordion/hooks.ts"],
|
|
4
|
-
"sourcesContent": ["import React, { useCallback, useEffect, useRef, useState } from 'react';\n\nexport type AccordionItemId = string | number;\n\nexport interface UseAccordionProps {\n defaultOpen?: AccordionItemId;\n singleOpen?: boolean;\n}\nexport interface UseAccordionSectionProps {\n ref: React.RefObject<HTMLDetailsElement>;\n open: boolean;\n onToggle: (\n e: React.MouseEvent | React.SyntheticEvent<HTMLElement, Event> | Event\n ) => void;\n onKeyDown: (e: React.KeyboardEvent) => void;\n role: string;\n // tabIndex: number;\n 'aria-expanded': boolean | undefined;\n}\n\nexport interface UseAccordionReturn {\n section: (id: AccordionItemId) => UseAccordionSectionProps;\n open: (id: AccordionItemId) => void;\n close: (id: AccordionItemId) => void;\n openAll: () => void;\n closeAll: () => void;\n onOpen: (id: AccordionItemId) => void;\n hasOpen: boolean;\n currentOpen?: AccordionItemId | AccordionItemId[] | null;\n}\n\nexport const useAccordion = ({\n defaultOpen,\n singleOpen = false,\n}: UseAccordionProps = {}): UseAccordionReturn => {\n const sectionsRef = useRef<\n Map<AccordionItemId, React.RefObject<HTMLDetailsElement>>\n >(new Map());\n const [current, setCurrentOpen] = useState(\n defaultOpen ? { [defaultOpen]: true } : {}\n );\n const getCurrentOpen = (): AccordionItemId | AccordionItemId[] | null => {\n const openSections: AccordionItemId[] = [];\n sectionsRef.current.forEach((ref, id) => {\n if (ref.current?.open) {\n openSections.push(id);\n }\n });\n\n if (singleOpen) {\n return openSections[0] || null;\n }\n return openSections.length ? openSections : null;\n };\n\n const open = (id: AccordionItemId) => {\n sectionsRef?.current?.get(id)?.current?.setAttribute('open', '');\n };\n\n const close = (id: AccordionItemId) => {\n sectionsRef.current.get(id)?.current?.removeAttribute('open');\n };\n\n const openAll = () => {\n if (singleOpen) {\n throw new Error('Cannot open all sections when singleOpen is true');\n }\n sectionsRef.current.forEach((ref) => ref.current?.setAttribute('open', ''));\n };\n\n const closeAll = () => {\n sectionsRef.current.forEach((ref) => ref.current?.removeAttribute('open'));\n };\n\n const navigateTo = useCallback(\n (direction: 'next' | 'previous') => {\n const activeElement = document.activeElement;\n if (!activeElement) return;\n const focusableElements = Array.from(\n document.querySelectorAll('summary')\n );\n const currentIndex = focusableElements.indexOf(\n activeElement as HTMLElement\n );\n let nextIndex;\n if (direction === 'next') {\n nextIndex =\n currentIndex >= 0 ? currentIndex + 1 : focusableElements.length - 1;\n } else if (direction === 'previous') {\n nextIndex =\n currentIndex <= focusableElements.length - 1 ? currentIndex - 1 : 0;\n }\n const nextElement = focusableElements[nextIndex];\n if (nextElement) {\n nextElement.focus();\n }\n },\n [current]\n );\n\n const section = useCallback(\n (id: AccordionItemId) => {\n if (!sectionsRef.current.has(id)) {\n sectionsRef.current.set(id, React.createRef());\n }\n const ref = sectionsRef.current.get(\n id\n ) as React.RefObject<HTMLDetailsElement>;\n\n const onToggle = (e) => {\n if (singleOpen && e.target?.open) {\n sectionsRef.current.forEach((sectionRef, sectionId) => {\n if (sectionId === id) {\n setCurrentOpen({ ...current, [id]: e.target?.open });\n }\n if (sectionId !== id && sectionRef.current?.hasAttribute('open')) {\n sectionRef.current?.removeAttribute('open');\n }\n });\n } else {\n setCurrentOpen({ ...current, [id]: e.target?.open });\n }\n };\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault(); // Prevent scrolling if needed\n navigateTo('next');\n break;\n case 'ArrowUp':\n e.preventDefault(); // Prevent scrolling if needed\n navigateTo('previous');\n break;\n case 'Enter':\n e.preventDefault(); // Prevent form submission if needed\n if (ref?.current?.hasAttribute('open')) {\n close(id);\n } else {\n open(id);\n }\n break;\n }\n };\n\n return {\n ref,\n open: ref?.current?.hasAttribute('open') || false,\n onToggle,\n onKeyDown,\n role: 'button',\n 'aria-expanded': ref?.current?.hasAttribute('open'),\n };\n },\n [current]\n );\n const hasOpen = useCallback(() => {\n return getCurrentOpen() !== null;\n }, []);\n useEffect(() => {\n if (defaultOpen) {\n if (Array.isArray(defaultOpen)) {\n defaultOpen.forEach((id) => open(id));\n } else {\n open(defaultOpen);\n }\n }\n }, [defaultOpen]);\n return {\n section,\n open,\n close,\n hasOpen: hasOpen(),\n openAll,\n closeAll,\n onOpen: open,\n currentOpen: Object.keys(current).length ? getCurrentOpen() : null,\n };\n};\n\nexport default useAccordion;\n"],
|
|
4
|
+
"sourcesContent": ["import React, { useCallback, useEffect, useRef, useState } from 'react';\n\nexport type AccordionItemId = string | number;\n\nexport interface UseAccordionProps {\n defaultOpen?: AccordionItemId;\n singleOpen?: boolean;\n}\nexport interface UseAccordionSectionProps {\n ref: React.RefObject<HTMLDetailsElement>;\n open: boolean;\n onToggle: (\n e: React.MouseEvent | React.SyntheticEvent<HTMLElement, Event> | Event\n ) => void;\n onKeyDown: (e: React.KeyboardEvent) => void;\n role: string;\n // tabIndex: number;\n 'aria-expanded': boolean | undefined;\n}\n\nexport interface UseAccordionReturn {\n section: (id: AccordionItemId) => UseAccordionSectionProps;\n open: (id: AccordionItemId) => void;\n close: (id: AccordionItemId) => void;\n openAll: () => void;\n closeAll: () => void;\n onOpen: (id: AccordionItemId) => void;\n hasOpen: boolean;\n currentOpen?: AccordionItemId | AccordionItemId[] | null;\n}\n\nexport const useAccordion = ({\n defaultOpen,\n singleOpen = false,\n}: UseAccordionProps = {}): UseAccordionReturn => {\n const sectionsRef = useRef<\n Map<AccordionItemId, React.RefObject<HTMLDetailsElement | null>>\n >(new Map());\n const [current, setCurrentOpen] = useState(\n defaultOpen ? { [defaultOpen]: true } : {}\n );\n const getCurrentOpen = (): AccordionItemId | AccordionItemId[] | null => {\n const openSections: AccordionItemId[] = [];\n sectionsRef.current.forEach((ref, id) => {\n if (ref.current?.open) {\n openSections.push(id);\n }\n });\n\n if (singleOpen) {\n return openSections[0] || null;\n }\n return openSections.length ? openSections : null;\n };\n\n const open = (id: AccordionItemId) => {\n sectionsRef?.current?.get(id)?.current?.setAttribute('open', '');\n };\n\n const close = (id: AccordionItemId) => {\n sectionsRef.current.get(id)?.current?.removeAttribute('open');\n };\n\n const openAll = () => {\n if (singleOpen) {\n throw new Error('Cannot open all sections when singleOpen is true');\n }\n sectionsRef.current.forEach((ref) => ref.current?.setAttribute('open', ''));\n };\n\n const closeAll = () => {\n sectionsRef.current.forEach((ref) => ref.current?.removeAttribute('open'));\n };\n\n const navigateTo = useCallback(\n (direction: 'next' | 'previous') => {\n const activeElement = document.activeElement;\n if (!activeElement) return;\n const focusableElements = Array.from(\n document.querySelectorAll('summary')\n );\n const currentIndex = focusableElements.indexOf(\n activeElement as HTMLElement\n );\n let nextIndex;\n if (direction === 'next') {\n nextIndex =\n currentIndex >= 0 ? currentIndex + 1 : focusableElements.length - 1;\n } else if (direction === 'previous') {\n nextIndex =\n currentIndex <= focusableElements.length - 1 ? currentIndex - 1 : 0;\n }\n const nextElement = focusableElements[nextIndex];\n if (nextElement) {\n nextElement.focus();\n }\n },\n [current]\n );\n\n const section = useCallback(\n (id: AccordionItemId) => {\n if (!sectionsRef.current.has(id)) {\n sectionsRef.current.set(id, React.createRef());\n }\n const ref = sectionsRef.current.get(\n id\n ) as React.RefObject<HTMLDetailsElement>;\n\n const onToggle = (e) => {\n if (singleOpen && e.target?.open) {\n sectionsRef.current.forEach((sectionRef, sectionId) => {\n if (sectionId === id) {\n setCurrentOpen({ ...current, [id]: e.target?.open });\n }\n if (sectionId !== id && sectionRef.current?.hasAttribute('open')) {\n sectionRef.current?.removeAttribute('open');\n }\n });\n } else {\n setCurrentOpen({ ...current, [id]: e.target?.open });\n }\n };\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault(); // Prevent scrolling if needed\n navigateTo('next');\n break;\n case 'ArrowUp':\n e.preventDefault(); // Prevent scrolling if needed\n navigateTo('previous');\n break;\n case 'Enter':\n e.preventDefault(); // Prevent form submission if needed\n if (ref?.current?.hasAttribute('open')) {\n close(id);\n } else {\n open(id);\n }\n break;\n }\n };\n\n return {\n ref,\n open: ref?.current?.hasAttribute('open') || false,\n onToggle,\n onKeyDown,\n role: 'button',\n 'aria-expanded': ref?.current?.hasAttribute('open'),\n };\n },\n [current]\n );\n const hasOpen = useCallback(() => {\n return getCurrentOpen() !== null;\n }, []);\n useEffect(() => {\n if (defaultOpen) {\n if (Array.isArray(defaultOpen)) {\n defaultOpen.forEach((id) => open(id));\n } else {\n open(defaultOpen);\n }\n }\n }, [defaultOpen]);\n return {\n section,\n open,\n close,\n hasOpen: hasOpen(),\n openAll,\n closeAll,\n onOpen: open,\n currentOpen: Object.keys(current).length ? getCurrentOpen() : null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AAAA,UACF,KAAK;AACH,cAAE,eAAe;AACjB,uBAAW,UAAU;AACrB;AAAA,UACF,KAAK;AACH,cAAE,eAAe;AACjB,gBAAI,KAAK,SAAS,aAAa,MAAM,GAAG;AACtC,oBAAM,EAAE;AAAA,YACV,OAAO;AACL,mBAAK,EAAE;AAAA,YACT;AACA;AAAA,QACJ;AAAA,MACF;AAEA,aAAO;AAAA,QACL;AAAA,QACA,MAAM,KAAK,SAAS,aAAa,MAAM,KAAK;AAAA,QAC5C;AAAA,QACA;AAAA,QACA,MAAM;AAAA,QACN,iBAAiB,KAAK,SAAS,aAAa,MAAM;AAAA,MACpD;AAAA,IACF;AAAA,IACA,CAAC,OAAO;AAAA,EACV;AACA,QAAM,cAAU,0BAAY,MAAM;AAChC,WAAO,eAAe,MAAM;AAAA,EAC9B,GAAG,CAAC,CAAC;AACL,8BAAU,MAAM;AACd,QAAI,aAAa;AACf,UAAI,MAAM,QAAQ,WAAW,GAAG;AAC9B,oBAAY,QAAQ,CAAC,OAAO,KAAK,EAAE,CAAC;AAAA,MACtC,OAAO;AACL,aAAK,WAAW;AAAA,MAClB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,WAAW,CAAC;AAChB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS,QAAQ;AAAA,IACjB;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,aAAa,OAAO,KAAK,OAAO,EAAE,SAAS,eAAe,IAAI;AAAA,EAChE;AACF;AAEA,IAAO,gBAAQ;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/form/AutoComplete/Status/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { Component } from 'react';\nimport AutoCompleteStatus from '@digigov/react-core/AutoCompleteStatus';\nimport AutoCompleteStatusContainer from '@digigov/react-core/AutoCompleteStatusContainer';\n\nconst debounce = function (\n func: () => void,\n wait: number,\n immediate?: boolean\n) {\n let timeout;\n return function (...args) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const context = this;\n const later = function () {\n timeout = null;\n if (!immediate) func.apply(context, args);\n };\n const callNow = immediate && !timeout;\n clearTimeout(timeout);\n timeout = setTimeout(later, wait);\n if (callNow) func.apply(context, args);\n return timeout;\n };\n};\nconst statusDebounceMillis = 1400;\n\ninterface StatusProps {\n id: string;\n length: number;\n queryLength: number;\n minQueryLength?: number;\n selectedOption: string;\n selectedOptionIndex: number;\n validChoiceMade: boolean;\n isInFocus: boolean;\n tQueryTooShort?: (x: number) => string;\n tNoResults?: () => string;\n tSelectedOption: (x: string, y: number, z: number) => string;\n tResults?: (x: number, y: string) => string;\n}\n\ninterface StateProps {\n bump: boolean;\n debounced: boolean;\n silenced: boolean;\n}\n\nexport default class Status extends Component<StatusProps, StateProps> {\n static defaultProps = {\n tQueryTooShort: (minQueryLength: number): string =>\n `Type in ${minQueryLength} or more characters for results`,\n tNoResults: (): string => 'No search results',\n tSelectedOption: (\n selectedOption: string,\n length: number,\n index: number\n ): string => `${selectedOption} ${index + 1} of ${length} is highlighted`,\n tResults: (length: number, contentSelectedOption: string): string => {\n const words = {\n result: length === 1 ? 'result' : 'results',\n is: length === 1 ? 'is' : 'are',\n };\n\n return `${length} ${words.result} ${words.is} available. ${contentSelectedOption}`;\n },\n };\n\n state = {\n bump: false,\n debounced: false,\n silenced: false,\n };\n debounceStatusUpdate: () => void;\n lastDebounceCall: any;\n componentWillUnmount(): void {\n clearTimeout(this.lastDebounceCall);\n }\n UNSAFE_componentWillMount() {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const that = this;\n this.debounceStatusUpdate = debounce(function () {\n if (!that.state.debounced) {\n const shouldSilence =\n !that.props.isInFocus || that.props.validChoiceMade;\n that.setState(({ bump }) => ({\n bump: !bump,\n debounced: true,\n silenced: shouldSilence,\n }));\n }\n }, statusDebounceMillis);\n }\n\n UNSAFE_componentWillReceiveProps() {\n this.setState({ debounced: false });\n }\n\n render(): JSX.Element {\n const {\n id,\n length,\n queryLength,\n minQueryLength,\n selectedOption,\n selectedOptionIndex,\n tQueryTooShort,\n tNoResults,\n tSelectedOption,\n tResults,\n } = this.props;\n const { bump, debounced, silenced } = this.state;\n\n const queryTooShort = queryLength < (minQueryLength as number);\n const noResults = length === 0;\n\n const contentSelectedOption = selectedOption\n ? tSelectedOption(selectedOption, length, selectedOptionIndex)\n : '';\n\n let content;\n if (queryTooShort) {\n content = tQueryTooShort?.(minQueryLength as number);\n } else if (noResults) {\n content = tNoResults?.();\n } else {\n content = tResults?.(length, contentSelectedOption);\n }\n\n this.lastDebounceCall = this.debounceStatusUpdate();\n\n return (\n <AutoCompleteStatusContainer>\n <AutoCompleteStatus id={id + '__status--A'}>\n {!silenced && debounced && bump ? content : ' '}\n </AutoCompleteStatus>\n <AutoCompleteStatus id={id + '__status--B'}>\n {!silenced && debounced && !bump ? content : ' '}\n </AutoCompleteStatus>\n </AutoCompleteStatusContainer>\n );\n }\n}\n\nexport { AutoCompleteStatusContainer, AutoCompleteStatus };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,sDAAAA;AAAA,EAAA,sEAAAC;AAAA,EAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import React, { Component, type JSX } from 'react';\nimport AutoCompleteStatus from '@digigov/react-core/AutoCompleteStatus';\nimport AutoCompleteStatusContainer from '@digigov/react-core/AutoCompleteStatusContainer';\n\nconst debounce = function (\n func: () => void,\n wait: number,\n immediate?: boolean\n) {\n let timeout;\n return function (...args) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const context = this;\n const later = function () {\n timeout = null;\n if (!immediate) func.apply(context, args);\n };\n const callNow = immediate && !timeout;\n clearTimeout(timeout);\n timeout = setTimeout(later, wait);\n if (callNow) func.apply(context, args);\n return timeout;\n };\n};\nconst statusDebounceMillis = 1400;\n\ninterface StatusProps {\n id: string;\n length: number;\n queryLength: number;\n minQueryLength?: number;\n selectedOption: string;\n selectedOptionIndex: number;\n validChoiceMade: boolean;\n isInFocus: boolean;\n tQueryTooShort?: (x: number) => string;\n tNoResults?: () => string;\n tSelectedOption: (x: string, y: number, z: number) => string;\n tResults?: (x: number, y: string) => string;\n}\n\ninterface StateProps {\n bump: boolean;\n debounced: boolean;\n silenced: boolean;\n}\n\nexport default class Status extends Component<StatusProps, StateProps> {\n static defaultProps = {\n tQueryTooShort: (minQueryLength: number): string =>\n `Type in ${minQueryLength} or more characters for results`,\n tNoResults: (): string => 'No search results',\n tSelectedOption: (\n selectedOption: string,\n length: number,\n index: number\n ): string => `${selectedOption} ${index + 1} of ${length} is highlighted`,\n tResults: (length: number, contentSelectedOption: string): string => {\n const words = {\n result: length === 1 ? 'result' : 'results',\n is: length === 1 ? 'is' : 'are',\n };\n\n return `${length} ${words.result} ${words.is} available. ${contentSelectedOption}`;\n },\n };\n\n state = {\n bump: false,\n debounced: false,\n silenced: false,\n };\n debounceStatusUpdate: () => void;\n lastDebounceCall: any;\n componentWillUnmount(): void {\n clearTimeout(this.lastDebounceCall);\n }\n UNSAFE_componentWillMount() {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const that = this;\n this.debounceStatusUpdate = debounce(function () {\n if (!that.state.debounced) {\n const shouldSilence =\n !that.props.isInFocus || that.props.validChoiceMade;\n that.setState(({ bump }) => ({\n bump: !bump,\n debounced: true,\n silenced: shouldSilence,\n }));\n }\n }, statusDebounceMillis);\n }\n\n UNSAFE_componentWillReceiveProps() {\n this.setState({ debounced: false });\n }\n\n render(): JSX.Element {\n const {\n id,\n length,\n queryLength,\n minQueryLength,\n selectedOption,\n selectedOptionIndex,\n tQueryTooShort,\n tNoResults,\n tSelectedOption,\n tResults,\n } = this.props;\n const { bump, debounced, silenced } = this.state;\n\n const queryTooShort = queryLength < (minQueryLength as number);\n const noResults = length === 0;\n\n const contentSelectedOption = selectedOption\n ? tSelectedOption(selectedOption, length, selectedOptionIndex)\n : '';\n\n let content;\n if (queryTooShort) {\n content = tQueryTooShort?.(minQueryLength as number);\n } else if (noResults) {\n content = tNoResults?.();\n } else {\n content = tResults?.(length, contentSelectedOption);\n }\n\n this.lastDebounceCall = this.debounceStatusUpdate();\n\n return (\n <AutoCompleteStatusContainer>\n <AutoCompleteStatus id={id + '__status--A'}>\n {!silenced && debounced && bump ? content : ' '}\n </AutoCompleteStatus>\n <AutoCompleteStatus id={id + '__status--B'}>\n {!silenced && debounced && !bump ? content : ' '}\n </AutoCompleteStatus>\n </AutoCompleteStatusContainer>\n );\n }\n}\n\nexport { AutoCompleteStatusContainer, AutoCompleteStatus };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,sDAAAA;AAAA,EAAA,sEAAAC;AAAA,EAAA;AAAA;AAAA;AAAA,mBAA2C;AAC3C,gCAA+B;AAC/B,yCAAwC;AAExC,MAAM,WAAW,SACf,MACA,MACA,WACA;AACA,MAAI;AACJ,SAAO,YAAa,MAAM;AAIxB,UAAM,UAAU;AAChB,UAAM,QAAQ,WAAY;AACxB,gBAAU;AACV,UAAI,CAAC,UAAW,MAAK,MAAM,SAAS,IAAI;AAAA,IAC1C;AACA,UAAM,UAAU,aAAa,CAAC;AAC9B,iBAAa,OAAO;AACpB,cAAU,WAAW,OAAO,IAAI;AAChC,QAAI,QAAS,MAAK,MAAM,SAAS,IAAI;AACrC,WAAO;AAAA,EACT;AACF;AACA,MAAM,uBAAuB;AAuB7B,MAAO,eAA6B,uBAAmC;AAAA,EAAvE;AAAA;AAoBE,iBAAQ;AAAA,MACN,MAAM;AAAA,MACN,WAAW;AAAA,MACX,UAAU;AAAA,IACZ;AAAA;AAAA,EAvBA;AAAA,SAAO,eAAe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e;AACjB,gBAAU,iBAAiB,cAAwB;AAAA,IACrD,WAAW,WAAW;AACpB,gBAAU,aAAa;AAAA,IACzB,OAAO;AACL,gBAAU,WAAW,QAAQ,qBAAqB;AAAA,IACpD;AAEA,SAAK,mBAAmB,KAAK,qBAAqB;AAElD,WACE,6BAAAC,QAAA,cAAC,mCAAAD,SAAA,MACC,6BAAAC,QAAA,cAAC,0BAAAF,SAAA,EAAmB,IAAI,KAAK,iBAC1B,CAAC,YAAY,aAAa,OAAO,UAAU,GAC9C,GACA,6BAAAE,QAAA,cAAC,0BAAAF,SAAA,EAAmB,IAAI,KAAK,iBAC1B,CAAC,YAAY,aAAa,CAAC,OAAO,UAAU,GAC/C,CACF;AAAA,EAEJ;AACF;",
|
|
6
6
|
"names": ["AutoCompleteStatus", "AutoCompleteStatusContainer", "React"]
|
|
7
7
|
}
|
|
@@ -31,7 +31,6 @@ __export(AutoComplete_exports, {
|
|
|
31
31
|
AutoCompleteAssistiveHint: () => import_AutoCompleteAssistiveHint.AutoCompleteAssistiveHint,
|
|
32
32
|
AutoCompleteContainer: () => import_AutoCompleteContainer.AutoCompleteContainer,
|
|
33
33
|
AutoCompleteInputBase: () => import_AutoCompleteInputBase.AutoCompleteInputBase,
|
|
34
|
-
AutoCompleteInputTypeahead: () => import_AutoCompleteInputTypeahead.AutoCompleteInputTypeahead,
|
|
35
34
|
AutoCompleteMultipleInput: () => import_AutoCompleteMultipleInput.AutoCompleteMultipleInput,
|
|
36
35
|
AutoCompleteMultipleInputContainer: () => import_AutoCompleteMultipleInputContainer.AutoCompleteMultipleInputContainer,
|
|
37
36
|
AutoCompleteResultList: () => import_AutoCompleteResultList.AutoCompleteResultList,
|
|
@@ -43,7 +42,6 @@ var import_react = __toESM(require("react"));
|
|
|
43
42
|
var import_AutoCompleteAssistiveHint = require("@digigov/react-core/AutoCompleteAssistiveHint");
|
|
44
43
|
var import_AutoCompleteContainer = require("@digigov/react-core/AutoCompleteContainer");
|
|
45
44
|
var import_AutoCompleteInputBase = require("@digigov/react-core/AutoCompleteInputBase");
|
|
46
|
-
var import_AutoCompleteInputTypeahead = require("@digigov/react-core/AutoCompleteInputTypeahead");
|
|
47
45
|
var import_AutoCompleteMultipleInput = require("@digigov/react-core/AutoCompleteMultipleInput");
|
|
48
46
|
var import_AutoCompleteMultipleInputContainer = require("@digigov/react-core/AutoCompleteMultipleInputContainer");
|
|
49
47
|
var import_AutoCompleteResultList = require("@digigov/react-core/AutoCompleteResultList");
|
|
@@ -105,6 +103,7 @@ class AutoComplete extends import_react.Component {
|
|
|
105
103
|
minLength: 0,
|
|
106
104
|
name: "ds-input-autocomplete",
|
|
107
105
|
placeholder: "",
|
|
106
|
+
hint: false,
|
|
108
107
|
onConfirm: () => {
|
|
109
108
|
return;
|
|
110
109
|
},
|
|
@@ -158,12 +157,13 @@ class AutoComplete extends import_react.Component {
|
|
|
158
157
|
}
|
|
159
158
|
handleComponentBlur(newState) {
|
|
160
159
|
const { options, query, selected } = this.state;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
160
|
+
const { confirmOnBlur, autoselect, onConfirm } = this.props;
|
|
161
|
+
let newQuery = query;
|
|
162
|
+
if (confirmOnBlur || autoselect) {
|
|
163
|
+
newQuery = newState?.query ?? query;
|
|
164
|
+
}
|
|
165
|
+
if (confirmOnBlur) {
|
|
166
|
+
onConfirm?.(options[selected]);
|
|
167
167
|
}
|
|
168
168
|
this.setState({
|
|
169
169
|
focused: null,
|
|
@@ -179,6 +179,7 @@ class AutoComplete extends import_react.Component {
|
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
181
|
handleAutoCompleteBlur(event, index) {
|
|
182
|
+
const { autoselect } = this.props;
|
|
182
183
|
const { focused, options, query, selected } = this.state;
|
|
183
184
|
let focusingOutsideComponent = false;
|
|
184
185
|
if (event.relatedTarget === null) {
|
|
@@ -193,17 +194,26 @@ class AutoComplete extends import_react.Component {
|
|
|
193
194
|
focusingAnotherOption = focused !== index && focused !== -1;
|
|
194
195
|
}
|
|
195
196
|
const blurComponent = focusingOutsideComponent && !(focusingAnotherOption || focusingInput || focusingButtonArrow);
|
|
196
|
-
if (blurComponent) {
|
|
197
|
+
if (blurComponent && !autoselect) {
|
|
197
198
|
const newQuery = (0, import_utils.isIosDevice)() ? query : this.templateInputValue(options[selected]);
|
|
198
199
|
this.handleComponentBlur({
|
|
199
200
|
menuOpen: false,
|
|
200
201
|
query: newQuery
|
|
201
202
|
});
|
|
202
203
|
}
|
|
204
|
+
if (blurComponent && autoselect) {
|
|
205
|
+
const selectedOption = this.templateInputValue(
|
|
206
|
+
options[selected]
|
|
207
|
+
);
|
|
208
|
+
const newQuery = (0, import_utils.isIosDevice)() ? query : selectedOption?.toLowerCase().includes(query.toLowerCase()) ? selectedOption : query;
|
|
209
|
+
this.handleComponentBlur({
|
|
210
|
+
menuOpen: false,
|
|
211
|
+
query: newQuery
|
|
212
|
+
});
|
|
213
|
+
}
|
|
203
214
|
}
|
|
204
215
|
handleInputChange(event) {
|
|
205
216
|
const { source, minLength } = this.props;
|
|
206
|
-
const autoselect = this.hasAutoselect();
|
|
207
217
|
const query = event.target.value;
|
|
208
218
|
const queryEmpty = query.length === 0;
|
|
209
219
|
this.setState({
|
|
@@ -216,7 +226,7 @@ class AutoComplete extends import_react.Component {
|
|
|
216
226
|
this.setState({
|
|
217
227
|
menuOpen: optionsAvailable,
|
|
218
228
|
options,
|
|
219
|
-
selected:
|
|
229
|
+
selected: -1,
|
|
220
230
|
validChoiceMade: false
|
|
221
231
|
});
|
|
222
232
|
});
|
|
@@ -257,6 +267,7 @@ class AutoComplete extends import_react.Component {
|
|
|
257
267
|
hovered: index
|
|
258
268
|
});
|
|
259
269
|
}
|
|
270
|
+
this.handleOptionFocus(index);
|
|
260
271
|
}
|
|
261
272
|
handleOptionClickMultiple(index) {
|
|
262
273
|
const selectedOption = this.state.options[index];
|
|
@@ -383,11 +394,13 @@ class AutoComplete extends import_react.Component {
|
|
|
383
394
|
case "enter":
|
|
384
395
|
this.handleEnter(event);
|
|
385
396
|
break;
|
|
386
|
-
case "escape":
|
|
397
|
+
case "escape": {
|
|
387
398
|
this.handleComponentBlur({
|
|
388
|
-
query: this.state.query
|
|
399
|
+
query: this.state.query,
|
|
400
|
+
menuOpen: false
|
|
389
401
|
});
|
|
390
402
|
break;
|
|
403
|
+
}
|
|
391
404
|
case "backspace":
|
|
392
405
|
if (this.props.multiple) {
|
|
393
406
|
if (this.state.query.length === 0 && this.state.selectedValues.length > 0) {
|
|
@@ -428,6 +441,7 @@ class AutoComplete extends import_react.Component {
|
|
|
428
441
|
name,
|
|
429
442
|
placeholder,
|
|
430
443
|
required,
|
|
444
|
+
hint,
|
|
431
445
|
tNoResults,
|
|
432
446
|
tStatusQueryTooShort,
|
|
433
447
|
tStatusNoResults,
|
|
@@ -458,7 +472,7 @@ class AutoComplete extends import_react.Component {
|
|
|
458
472
|
const menuIsVisible = menuOpen || showNoOptionsFound;
|
|
459
473
|
const selectedOptionText = this.templateInputValue(options[selected]);
|
|
460
474
|
const optionBeginsWithQuery = selectedOptionText && selectedOptionText.toLowerCase().indexOf(query.toLowerCase()) === 0;
|
|
461
|
-
const hintValue = optionBeginsWithQuery && autoselect ? query + selectedOptionText.substr(query.length) : "";
|
|
475
|
+
const hintValue = optionBeginsWithQuery && (autoselect || hint) ? query + selectedOptionText.substr(query.length) : "";
|
|
462
476
|
const assistiveHintID = id + "__assistiveHint";
|
|
463
477
|
const ariaDescribedProp = ariaHint ? {
|
|
464
478
|
"aria-describedby": assistiveHintID
|
|
@@ -541,7 +555,7 @@ class AutoComplete extends import_react.Component {
|
|
|
541
555
|
tSelectedOption: tStatusSelectedOption,
|
|
542
556
|
tResults: tStatusResults
|
|
543
557
|
}
|
|
544
|
-
),
|
|
558
|
+
), multiple && !autoselect ? /* @__PURE__ */ import_react.default.createElement(
|
|
545
559
|
import_AutoCompleteMultipleInputContainer.AutoCompleteMultipleInputContainer,
|
|
546
560
|
{
|
|
547
561
|
isFocused: componentIsFocused,
|
|
@@ -589,7 +603,7 @@ class AutoComplete extends import_react.Component {
|
|
|
589
603
|
onChange: this.handleInputChange,
|
|
590
604
|
onFocus: this.handleInputFocus,
|
|
591
605
|
name,
|
|
592
|
-
placeholder,
|
|
606
|
+
placeholder: hintValue || placeholder,
|
|
593
607
|
ref: (inputElement) => {
|
|
594
608
|
this.elementReferences[-1] = inputElement;
|
|
595
609
|
},
|
|
@@ -613,7 +627,7 @@ class AutoComplete extends import_react.Component {
|
|
|
613
627
|
this.setState({
|
|
614
628
|
menuOpen: optionsAvailable,
|
|
615
629
|
options: options2,
|
|
616
|
-
selected:
|
|
630
|
+
selected: -1,
|
|
617
631
|
validChoiceMade: false
|
|
618
632
|
});
|
|
619
633
|
});
|
|
@@ -656,7 +670,7 @@ class AutoComplete extends import_react.Component {
|
|
|
656
670
|
onChange: this.handleInputChange,
|
|
657
671
|
onFocus: this.handleInputFocus,
|
|
658
672
|
name,
|
|
659
|
-
placeholder,
|
|
673
|
+
placeholder: hintValue || placeholder,
|
|
660
674
|
ref: (inputElement) => {
|
|
661
675
|
this.elementReferences[-1] = inputElement;
|
|
662
676
|
},
|
|
@@ -683,7 +697,6 @@ class AutoComplete extends import_react.Component {
|
|
|
683
697
|
AutoCompleteAssistiveHint,
|
|
684
698
|
AutoCompleteContainer,
|
|
685
699
|
AutoCompleteInputBase,
|
|
686
|
-
AutoCompleteInputTypeahead,
|
|
687
700
|
AutoCompleteMultipleInput,
|
|
688
701
|
AutoCompleteMultipleInputContainer,
|
|
689
702
|
AutoCompleteResultList,
|