@zanichelli/zanichelli-it-frontend-kit 1.3.1 → 1.4.0-RC2

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.
Files changed (124) hide show
  1. package/dist/types/components/menubar/menubar.d.ts +5 -0
  2. package/dist/types/components/menubar/mobile-menubar/mobile-menubar.d.ts +5 -0
  3. package/dist/types/components/menubar/search-form/search-form.d.ts +28 -5
  4. package/dist/types/components/menubar/search-form/suggestions.d.ts +11 -0
  5. package/dist/types/components.d.ts +60 -4
  6. package/dist/types/utils/subjects.api.d.ts +6 -0
  7. package/dist/types/utils/types.d.ts +7 -0
  8. package/dist/types/utils/utils.d.ts +8 -0
  9. package/dist/zanichelli-it-frontend-kit/index-DPw_TAEB.js +4170 -0
  10. package/dist/zanichelli-it-frontend-kit/index-DPw_TAEB.js.map +1 -0
  11. package/dist/zanichelli-it-frontend-kit/index.esm.js +10 -0
  12. package/dist/zanichelli-it-frontend-kit/index.esm.js.map +1 -1
  13. package/dist/zanichelli-it-frontend-kit/menu-BsP3cOc_.js +46 -0
  14. package/dist/zanichelli-it-frontend-kit/menu-BsP3cOc_.js.map +1 -0
  15. package/dist/zanichelli-it-frontend-kit/subjects.api-BRhngFD0.js +54 -0
  16. package/dist/zanichelli-it-frontend-kit/subjects.api-BRhngFD0.js.map +1 -0
  17. package/dist/zanichelli-it-frontend-kit/zanichelli-it-frontend-kit.css +993 -1
  18. package/dist/zanichelli-it-frontend-kit/zanichelli-it-frontend-kit.esm.js +49 -1
  19. package/dist/zanichelli-it-frontend-kit/zanichelli-it-frontend-kit.esm.js.map +1 -1
  20. package/dist/zanichelli-it-frontend-kit/zanit-back-to-top.entry.esm.js.map +1 -0
  21. package/dist/{components/zanit-back-to-top.js → zanichelli-it-frontend-kit/zanit-back-to-top.entry.js} +10 -34
  22. package/dist/zanichelli-it-frontend-kit/zanit-back-to-top.entry.js.map +1 -0
  23. package/dist/zanichelli-it-frontend-kit/zanit-menubar.entry.esm.js.map +1 -0
  24. package/dist/{components/zanit-menubar.js → zanichelli-it-frontend-kit/zanit-menubar.entry.js} +19 -58
  25. package/dist/zanichelli-it-frontend-kit/zanit-menubar.entry.js.map +1 -0
  26. package/dist/zanichelli-it-frontend-kit/zanit-mobile-menubar.entry.esm.js.map +1 -0
  27. package/dist/{components/p-BJzEFXY7.js → zanichelli-it-frontend-kit/zanit-mobile-menubar.entry.js} +18 -87
  28. package/dist/zanichelli-it-frontend-kit/zanit-mobile-menubar.entry.js.map +1 -0
  29. package/dist/zanichelli-it-frontend-kit/zanit-search-form.entry.esm.js.map +1 -0
  30. package/dist/zanichelli-it-frontend-kit/zanit-search-form.entry.js +307 -0
  31. package/dist/zanichelli-it-frontend-kit/zanit-search-form.entry.js.map +1 -0
  32. package/package.json +1 -1
  33. package/www/build/index-DPw_TAEB.js +4170 -0
  34. package/www/build/index-DPw_TAEB.js.map +1 -0
  35. package/www/build/index.esm.js +10 -0
  36. package/www/build/index.esm.js.map +1 -1
  37. package/www/build/menu-BsP3cOc_.js +46 -0
  38. package/www/build/menu-BsP3cOc_.js.map +1 -0
  39. package/www/build/subjects.api-BRhngFD0.js +54 -0
  40. package/www/build/subjects.api-BRhngFD0.js.map +1 -0
  41. package/www/build/zanichelli-it-frontend-kit.css +993 -1
  42. package/www/build/zanichelli-it-frontend-kit.esm.js +49 -1
  43. package/www/build/zanichelli-it-frontend-kit.esm.js.map +1 -1
  44. package/www/build/zanit-back-to-top.entry.esm.js.map +1 -0
  45. package/www/build/zanit-back-to-top.entry.js +64 -0
  46. package/www/build/zanit-back-to-top.entry.js.map +1 -0
  47. package/www/build/zanit-menubar.entry.esm.js.map +1 -0
  48. package/{dist/collection/components/menubar/menubar.js → www/build/zanit-menubar.entry.js} +31 -159
  49. package/www/build/zanit-menubar.entry.js.map +1 -0
  50. package/www/build/zanit-mobile-menubar.entry.esm.js.map +1 -0
  51. package/www/build/zanit-mobile-menubar.entry.js +171 -0
  52. package/www/build/zanit-mobile-menubar.entry.js.map +1 -0
  53. package/www/build/zanit-search-form.entry.esm.js.map +1 -0
  54. package/www/build/zanit-search-form.entry.js +307 -0
  55. package/www/build/zanit-search-form.entry.js.map +1 -0
  56. package/www/index.html +11 -2
  57. package/dist/cjs/index-BLzQAHAI.js +0 -1578
  58. package/dist/cjs/index-BLzQAHAI.js.map +0 -1
  59. package/dist/cjs/index.cjs.js +0 -5
  60. package/dist/cjs/index.cjs.js.map +0 -1
  61. package/dist/cjs/loader.cjs.js +0 -15
  62. package/dist/cjs/loader.cjs.js.map +0 -1
  63. package/dist/cjs/zanichelli-it-frontend-kit.cjs.js +0 -27
  64. package/dist/cjs/zanichelli-it-frontend-kit.cjs.js.map +0 -1
  65. package/dist/cjs/zanit-back-to-top.zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.cjs.js.map +0 -1
  66. package/dist/cjs/zanit-back-to-top_4.cjs.entry.js +0 -771
  67. package/dist/cjs/zanit-back-to-top_4.cjs.entry.js.map +0 -1
  68. package/dist/collection/collection-manifest.json +0 -15
  69. package/dist/collection/components/back-to-top/back-to-top.css +0 -16
  70. package/dist/collection/components/back-to-top/back-to-top.js +0 -130
  71. package/dist/collection/components/back-to-top/back-to-top.js.map +0 -1
  72. package/dist/collection/components/menubar/menu/menu.css +0 -95
  73. package/dist/collection/components/menubar/menu/menu.js +0 -38
  74. package/dist/collection/components/menubar/menu/menu.js.map +0 -1
  75. package/dist/collection/components/menubar/menubar.css +0 -168
  76. package/dist/collection/components/menubar/menubar.js.map +0 -1
  77. package/dist/collection/components/menubar/mobile-menubar/mobile-menubar.css +0 -121
  78. package/dist/collection/components/menubar/mobile-menubar/mobile-menubar.js +0 -291
  79. package/dist/collection/components/menubar/mobile-menubar/mobile-menubar.js.map +0 -1
  80. package/dist/collection/components/menubar/search-form/search-form.css +0 -155
  81. package/dist/collection/components/menubar/search-form/search-form.js +0 -176
  82. package/dist/collection/components/menubar/search-form/search-form.js.map +0 -1
  83. package/dist/collection/index.js +0 -11
  84. package/dist/collection/index.js.map +0 -1
  85. package/dist/collection/utils/index.js +0 -2
  86. package/dist/collection/utils/index.js.map +0 -1
  87. package/dist/collection/utils/utils.js +0 -17
  88. package/dist/collection/utils/utils.js.map +0 -1
  89. package/dist/components/index.js +0 -1335
  90. package/dist/components/index.js.map +0 -1
  91. package/dist/components/p-BJzEFXY7.js.map +0 -1
  92. package/dist/components/p-Cfa-BVne.js +0 -133
  93. package/dist/components/p-Cfa-BVne.js.map +0 -1
  94. package/dist/components/zanit-back-to-top.js.map +0 -1
  95. package/dist/components/zanit-menubar.js.map +0 -1
  96. package/dist/components/zanit-mobile-menubar.js +0 -9
  97. package/dist/components/zanit-mobile-menubar.js.map +0 -1
  98. package/dist/components/zanit-search-form.js +0 -9
  99. package/dist/components/zanit-search-form.js.map +0 -1
  100. package/dist/esm/index-DSdvvVFj.js +0 -1549
  101. package/dist/esm/index-DSdvvVFj.js.map +0 -1
  102. package/dist/esm/index.js +0 -4
  103. package/dist/esm/index.js.map +0 -1
  104. package/dist/esm/loader.js +0 -13
  105. package/dist/esm/loader.js.map +0 -1
  106. package/dist/esm/zanichelli-it-frontend-kit.js +0 -23
  107. package/dist/esm/zanichelli-it-frontend-kit.js.map +0 -1
  108. package/dist/esm/zanit-back-to-top.zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.js.map +0 -1
  109. package/dist/esm/zanit-back-to-top_4.entry.js +0 -766
  110. package/dist/esm/zanit-back-to-top_4.entry.js.map +0 -1
  111. package/dist/index.cjs.js +0 -1
  112. package/dist/index.js +0 -1
  113. package/dist/zanichelli-it-frontend-kit/p-DSdvvVFj.js +0 -3
  114. package/dist/zanichelli-it-frontend-kit/p-DSdvvVFj.js.map +0 -1
  115. package/dist/zanichelli-it-frontend-kit/p-fe01ee7e.entry.js +0 -2
  116. package/dist/zanichelli-it-frontend-kit/p-fe01ee7e.entry.js.map +0 -1
  117. package/dist/zanichelli-it-frontend-kit/zanit-back-to-top.zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.esm.js.map +0 -1
  118. package/www/build/p-43c395dc.css +0 -1
  119. package/www/build/p-DSdvvVFj.js +0 -3
  120. package/www/build/p-DSdvvVFj.js.map +0 -1
  121. package/www/build/p-b4df0dec.js +0 -2
  122. package/www/build/p-fe01ee7e.entry.js +0 -2
  123. package/www/build/p-fe01ee7e.entry.js.map +0 -1
  124. package/www/build/zanit-back-to-top.zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.esm.js.map +0 -1
@@ -1,2 +1,12 @@
1
+ /**
2
+ * @fileoverview entry point for your component library
3
+ *
4
+ * This is the entry point for your component library. Use this file to export utilities,
5
+ * constants or data structure that accompany your components.
6
+ *
7
+ * DO NOT use this file to export your components. Instead, use the recommended approaches
8
+ * to consume components of this package as outlined in the `README.md`.
9
+ */
10
+ //# sourceMappingURL=index.esm.js.map
1
11
 
2
12
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.esm.js","sources":["src/index.ts"],"sourcesContent":["/**\n * @fileoverview entry point for your component library\n *\n * This is the entry point for your component library. Use this file to export utilities,\n * constants or data structure that accompany your components.\n *\n * DO NOT use this file to export your components. Instead, use the recommended approaches\n * to consume components of this package as outlined in the `README.md`.\n */\n\nexport type * from './components.d.ts';\nexport * from './utils/types';\n"],"names":[],"mappings":"AAAA;;;;;;;;AAQG"}
@@ -0,0 +1,46 @@
1
+ import { h } from './index-DPw_TAEB.js';
2
+
3
+ const DEFAULT_GROUP_KEY = 'default';
4
+ const DEFAULT_GROUP = {
5
+ id: DEFAULT_GROUP_KEY,
6
+ label: DEFAULT_GROUP_KEY,
7
+ };
8
+ /** Get the items grouped by their group. */
9
+ const getGroupedItems = (items) => {
10
+ const groups = items.reduce((grouped, item) => {
11
+ const itemGroup = grouped.find(({ group }) => group.id === (item.group?.id || DEFAULT_GROUP.id));
12
+ if (!itemGroup) {
13
+ grouped.push({ group: item.group ?? DEFAULT_GROUP, items: [item] });
14
+ }
15
+ else {
16
+ itemGroup.items.push(item);
17
+ }
18
+ return grouped;
19
+ }, []);
20
+ // Sort to keep default group at the end
21
+ return groups.sort((a, b) => (a.group.id === DEFAULT_GROUP_KEY ? 1 : b.group.id === DEFAULT_GROUP_KEY ? -1 : 0));
22
+ };
23
+ /**
24
+ * Floating menu component. It shows a list of items that can be grouped.
25
+ */
26
+ const Menu = ({ controlledBy, items, currentPath = [], onItemKeyDown }) => {
27
+ if (!items?.length) {
28
+ return null;
29
+ }
30
+ const groups = getGroupedItems(items);
31
+ const isActive = (item) => currentPath.includes(controlledBy) && currentPath.includes(item.id);
32
+ return (h("div", { class: "menu-wrapper", role: "none" },
33
+ h("div", { class: "menu", "aria-labelledby": controlledBy ?? undefined, role: "menu" }, groups.map(({ group, items }) => (h("div", { class: { group: true, highlight: items.some((item) => item.highlight) } },
34
+ group.id !== DEFAULT_GROUP_KEY ? (h("div", { class: "group-name", id: group.id }, group.label)) : groups.length > 1 ? (
35
+ // empty div to keep the same height as the other groups
36
+ h("div", { class: "group-name" })) : null,
37
+ h("ul", { class: "menu-list", role: "group", "aria-labelledby": group.id !== DEFAULT_GROUP_KEY ? group.id : undefined }, items.map((item) => (h("li", { role: "none" }, item.href && (h("a", { class: {
38
+ 'menu-item': true,
39
+ 'active': isActive(item),
40
+ }, href: item.href, role: "menuitem", tabIndex: -1, "aria-current": isActive(item) ? 'page' : 'false', onKeyDown: (event) => onItemKeyDown(event), target: item.target }, item.label))))))))))));
41
+ };
42
+
43
+ export { Menu as M };
44
+ //# sourceMappingURL=menu-BsP3cOc_.js.map
45
+
46
+ //# sourceMappingURL=menu-BsP3cOc_.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu-BsP3cOc_.js","sources":["src/components/menubar/menu/menu.tsx"],"sourcesContent":["import { FunctionalComponent, h } from '@stencil/core';\nimport { MenuItem } from '../../../utils';\n\n/**\n * Menu of items that can be grouped.\n * @member {string} controlledBy - The HTML id of the element that controls the menu.\n * @member {MenuItem[]} items - The items to show in the menu.\n * @member {string[]} currentPath - Path of current item.\n * @member {function} onItemKeyDown - The function to call when a key is pressed from a menuitem.\n */\nexport interface MenuProps {\n controlledBy?: string;\n items?: MenuItem[];\n currentPath?: string[];\n onItemKeyDown?: (event: KeyboardEvent) => void;\n}\n\nconst DEFAULT_GROUP_KEY = 'default';\nconst DEFAULT_GROUP = {\n id: DEFAULT_GROUP_KEY,\n label: DEFAULT_GROUP_KEY,\n};\n\n/** Get the items grouped by their group. */\nconst getGroupedItems = (items: MenuItem[]) => {\n const groups = items.reduce<{ group: MenuProps['items'][number]['group']; items: MenuItem[] }[]>((grouped, item) => {\n const itemGroup = grouped.find(({ group }) => group.id === (item.group?.id || DEFAULT_GROUP.id));\n if (!itemGroup) {\n grouped.push({ group: item.group ?? DEFAULT_GROUP, items: [item] });\n } else {\n itemGroup.items.push(item);\n }\n\n return grouped;\n }, []);\n\n // Sort to keep default group at the end\n return groups.sort((a, b) => (a.group.id === DEFAULT_GROUP_KEY ? 1 : b.group.id === DEFAULT_GROUP_KEY ? -1 : 0));\n};\n\n/**\n * Floating menu component. It shows a list of items that can be grouped.\n */\nexport const Menu: FunctionalComponent<MenuProps> = ({ controlledBy, items, currentPath = [], onItemKeyDown }) => {\n if (!items?.length) {\n return null;\n }\n\n const groups = getGroupedItems(items);\n\n const isActive = (item: MenuItem) => currentPath.includes(controlledBy) && currentPath.includes(item.id);\n\n return (\n <div\n class=\"menu-wrapper\"\n role=\"none\"\n >\n <div\n class=\"menu\"\n aria-labelledby={controlledBy ?? undefined}\n role=\"menu\"\n >\n {groups.map(({ group, items }) => (\n <div class={{ group: true, highlight: items.some((item) => item.highlight) }}>\n {group.id !== DEFAULT_GROUP_KEY ? (\n <div\n class=\"group-name\"\n id={group.id}\n >\n {group.label}\n </div>\n ) : groups.length > 1 ? (\n // empty div to keep the same height as the other groups\n <div class=\"group-name\" />\n ) : null}\n <ul\n class=\"menu-list\"\n role=\"group\"\n aria-labelledby={group.id !== DEFAULT_GROUP_KEY ? group.id : undefined}\n >\n {items.map((item) => (\n <li role=\"none\">\n {item.href && (\n <a\n class={{\n 'menu-item': true,\n 'active': isActive(item),\n }}\n href={item.href}\n role=\"menuitem\"\n tabIndex={-1}\n aria-current={isActive(item) ? 'page' : 'false'}\n onKeyDown={(event) => onItemKeyDown(event)}\n target={item.target}\n >\n {item.label}\n </a>\n )}\n </li>\n ))}\n </ul>\n </div>\n ))}\n </div>\n </div>\n );\n};\n"],"names":[],"mappings":";;AAiBA,MAAM,iBAAiB,GAAG,SAAS;AACnC,MAAM,aAAa,GAAG;AACpB,IAAA,EAAE,EAAE,iBAAiB;AACrB,IAAA,KAAK,EAAE,iBAAiB;CACzB;AAED;AACA,MAAM,eAAe,GAAG,CAAC,KAAiB,KAAI;IAC5C,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAsE,CAAC,OAAO,EAAE,IAAI,KAAI;AACjH,QAAA,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,aAAa,CAAC,EAAE,CAAC,CAAC;QAChG,IAAI,CAAC,SAAS,EAAE;AACd,YAAA,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,aAAa,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;;aAC9D;AACL,YAAA,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;;AAG5B,QAAA,OAAO,OAAO;KACf,EAAE,EAAE,CAAC;;IAGN,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,iBAAiB,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,iBAAiB,GAAG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K,iBAAiB,GAAG,KAAK,CAAC,EAAE,GAAG,SAAS,IAErE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,MACd,CAAA,CAAA,IAAA,EAAA,EAAI,IAAI,EAAC,MAAM,IACZ,IAAI,CAAC,IAAI,KACR,CACE,CAAA,GAAA,EAAA,EAAA,KAAK,EAAE;AACL,oBAAA,WAAW,EAAE,IAAI;AACjB,oBAAA,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC;AACzB,iBAAA,EACD,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAC,UAAU,EACf,QAAQ,EAAE,CAAC,CAAC,EACE,cAAA,EAAA,QAAQ,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG,OAAO,EAC/C,SAAS,EAAE,CAAC,KAAK,KAAK,aAAa,CAAC,KAAK,CAAC,EAC1C,MAAM,EAAE,IAAI,CAAC,MAAM,EAAA,EAElB,IAAI,CAAC,KAAK,CACT,CACL,CACE,CACN,CAAC,CACC,CACD,CACP,CAAC,CACE,CACF;AAEV;;;;"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Check if an element contains an event target by checking its composedPath.
3
+ * Useful when an event target may come from a component's shadow DOM.
4
+ */
5
+ const containsTarget = (ancestor, event) => {
6
+ return event
7
+ .composedPath()
8
+ .filter((el) => el !== document && el !== window.window)
9
+ .some((el) => ancestor.contains(el));
10
+ };
11
+ /** Move the focus to `next` element, set tabindex to 0 for `next` and -1 to `current`. */
12
+ const moveFocus = (current, next) => {
13
+ current.tabIndex = -1;
14
+ next.tabIndex = 0;
15
+ next.focus({ preventScroll: true });
16
+ };
17
+ /** Check if event key is ArrowUp */
18
+ const isArrowUpKey = (event) => event.key === 'ArrowUp';
19
+ /** Check if event key is ArrowDown */
20
+ const isArrowDownKey = (event) => event.key === 'ArrowDown';
21
+ /** Check if event key is Tab */
22
+ const isTabKey = (event) => event.key === 'Tab';
23
+ /** Check if event key is Escape */
24
+ const isEscKey = (event) => event.key === 'Escape';
25
+
26
+ var SearchEnv;
27
+ (function (SearchEnv) {
28
+ SearchEnv["DEV"] = "dev";
29
+ SearchEnv["TEST"] = "test";
30
+ SearchEnv["PROD"] = "prod";
31
+ })(SearchEnv || (SearchEnv = {}));
32
+ const S3_SHOP_URL = {
33
+ dev: 'https://zanichelli-shop-dev.s3.eu-west-1.amazonaws.com',
34
+ test: 'https://zanichelli-shop-test.s3.eu-west-1.amazonaws.com',
35
+ prod: 'https://zanichelli-shop.s3.eu-west-1.amazonaws.com',
36
+ };
37
+ async function getSubjectsByArea(searchEnv) {
38
+ try {
39
+ const response = await fetch(`${S3_SHOP_URL[searchEnv]}/categories.json`);
40
+ if (!response.ok) {
41
+ throw new Error(`HTTP ${response.status}`);
42
+ }
43
+ return await response.json();
44
+ }
45
+ catch (err) {
46
+ console.error('Error fetching subjects:', err);
47
+ return {};
48
+ }
49
+ }
50
+
51
+ export { SearchEnv as S, isTabKey as a, isArrowDownKey as b, containsTarget as c, isArrowUpKey as d, getSubjectsByArea as g, isEscKey as i, moveFocus as m };
52
+ //# sourceMappingURL=subjects.api-BRhngFD0.js.map
53
+
54
+ //# sourceMappingURL=subjects.api-BRhngFD0.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subjects.api-BRhngFD0.js","sources":["src/utils/utils.ts","src/utils/subjects.api.ts"],"sourcesContent":["/**\n * Check if an element contains an event target by checking its composedPath.\n * Useful when an event target may come from a component's shadow DOM.\n */\nexport const containsTarget = (ancestor: HTMLElement, event: Event) => {\n return event\n .composedPath()\n .filter((el) => el !== document && el !== window.window)\n .some((el) => ancestor.contains(el as HTMLElement));\n};\n\n/** Move the focus to `next` element, set tabindex to 0 for `next` and -1 to `current`. */\nexport const moveFocus = (current: HTMLElement, next: HTMLElement) => {\n current.tabIndex = -1;\n next.tabIndex = 0;\n next.focus({ preventScroll: true });\n};\n\n/** Check if event key is ArrowUp */\nexport const isArrowUpKey = (event: KeyboardEvent) => event.key === 'ArrowUp';\n\n/** Check if event key is ArrowDown */\nexport const isArrowDownKey = (event: KeyboardEvent) => event.key === 'ArrowDown';\n\n/** Check if event key is Tab */\nexport const isTabKey = (event: KeyboardEvent) => event.key === 'Tab';\n\n/** Check if event key is Escape */\nexport const isEscKey = (event: KeyboardEvent) => event.key === 'Escape';\n","export enum SearchEnv {\n DEV = 'dev',\n TEST = 'test',\n PROD = 'prod',\n}\n\nconst S3_SHOP_URL: Record<string, string> = {\n dev: 'https://zanichelli-shop-dev.s3.eu-west-1.amazonaws.com',\n test: 'https://zanichelli-shop-test.s3.eu-west-1.amazonaws.com',\n prod: 'https://zanichelli-shop.s3.eu-west-1.amazonaws.com',\n};\n\nexport async function getSubjectsByArea(searchEnv: SearchEnv): Promise<Record<string, string[]>> {\n try {\n const response = await fetch(`${S3_SHOP_URL[searchEnv]}/categories.json`);\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}`);\n }\n return await response.json();\n } catch (err) {\n console.error('Error fetching subjects:', err);\n return {};\n }\n}\n"],"names":[],"mappings":"AAAA;;;AAGG;MACU,cAAc,GAAG,CAAC,QAAqB,EAAE,KAAY,KAAI;AACpE,IAAA,OAAO;AACJ,SAAA,YAAY;AACZ,SAAA,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,QAAQ,IAAI,EAAE,KAAK,MAAM,CAAC,MAAM;AACtD,SAAA,IAAI,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,QAAQ,CAAC,EAAiB,CAAC,CAAC;AACvD;AAEA;MACa,SAAS,GAAG,CAAC,OAAoB,EAAE,IAAiB,KAAI;AACnE,IAAA,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACrB,IAAA,IAAI,CAAC,QAAQ,GAAG,CAAC;IACjB,IAAI,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;AACrC;AAEA;AACO,MAAM,YAAY,GAAG,CAAC,KAAoB,KAAK,KAAK,CAAC,GAAG,KAAK;AAEpE;AACO,MAAM,cAAc,GAA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