fictoan-react 2.0.0-beta.17 → 2.0.0-beta.19

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 (203) hide show
  1. package/dist/components/Accordion/Accordion.d.ts.map +1 -1
  2. package/dist/components/Accordion/Accordion.js +27 -0
  3. package/dist/components/Accordion/Accordion.js.map +1 -0
  4. package/dist/components/Badge/Badge.d.ts.map +1 -1
  5. package/dist/components/Badge/Badge.js +55 -0
  6. package/dist/components/Badge/Badge.js.map +1 -0
  7. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
  8. package/dist/components/Breadcrumbs/Breadcrumbs.js +64 -0
  9. package/dist/components/Breadcrumbs/Breadcrumbs.js.map +1 -0
  10. package/dist/components/Button/Button.js +28 -0
  11. package/dist/components/Button/Button.js.map +1 -0
  12. package/dist/components/ButtonGroup/ButtonGroup.js +27 -0
  13. package/dist/components/ButtonGroup/ButtonGroup.js.map +1 -0
  14. package/dist/components/Callout/Callout.d.ts.map +1 -1
  15. package/dist/components/Callout/Callout.js +37 -0
  16. package/dist/components/Callout/Callout.js.map +1 -0
  17. package/dist/components/Card/Card.js +27 -0
  18. package/dist/components/Card/Card.js.map +1 -0
  19. package/dist/components/CodeBlock/CodeBlock.js +191 -0
  20. package/dist/components/CodeBlock/CodeBlock.js.map +1 -0
  21. package/dist/components/Divider/Divider.js +29 -0
  22. package/dist/components/Divider/Divider.js.map +1 -0
  23. package/dist/components/Drawer/Drawer.d.ts +3 -0
  24. package/dist/components/Drawer/Drawer.d.ts.map +1 -1
  25. package/dist/components/Drawer/Drawer.js +96 -0
  26. package/dist/components/Drawer/Drawer.js.map +1 -0
  27. package/dist/components/Element/Element.d.ts +6 -2
  28. package/dist/components/Element/Element.d.ts.map +1 -1
  29. package/dist/components/Element/Element.js +154 -0
  30. package/dist/components/Element/Element.js.map +1 -0
  31. package/dist/components/Element/Tags.js +31 -0
  32. package/dist/components/Element/Tags.js.map +1 -0
  33. package/dist/components/Element/constants.d.ts +21 -21
  34. package/dist/components/Element/constants.d.ts.map +1 -1
  35. package/dist/components/Element/constants.js +8 -0
  36. package/dist/components/Element/constants.js.map +1 -0
  37. package/dist/components/Form/Checkbox/Checkbox.d.ts.map +1 -1
  38. package/dist/components/Form/Checkbox/Checkbox.js +78 -0
  39. package/dist/components/Form/Checkbox/Checkbox.js.map +1 -0
  40. package/dist/components/Form/Checkbox/CheckboxAndSwitchGroup.d.ts.map +1 -1
  41. package/dist/components/Form/Checkbox/CheckboxAndSwitchGroup.js +177 -0
  42. package/dist/components/Form/Checkbox/CheckboxAndSwitchGroup.js.map +1 -0
  43. package/dist/components/Form/Checkbox/Switch.d.ts.map +1 -1
  44. package/dist/components/Form/Checkbox/Switch.js +79 -0
  45. package/dist/components/Form/Checkbox/Switch.js.map +1 -0
  46. package/dist/components/Form/FileUpload/FileUpload.d.ts.map +1 -1
  47. package/dist/components/Form/FileUpload/FileUpload.js +142 -0
  48. package/dist/components/Form/FileUpload/FileUpload.js.map +1 -0
  49. package/dist/components/Form/Form/Form.js +37 -0
  50. package/dist/components/Form/Form/Form.js.map +1 -0
  51. package/dist/components/Form/Form/FormGenerator.js +64 -0
  52. package/dist/components/Form/Form/FormGenerator.js.map +1 -0
  53. package/dist/components/Form/FormItem/FormItem.d.ts +16 -0
  54. package/dist/components/Form/FormItem/FormItem.d.ts.map +1 -1
  55. package/dist/components/Form/FormItem/FormItem.js +127 -0
  56. package/dist/components/Form/FormItem/FormItem.js.map +1 -0
  57. package/dist/components/Form/FormItemGroup/FormItemGroup.d.ts.map +1 -1
  58. package/dist/components/Form/FormItemGroup/FormItemGroup.js +42 -0
  59. package/dist/components/Form/FormItemGroup/FormItemGroup.js.map +1 -0
  60. package/dist/components/Form/InputField/InputField.d.ts.map +1 -1
  61. package/dist/components/Form/InputField/InputField.js +156 -0
  62. package/dist/components/Form/InputField/InputField.js.map +1 -0
  63. package/dist/components/Form/InputLabel/InputLabel.js +30 -0
  64. package/dist/components/Form/InputLabel/InputLabel.js.map +1 -0
  65. package/dist/components/Form/ListBox/ListBox.d.ts +1 -1
  66. package/dist/components/Form/ListBox/ListBox.d.ts.map +1 -1
  67. package/dist/components/Form/ListBox/ListBox.js +287 -0
  68. package/dist/components/Form/ListBox/ListBox.js.map +1 -0
  69. package/dist/components/Form/ListBox/constants.d.ts +1 -1
  70. package/dist/components/Form/ListBox/constants.d.ts.map +1 -1
  71. package/dist/components/Form/ListBox/listBoxUtils.js +49 -0
  72. package/dist/components/Form/ListBox/listBoxUtils.js.map +1 -0
  73. package/dist/components/Form/PinInputField/PinInputField.d.ts +6 -1
  74. package/dist/components/Form/PinInputField/PinInputField.d.ts.map +1 -1
  75. package/dist/components/Form/PinInputField/PinInputField.js +165 -0
  76. package/dist/components/Form/PinInputField/PinInputField.js.map +1 -0
  77. package/dist/components/Form/RadioButton/RadioButton.d.ts.map +1 -1
  78. package/dist/components/Form/RadioButton/RadioButton.js +82 -0
  79. package/dist/components/Form/RadioButton/RadioButton.js.map +1 -0
  80. package/dist/components/Form/RadioButton/RadioGroup.d.ts.map +1 -1
  81. package/dist/components/Form/RadioButton/RadioGroup.js +97 -0
  82. package/dist/components/Form/RadioButton/RadioGroup.js.map +1 -0
  83. package/dist/components/Form/RadioButton/RadioTabGroup.d.ts +1 -1
  84. package/dist/components/Form/RadioButton/RadioTabGroup.d.ts.map +1 -1
  85. package/dist/components/Form/RadioButton/RadioTabGroup.js +182 -0
  86. package/dist/components/Form/RadioButton/RadioTabGroup.js.map +1 -0
  87. package/dist/components/Form/Range/Range.js +376 -0
  88. package/dist/components/Form/Range/Range.js.map +1 -0
  89. package/dist/components/Form/Select/Select.d.ts +1 -1
  90. package/dist/components/Form/Select/Select.d.ts.map +1 -1
  91. package/dist/components/Form/Select/Select.js +83 -0
  92. package/dist/components/Form/Select/Select.js.map +1 -0
  93. package/dist/components/Form/TextArea/TextArea.d.ts.map +1 -1
  94. package/dist/components/Form/TextArea/TextArea.js +111 -0
  95. package/dist/components/Form/TextArea/TextArea.js.map +1 -0
  96. package/dist/components/Meter/Meter.d.ts.map +1 -1
  97. package/dist/components/Meter/Meter.js +105 -0
  98. package/dist/components/Meter/Meter.js.map +1 -0
  99. package/dist/components/Modal/Modal.d.ts.map +1 -1
  100. package/dist/components/Modal/Modal.js +76 -0
  101. package/dist/components/Modal/Modal.js.map +1 -0
  102. package/dist/components/Notification/NotificationItem/NotificationItem.d.ts.map +1 -1
  103. package/dist/components/Notification/NotificationItem/NotificationItem.js +70 -0
  104. package/dist/components/Notification/NotificationItem/NotificationItem.js.map +1 -0
  105. package/dist/components/Notification/NotificationsProvider/NotificationsProvider.d.ts.map +1 -1
  106. package/dist/components/Notification/NotificationsProvider/NotificationsProvider.js +88 -0
  107. package/dist/components/Notification/NotificationsProvider/NotificationsProvider.js.map +1 -0
  108. package/dist/components/Notification/NotificationsWrapper/NotificationsWrapper.d.ts.map +1 -1
  109. package/dist/components/Notification/NotificationsWrapper/NotificationsWrapper.js +35 -0
  110. package/dist/components/Notification/NotificationsWrapper/NotificationsWrapper.js.map +1 -0
  111. package/dist/components/OptionCard/OptionCard.js +150 -0
  112. package/dist/components/OptionCard/OptionCard.js.map +1 -0
  113. package/dist/components/Pagination/Pagination.d.ts +1 -1
  114. package/dist/components/Pagination/Pagination.d.ts.map +1 -1
  115. package/dist/components/Pagination/Pagination.js +207 -0
  116. package/dist/components/Pagination/Pagination.js.map +1 -0
  117. package/dist/components/Pagination/usePagination.js +35 -0
  118. package/dist/components/Pagination/usePagination.js.map +1 -0
  119. package/dist/components/Portion/Portion.d.ts +1 -0
  120. package/dist/components/Portion/Portion.d.ts.map +1 -1
  121. package/dist/components/Portion/Portion.js +35 -0
  122. package/dist/components/Portion/Portion.js.map +1 -0
  123. package/dist/components/ProgressBar/ProgressBar.d.ts.map +1 -1
  124. package/dist/components/ProgressBar/ProgressBar.js +60 -0
  125. package/dist/components/ProgressBar/ProgressBar.js.map +1 -0
  126. package/dist/components/Row/Row.d.ts +1 -0
  127. package/dist/components/Row/Row.d.ts.map +1 -1
  128. package/dist/components/Row/Row.js +40 -0
  129. package/dist/components/Row/Row.js.map +1 -0
  130. package/dist/components/Sidebar/ContentWrapper/ContentWrapper.js +23 -0
  131. package/dist/components/Sidebar/ContentWrapper/ContentWrapper.js.map +1 -0
  132. package/dist/components/Sidebar/SidebarFooter/SidebarFooter.js +25 -0
  133. package/dist/components/Sidebar/SidebarFooter/SidebarFooter.js.map +1 -0
  134. package/dist/components/Sidebar/SidebarHeader/SidebarHeader.js +25 -0
  135. package/dist/components/Sidebar/SidebarHeader/SidebarHeader.js.map +1 -0
  136. package/dist/components/Sidebar/SidebarItem/SidebarItem.js +30 -0
  137. package/dist/components/Sidebar/SidebarItem/SidebarItem.js.map +1 -0
  138. package/dist/components/Sidebar/SidebarItemsGroup/SidebarItemsGroup.js +29 -0
  139. package/dist/components/Sidebar/SidebarItemsGroup/SidebarItemsGroup.js.map +1 -0
  140. package/dist/components/Sidebar/SidebarWrapper/SidebarWrapper.d.ts.map +1 -1
  141. package/dist/components/Sidebar/SidebarWrapper/SidebarWrapper.js +35 -0
  142. package/dist/components/Sidebar/SidebarWrapper/SidebarWrapper.js.map +1 -0
  143. package/dist/components/Skeleton/Skeleton.d.ts.map +1 -1
  144. package/dist/components/Skeleton/Skeleton.js +82 -0
  145. package/dist/components/Skeleton/Skeleton.js.map +1 -0
  146. package/dist/components/Spinner/Spinner.js +33 -0
  147. package/dist/components/Spinner/Spinner.js.map +1 -0
  148. package/dist/components/Table/Table.d.ts +0 -1
  149. package/dist/components/Table/Table.d.ts.map +1 -1
  150. package/dist/components/Table/Table.js +40 -0
  151. package/dist/components/Table/Table.js.map +1 -0
  152. package/dist/components/Tabs/Tabs.d.ts.map +1 -1
  153. package/dist/components/Tabs/Tabs.js +106 -0
  154. package/dist/components/Tabs/Tabs.js.map +1 -0
  155. package/dist/components/ThemeProvider/ThemeProvider.d.ts +6 -0
  156. package/dist/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
  157. package/dist/components/ThemeProvider/ThemeProvider.js +52 -0
  158. package/dist/components/ThemeProvider/ThemeProvider.js.map +1 -0
  159. package/dist/components/Toast/ToastItem/ToastItem.js +47 -0
  160. package/dist/components/Toast/ToastItem/ToastItem.js.map +1 -0
  161. package/dist/components/Toast/ToastsProvider/ToastsProvider.d.ts.map +1 -1
  162. package/dist/components/Toast/ToastsProvider/ToastsProvider.js +45 -0
  163. package/dist/components/Toast/ToastsProvider/ToastsProvider.js.map +1 -0
  164. package/dist/components/Toast/ToastsWrapper/ToastsWrapper.d.ts.map +1 -1
  165. package/dist/components/Toast/ToastsWrapper/ToastsWrapper.js +28 -0
  166. package/dist/components/Toast/ToastsWrapper/ToastsWrapper.js.map +1 -0
  167. package/dist/components/Tooltip/Tooltip.d.ts +1 -1
  168. package/dist/components/Tooltip/Tooltip.d.ts.map +1 -1
  169. package/dist/components/Tooltip/Tooltip.js +62 -0
  170. package/dist/components/Tooltip/Tooltip.js.map +1 -0
  171. package/dist/components/Typography/Heading.js +30 -0
  172. package/dist/components/Typography/Heading.js.map +1 -0
  173. package/dist/components/Typography/Text.js +15 -0
  174. package/dist/components/Typography/Text.js.map +1 -0
  175. package/dist/components/index.js +124 -75
  176. package/dist/components/index.js.map +1 -1
  177. package/dist/fictoan-schema.json +2066 -0
  178. package/dist/hooks/UseClickOutside.js +17 -0
  179. package/dist/hooks/UseClickOutside.js.map +1 -0
  180. package/dist/hooks/UseViewTransition.d.ts +2 -0
  181. package/dist/hooks/UseViewTransition.d.ts.map +1 -0
  182. package/dist/hooks/UseViewTransition.js +17 -0
  183. package/dist/hooks/UseViewTransition.js.map +1 -0
  184. package/dist/index.css +6 -10661
  185. package/dist/index.d.ts +3 -1
  186. package/dist/index.d.ts.map +1 -1
  187. package/dist/index.js +145 -152
  188. package/dist/index.js.map +1 -1
  189. package/dist/scripts/generateSchema.d.ts +2 -0
  190. package/dist/scripts/generateSchema.d.ts.map +1 -0
  191. package/dist/scripts/schema-meta.d.ts +12 -0
  192. package/dist/scripts/schema-meta.d.ts.map +1 -0
  193. package/dist/styles/colours.js +55 -0
  194. package/dist/styles/colours.js.map +1 -0
  195. package/dist/utils/classNames.d.ts +1 -1
  196. package/dist/utils/classNames.d.ts.map +1 -1
  197. package/dist/utils/classNames.js +6 -0
  198. package/dist/utils/classNames.js.map +1 -0
  199. package/dist/utils/propSeparation.js +77 -0
  200. package/dist/utils/propSeparation.js.map +1 -0
  201. package/package.json +24 -19
  202. package/dist/Accordion-CeGNgNW8.js +0 -4254
  203. package/dist/Accordion-CeGNgNW8.js.map +0 -1
@@ -0,0 +1,106 @@
1
+ "use client";
2
+ import { jsxs as h, jsx as a } from "react/jsx-runtime";
3
+ import y, { useRef as g, useCallback as p, useEffect as x } from "react";
4
+ import { Nav as S, Div as v } from "../Element/Tags.js";
5
+ /* empty css */
6
+ import { Divider as B } from "../Divider/Divider.js";
7
+ import { Text as C } from "../Typography/Text.js";
8
+ import { Element as T } from "../Element/Element.js";
9
+ const j = y.forwardRef(
10
+ ({ tabs: n, additionalNavContentWrapper: E, defaultActiveTab: $, align: w = "left", isFullWidth: N, ...R }, A) => {
11
+ const c = n.findIndex((e) => e.key === $), o = c > -1 ? c : 0, [t, s] = y.useState(
12
+ n.length > 0 ? n[o] : void 0
13
+ ), [D, k] = y.useState(!1), u = g([]), i = g(null), d = p((e) => {
14
+ (t == null ? void 0 : t.key) !== e.key && (k(!0), i.current !== null && clearTimeout(i.current), i.current = setTimeout(() => {
15
+ s(e), k(!1), i.current = null;
16
+ }, 150));
17
+ }, [t == null ? void 0 : t.key]);
18
+ x(() => () => {
19
+ i.current !== null && clearTimeout(i.current);
20
+ }, []), x(() => {
21
+ n.length > 0 ? n.find((r) => r.key === (t == null ? void 0 : t.key)) || s(n[o]) : s(void 0);
22
+ }, [n, o, t == null ? void 0 : t.key]);
23
+ const I = p((e, r) => {
24
+ var m;
25
+ let l = r;
26
+ if (e.key === "ArrowRight")
27
+ l = (r + 1) % n.length;
28
+ else if (e.key === "ArrowLeft")
29
+ l = (r - 1 + n.length) % n.length;
30
+ else if (e.key === "Home")
31
+ l = 0;
32
+ else if (e.key === "End")
33
+ l = n.length - 1;
34
+ else
35
+ return;
36
+ e.preventDefault();
37
+ const f = n[l];
38
+ f && (d(f), (m = u.current[l]) == null || m.focus());
39
+ }, [n, d]);
40
+ return t ? /* @__PURE__ */ h(
41
+ T,
42
+ {
43
+ as: "div",
44
+ "data-tabs": !0,
45
+ ref: A,
46
+ "data-align": w,
47
+ "data-full-width": N,
48
+ ...R,
49
+ children: [
50
+ /* @__PURE__ */ a(S, { "data-tabs-nav": !0, role: "tablist", "aria-label": "Tab Navigation", children: /* @__PURE__ */ h("ul", { className: "tab-labels-list", role: "none", children: [
51
+ n.map((e, r) => /* @__PURE__ */ a("li", { role: "none", children: /* @__PURE__ */ a(
52
+ T,
53
+ {
54
+ as: "button",
55
+ ref: (l) => {
56
+ u.current[r] = l;
57
+ },
58
+ id: `tab-${e.key}`,
59
+ role: "tab",
60
+ "aria-selected": t.key === e.key,
61
+ "aria-controls": `tab-panel-${e.key}`,
62
+ tabIndex: t.key === e.key ? 0 : -1,
63
+ "data-tab-label": !0,
64
+ "data-active": t.key === e.key,
65
+ "data-alert": e.hasAlert,
66
+ onClick: () => d(e),
67
+ onKeyDown: (l) => I(l, r),
68
+ className: `tab-button ${t.key === e.key ? "is-active" : ""}`,
69
+ marginBottom: "nano",
70
+ children: /* @__PURE__ */ a(
71
+ C,
72
+ {
73
+ className: `tab-label ${t.key === e.key ? "is-active" : ""} ${e.hasAlert ? "has-alert" : ""}`,
74
+ children: e.label
75
+ }
76
+ )
77
+ }
78
+ ) }, e.key)),
79
+ E
80
+ ] }) }),
81
+ /* @__PURE__ */ a(B, { kind: "tertiary", marginTop: "none", marginBottom: "micro" }),
82
+ n.map((e) => /* @__PURE__ */ a(
83
+ v,
84
+ {
85
+ id: `tab-panel-${e.key}`,
86
+ role: "tabpanel",
87
+ "aria-labelledby": `tab-${e.key}`,
88
+ tabIndex: t.key === e.key ? 0 : -1,
89
+ "data-tab-content": !0,
90
+ "data-active": t.key === e.key,
91
+ "data-exiting": t.key === e.key && D,
92
+ hidden: t.key !== e.key,
93
+ children: e.content
94
+ },
95
+ e.key
96
+ ))
97
+ ]
98
+ }
99
+ ) : null;
100
+ }
101
+ );
102
+ j.displayName = "Tabs";
103
+ export {
104
+ j as Tabs
105
+ };
106
+ //# sourceMappingURL=Tabs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tabs.js","sources":["../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["// REACT CORE ==========================================================================================================\nimport React, { useEffect, useCallback, useRef } from \"react\";\n\n// LOCAL COMPONENTS ====================================================================================================\nimport { CommonAndHTMLProps } from \"../Element/constants\";\nimport { Div, Nav } from \"../Element/Tags\";\nimport { Element } from \"$element\";\n\n// STYLES ==============================================================================================================\nimport \"./tabs.css\";\n\n// OTHER ===============================================================================================================\nimport { Divider } from \"../Divider/Divider\";\nimport { Text } from \"../Typography/Text\";\n\ninterface TabType {\n key : string;\n label : React.ReactNode;\n content : React.ReactNode;\n hasAlert ? : boolean;\n}\n\n// prettier-ignore\nexport interface TabsCustomProps {\n tabs : TabType[];\n additionalNavContentWrapper ? : React.ReactNode;\n defaultActiveTab ? : React.ReactNode;\n align ? : \"left\" | \"centre\" | \"center\" | \"right\";\n isFullWidth ? : boolean;\n}\n\nexport type TabsElementType = HTMLDivElement;\nexport type TabsProps = Omit<CommonAndHTMLProps<TabsElementType>, keyof TabsCustomProps> & TabsCustomProps;\n\nexport const Tabs = React.forwardRef(\n (\n {tabs, additionalNavContentWrapper, defaultActiveTab, align = \"left\", isFullWidth, ...props} : TabsProps,\n ref : React.Ref<TabsElementType>) => {\n const index = tabs.findIndex((tab) => tab.key === defaultActiveTab);\n const defaultTabIndex = index > -1 ? index : 0;\n const [ activeTab, setActiveTab ] = React.useState<TabType | undefined>(\n tabs.length > 0 ? tabs[defaultTabIndex] : undefined,\n );\n const [ isExiting, setIsExiting ] = React.useState<boolean>(false);\n\n // Refs for keyboard navigation to focus the tab buttons\n const tabButtonRefs = useRef<(HTMLButtonElement | null)[]>([]);\n\n // Holds the pending exit-animation timer so rapid switching / unmount\n // mid-transition can clear it instead of committing a stale tab.\n const exitTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // V2's performant animation logic\n const handleTabChange = useCallback((tab : TabType) => {\n if (activeTab?.key !== tab.key) {\n setIsExiting(true);\n // Cancel any in-flight transition before queuing a new one.\n if (exitTimerRef.current !== null) {\n clearTimeout(exitTimerRef.current);\n }\n exitTimerRef.current = setTimeout(() => {\n setActiveTab(tab);\n setIsExiting(false);\n exitTimerRef.current = null;\n }, 150); // Animation duration\n }\n }, [ activeTab?.key ]);\n\n // Clear any pending exit-animation timer on unmount.\n useEffect(() => {\n return () => {\n if (exitTimerRef.current !== null) {\n clearTimeout(exitTimerRef.current);\n }\n };\n }, []);\n\n useEffect(() => {\n if (tabs.length > 0) {\n // If the current active tab still exists in the new tabs array, keep it.\n // This preserves the active state if the content of a tab changes.\n const currentTabStillExists = tabs.find(tab => tab.key === activeTab?.key);\n if (!currentTabStillExists) {\n // Otherwise, default to the designated default tab or the first one.\n setActiveTab(tabs[defaultTabIndex]);\n }\n } else {\n setActiveTab(undefined);\n }\n }, [ tabs, defaultTabIndex, activeTab?.key ]);\n\n\n const handleKeyDown = useCallback((event : React.KeyboardEvent, currentIndex : number) => {\n let nextIndex = currentIndex;\n\n if (event.key === \"ArrowRight\") {\n nextIndex = (currentIndex + 1) % tabs.length;\n } else if (event.key === \"ArrowLeft\") {\n nextIndex = (currentIndex - 1 + tabs.length) % tabs.length;\n } else if (event.key === \"Home\") {\n nextIndex = 0;\n } else if (event.key === \"End\") {\n nextIndex = tabs.length - 1;\n } else {\n // Exit if it's not a navigation key\n return;\n }\n\n event.preventDefault();\n const nextTab = tabs[nextIndex];\n if (nextTab) {\n handleTabChange(nextTab);\n tabButtonRefs.current[nextIndex]?.focus();\n }\n\n }, [ tabs, handleTabChange ]);\n\n if (!activeTab) {\n return null; // Render nothing if there are no tabs or no active tab\n }\n\n return (\n <Element<TabsElementType>\n as=\"div\"\n data-tabs\n ref={ref}\n data-align={align}\n data-full-width={isFullWidth}\n {...props}\n >\n <Nav data-tabs-nav role=\"tablist\" aria-label=\"Tab Navigation\">\n {/* role=\"none\" on the list + items removes their list semantics from the\n a11y tree so the role=\"tab\" buttons become the tablist's owned children\n (otherwise axe flags aria-required-children / aria-required-parent). */}\n <ul className=\"tab-labels-list\" role=\"none\">\n {tabs.map((tab, i) => (\n <li key={tab.key} role=\"none\">\n <Element<HTMLButtonElement>\n as=\"button\"\n ref={(el) => { tabButtonRefs.current[i] = el; }}\n id={`tab-${tab.key}`}\n role=\"tab\"\n aria-selected={activeTab.key === tab.key}\n aria-controls={`tab-panel-${tab.key}`}\n tabIndex={activeTab.key === tab.key ? 0 : -1} // Roaming tabindex\n data-tab-label\n data-active={activeTab.key === tab.key}\n data-alert={tab.hasAlert}\n onClick={() => handleTabChange(tab)}\n onKeyDown={(e) => handleKeyDown(e, i)}\n className={`tab-button ${activeTab.key === tab.key ? \"is-active\" : \"\"}`}\n marginBottom=\"nano\"\n >\n <Text\n className={`tab-label ${activeTab.key === tab.key ? \"is-active\" : \"\"} ${tab.hasAlert ? \"has-alert\" : \"\"}`}\n >\n {tab.label}\n </Text>\n </Element>\n </li>\n ))}\n {additionalNavContentWrapper}\n </ul>\n </Nav>\n\n <Divider kind=\"tertiary\" marginTop=\"none\" marginBottom=\"micro\" />\n\n {tabs.map((tab) => (\n <Div\n key={tab.key}\n id={`tab-panel-${tab.key}`}\n role=\"tabpanel\"\n aria-labelledby={`tab-${tab.key}`}\n tabIndex={activeTab.key === tab.key ? 0 : -1}\n data-tab-content\n data-active={activeTab.key === tab.key}\n data-exiting={activeTab.key === tab.key && isExiting}\n hidden={activeTab.key !== tab.key}\n >\n {tab.content}\n </Div>\n ))}\n </Element>\n );\n },\n);\nTabs.displayName = \"Tabs\";"],"names":["Tabs","React","tabs","additionalNavContentWrapper","defaultActiveTab","align","isFullWidth","props","ref","index","tab","defaultTabIndex","activeTab","setActiveTab","isExiting","setIsExiting","tabButtonRefs","useRef","exitTimerRef","handleTabChange","useCallback","useEffect","handleKeyDown","event","currentIndex","nextIndex","nextTab","_a","jsxs","Element","jsx","Nav","i","el","e","Text","Divider","Div"],"mappings":";;;;;;;AAkCO,MAAMA,IAAOC,EAAM;AAAA,EACtB,CACI,EAAC,MAAAC,GAAM,6BAAAC,GAA6B,kBAAAC,GAAkB,OAAAC,IAAQ,QAAQ,aAAAC,GAAa,GAAGC,EAAA,GACtFC,MAAqC;AACrC,UAAMC,IAAQP,EAAK,UAAU,CAACQ,MAAQA,EAAI,QAAQN,CAAgB,GAC5DO,IAAkBF,IAAQ,KAAKA,IAAQ,GACvC,CAAEG,GAAWC,CAAa,IAAIZ,EAAM;AAAA,MACtCC,EAAK,SAAS,IAAIA,EAAKS,CAAe,IAAI;AAAA,IAAA,GAExC,CAAEG,GAAWC,CAAa,IAAId,EAAM,SAAkB,EAAK,GAG3De,IAAgBC,EAAqC,EAAE,GAIvDC,IAAeD,EAA6C,IAAI,GAGhEE,IAAkBC,EAAY,CAACV,MAAkB;AACnD,OAAIE,KAAA,gBAAAA,EAAW,SAAQF,EAAI,QACvBK,EAAa,EAAI,GAEbG,EAAa,YAAY,QACzB,aAAaA,EAAa,OAAO,GAErCA,EAAa,UAAU,WAAW,MAAM;AACpC,QAAAL,EAAaH,CAAG,GAChBK,EAAa,EAAK,GAClBG,EAAa,UAAU;AAAA,MAC3B,GAAG,GAAG;AAAA,IAEd,GAAG,CAAEN,KAAA,gBAAAA,EAAW,GAAI,CAAC;AAGrB,IAAAS,EAAU,MACC,MAAM;AACT,MAAIH,EAAa,YAAY,QACzB,aAAaA,EAAa,OAAO;AAAA,IAEzC,GACD,CAAA,CAAE,GAELG,EAAU,MAAM;AACZ,MAAInB,EAAK,SAAS,IAGgBA,EAAK,KAAK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EAAI;AAAA,cAE7B,UAAAA,EAAI;AAAA,YAAA;AAAA,YAVAA,EAAI;AAAA,UAAA,CAYhB;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA,IA/DE;AAAA,EAkEf;AACJ;AACAV,EAAK,cAAc;"}
@@ -7,6 +7,12 @@ export type ThemeProviderElementType = HTMLDivElement;
7
7
  export interface ThemeProviderProps extends CommonAndHTMLProps<ThemeProviderElementType> {
8
8
  themeList: string[];
9
9
  currentTheme: string;
10
+ /** localStorage key the theme is persisted under. Defaults to "fictoan-theme"; pass a unique
11
+ * value (your package.json name works well) when multiple Fictoan apps can share an origin
12
+ * (e.g. localhost during dev, GitHub Pages) so their themes don't collide. */
13
+ storageKey?: string;
14
+ /** Pass your CSP nonce so the no-flash inline script is allowed under a strict `script-src`. */
15
+ nonce?: string;
10
16
  }
11
17
  export declare const ThemeProvider: React.ForwardRefExoticComponent<ThemeProviderProps & React.RefAttributes<HTMLDivElement>>;
12
18
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../../src/components/ThemeProvider/ThemeProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAGhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAqB1D,KAAK,gBAAgB,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAK/E,eAAO,MAAM,QAAQ,QAAO,gBAM3B,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,cAAc,CAAC;AACtD,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB,CAAC,wBAAwB,CAAC;IACpF,SAAS,EAAM,MAAM,EAAE,CAAC;IACxB,YAAY,EAAG,MAAM,CAAC;CACzB;AAaD,eAAO,MAAM,aAAa,2FAuDzB,CAAC"}
1
+ {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../../src/components/ThemeProvider/ThemeProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAGhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAO1D,KAAK,gBAAgB,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAK/E,eAAO,MAAM,QAAQ,QAAO,gBAM3B,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,cAAc,CAAC;AACtD,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB,CAAC,wBAAwB,CAAC;IACpF,SAAS,EAAM,MAAM,EAAE,CAAC;IACxB,YAAY,EAAG,MAAM,CAAC;IACtB;;mFAE+E;IAC/E,UAAW,CAAC,EAAG,MAAM,CAAC;IACtB,gGAAgG;IAChG,KAAW,CAAC,EAAG,MAAM,CAAC;CACzB;AAaD,eAAO,MAAM,aAAa,2FAqFzB,CAAC"}
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import { jsxs as w, jsx as h } from "react/jsx-runtime";
3
+ import m, { useState as N, useCallback as C, useEffect as _ } from "react";
4
+ import { Element as I } from "../Element/Element.js";
5
+ const p = "fictoan-theme";
6
+ let y = !1;
7
+ const P = ["", (e) => {
8
+ }], v = m.createContext(void 0), R = () => {
9
+ const e = m.useContext(v);
10
+ return e === void 0 ? P : e;
11
+ }, g = (e, o) => {
12
+ let a;
13
+ try {
14
+ a = localStorage.getItem(e) || void 0;
15
+ } catch {
16
+ }
17
+ return a || o;
18
+ }, k = m.forwardRef(
19
+ ({ currentTheme: e, themeList: o, children: a, nonce: u, storageKey: c, ...S }, T) => {
20
+ const t = c ?? p, [r, E] = N(() => g(t) || e), i = C(
21
+ (n) => {
22
+ const s = typeof n == "function" ? n(r) : n, d = o.includes(s) ? s : o[0], f = () => {
23
+ document.documentElement.className = "", document.documentElement.classList.add(d);
24
+ }, l = typeof document < "u" ? document : null;
25
+ l && typeof l.startViewTransition == "function" ? l.startViewTransition(f) : typeof document < "u" && f(), E(d);
26
+ try {
27
+ localStorage.setItem(t, d);
28
+ } catch {
29
+ }
30
+ },
31
+ [r, o, t]
32
+ );
33
+ _(() => {
34
+ var s;
35
+ const n = g(t);
36
+ i(n || e), c === void 0 && !y && typeof process < "u" && ((s = process.env) == null ? void 0 : s.NODE_ENV) !== "production" && (y = !0, console.warn(
37
+ `[fictoan-react] ThemeProvider is persisting the theme to the default localStorage key "${p}". If more than one Fictoan app can share an origin (e.g. localhost during dev, GitHub Pages), pass a unique \`storageKey\` (your package.json name works well) so their themes don't collide.`
38
+ ));
39
+ }, [e, i, t, c]);
40
+ const x = `(function(){try{var t=localStorage.getItem(${JSON.stringify(t)})||${JSON.stringify(e)};if(t){document.documentElement.className=t;}}catch(e){}})();`;
41
+ return /* @__PURE__ */ w(v.Provider, { value: [r, i], children: [
42
+ /* @__PURE__ */ h("script", { nonce: u, dangerouslySetInnerHTML: { __html: x } }),
43
+ /* @__PURE__ */ h(I, { as: "div", "data-theme-provider": !0, ref: T, ...S, children: a })
44
+ ] });
45
+ }
46
+ );
47
+ k.displayName = "ThemeProvider";
48
+ export {
49
+ k as ThemeProvider,
50
+ R as useTheme
51
+ };
52
+ //# sourceMappingURL=ThemeProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeProvider.js","sources":["../../../src/components/ThemeProvider/ThemeProvider.tsx"],"sourcesContent":["// REACT CORE ==========================================================================================================\nimport React, { useCallback, useEffect, useState } from \"react\";\n\n// ELEMENT =============================================================================================================\nimport { CommonAndHTMLProps } from \"../Element/constants\";\nimport { Element } from \"$element\";\n\nconst DEFAULT_STORAGE_KEY = \"fictoan-theme\";\nlet hasWarnedDefaultKey = false;\n\n// Create a tuple type for the theme context\ntype ThemeContextType = [string, React.Dispatch<React.SetStateAction<string>>];\n\nconst defaultContext: ThemeContextType = [\"\", (_) => {}];\nconst ThemeContext = React.createContext<ThemeContextType | undefined>(undefined);\n\nexport const useTheme = (): ThemeContextType => {\n const context = React.useContext(ThemeContext);\n if (context === undefined) {\n return defaultContext;\n }\n return context;\n};\n\nexport type ThemeProviderElementType = HTMLDivElement;\nexport interface ThemeProviderProps extends CommonAndHTMLProps<ThemeProviderElementType> {\n themeList : string[];\n currentTheme : string;\n /** localStorage key the theme is persisted under. Defaults to \"fictoan-theme\"; pass a unique\n * value (your package.json name works well) when multiple Fictoan apps can share an origin\n * (e.g. localhost during dev, GitHub Pages) so their themes don't collide. */\n storageKey ? : string;\n /** Pass your CSP nonce so the no-flash inline script is allowed under a strict `script-src`. */\n nonce ? : string;\n}\n\nconst getTheme = (key: string, fallback?: string) => {\n let theme;\n try {\n theme = localStorage.getItem(key) || undefined;\n } catch (e) {\n // Unsupported\n }\n return theme || fallback;\n};\n\n// COMPONENT ///////////////////////////////////////////////////////////////////////////////////////////////////////////\nexport const ThemeProvider = React.forwardRef(\n ({ currentTheme, themeList, children, nonce, storageKey, ...props }: ThemeProviderProps, ref: React.Ref<ThemeProviderElementType>) => {\n const resolvedKey = storageKey ?? DEFAULT_STORAGE_KEY;\n const [themeState, setThemeState] = useState<string>(() =>\n getTheme(resolvedKey) || currentTheme);\n\n const setTheme = useCallback(\n (value: React.SetStateAction<string>) => {\n // Handle both direct values and updater functions\n const newTheme = typeof value === \"function\"\n ? value(themeState)\n : value;\n\n const finalTheme = themeList.includes(newTheme)\n ? newTheme\n : themeList[0];\n\n // The visible theme switch is documentElement.className changing,\n // which all theme-* CSS rules cascade off. Wrap that mutation in\n // a view transition so consumers get a smooth crossfade between\n // themes without writing animation CSS. Falls back to instant\n // change on browsers that don't support the API.\n const applyClass = () => {\n document.documentElement.className = \"\";\n document.documentElement.classList.add(finalTheme);\n };\n\n const doc = typeof document !== \"undefined\"\n ? document as Document & { startViewTransition?: (cb: () => void) => unknown }\n : null;\n\n if (doc && typeof doc.startViewTransition === \"function\") {\n doc.startViewTransition(applyClass);\n } else if (typeof document !== \"undefined\") {\n applyClass();\n }\n\n setThemeState(finalTheme);\n try {\n localStorage.setItem(resolvedKey, finalTheme);\n } catch (e) {\n // Unsupported\n }\n },\n [themeState, themeList, resolvedKey]\n );\n\n useEffect(() => {\n const theme = getTheme(resolvedKey);\n setTheme(theme || currentTheme);\n\n if (\n storageKey === undefined && !hasWarnedDefaultKey &&\n typeof process !== \"undefined\" && process.env?.NODE_ENV !== \"production\"\n ) {\n hasWarnedDefaultKey = true;\n console.warn(\n `[fictoan-react] ThemeProvider is persisting the theme to the default localStorage ` +\n `key \"${DEFAULT_STORAGE_KEY}\". If more than one Fictoan app can share an origin (e.g. ` +\n `localhost during dev, GitHub Pages), pass a unique \\`storageKey\\` (your package.json ` +\n `name works well) so their themes don't collide.`,\n );\n }\n }, [currentTheme, setTheme, resolvedKey, storageKey]);\n\n // No-flash pre-hydration script: set the persisted theme class on <html>\n // before first paint, so the (un-gated, SSR-rendered) children don't flash\n // the default theme. Reads the same storageKey as the component; falls back\n // to currentTheme. Inline → strict-CSP consumers should pass a `nonce`.\n // SSR/SSG: runs during initial HTML parse; pure CSR: a no-op (the mount\n // effect applies the theme).\n const noFlashScript =\n `(function(){try{var t=localStorage.getItem(${JSON.stringify(resolvedKey)})` +\n `||${JSON.stringify(currentTheme)};` +\n `if(t){document.documentElement.className=t;}}catch(e){}})();`;\n\n return (\n <ThemeContext.Provider value={[themeState, setTheme]}>\n <script nonce={nonce} dangerouslySetInnerHTML={{ __html: noFlashScript }} />\n <Element<ThemeProviderElementType> as=\"div\" data-theme-provider ref={ref} {...props}>\n {children}\n </Element>\n </ThemeContext.Provider>\n );\n }\n);\nThemeProvider.displayName = \"ThemeProvider\";\n"],"names":["DEFAULT_STORAGE_KEY","hasWarnedDefaultKey","defaultContext","_","ThemeContext","React","useTheme","context","getTheme","key","fallback","theme","ThemeProvider","currentTheme","themeList","children","nonce","storageKey","props","ref","resolvedKey","themeState","setThemeState","useState","setTheme","useCallback","value","newTheme","finalTheme","apply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;AAAA,IAAA;AAGvC,IAAAW,EAAU,MAAM;;AACZ,YAAMpB,IAAQH,EAASY,CAAW;AAClC,MAAAI,EAASb,KAASE,CAAY,GAG1BI,MAAe,UAAa,CAAChB,KAC7B,OAAO,UAAY,SAAe+B,IAAA,QAAQ,QAAR,gBAAAA,EAAa,cAAa,iBAE5D/B,IAAsB,IACtB,QAAQ;AAAA,QACJ,0FACQD,CAAmB;AAAA,MAAA;AAAA,IAKvC,GAAG,CAACa,GAAcW,GAAUJ,GAAaH,CAAU,CAAC;AAQpD,UAAMgB,IACF,8CAA8C,KAAK,UAAUb,CAAW,CAAC,MACpE,KAAK,UAAUP,CAAY,CAAC;AAGrC,WACI,gBAAAqB,EAAC9B,EAAa,UAAb,EAAsB,OAAO,CAACiB,GAAYG,CAAQ,GAC/C,UAAA;AAAA,MAAA,gBAAAW,EAAC,YAAO,OAAAnB,GAAc,yBAAyB,EAAE,QAAQiB,KAAiB;AAAA,MAC1E,gBAAAE,EAACC,KAAkC,IAAG,OAAM,uBAAmB,IAAC,KAAAjB,GAAW,GAAGD,GACzE,UAAAH,EAAA,CACL;AAAA,IAAA,GACJ;AAAA,EAER;AACJ;AACAH,EAAc,cAAc;"}
@@ -0,0 +1,47 @@
1
+ "use client";
2
+ import { jsx as n } from "react/jsx-runtime";
3
+ import { useState as u, useEffect as r } from "react";
4
+ /* empty css */
5
+ import { Element as c } from "../../Element/Element.js";
6
+ const f = ({
7
+ id: a,
8
+ duration: e = 4,
9
+ onClose: i,
10
+ children: o
11
+ }) => {
12
+ const [t, m] = u(!1);
13
+ return r(() => {
14
+ if (e === 0) return;
15
+ const s = setTimeout(() => {
16
+ m(!0);
17
+ }, e * 1e3);
18
+ return () => clearTimeout(s);
19
+ }, [e]), r(() => {
20
+ if (!t) return;
21
+ const s = setTimeout(() => {
22
+ i();
23
+ }, 500);
24
+ return () => clearTimeout(s);
25
+ }, [t, i]), /* @__PURE__ */ n(
26
+ c,
27
+ {
28
+ as: "div",
29
+ "data-toast-item": !0,
30
+ id: a,
31
+ classNames: t ? ["dismissed"] : [],
32
+ onTransitionEnd: () => {
33
+ t && i();
34
+ },
35
+ role: "status",
36
+ "aria-live": "polite",
37
+ "aria-atomic": "true",
38
+ shadow: "soft",
39
+ children: o
40
+ }
41
+ );
42
+ };
43
+ f.displayName = "ToastItem";
44
+ export {
45
+ f as ToastItem
46
+ };
47
+ //# sourceMappingURL=ToastItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToastItem.js","sources":["../../../../src/components/Toast/ToastItem/ToastItem.tsx"],"sourcesContent":["// REACT CORE ==========================================================================================================\nimport React, { useState, useEffect } from \"react\";\n\n// STYLES ==============================================================================================================\nimport \"./toast-item.css\";\n\n// OTHER ===============================================================================================================\nimport { Element } from \"$element\";\n\n// TYPES ===============================================================================================================\nexport interface ToastItemProps {\n id : string;\n duration ? : number;\n onClose : () => void;\n children : React.ReactNode;\n}\n\nexport type ToastItemElementType = HTMLDivElement;\n\n// COMPONENT ===========================================================================================================\nexport const ToastItem = ({\n id,\n duration = 4,\n onClose,\n children,\n}: ToastItemProps) => {\n const [isExiting, setIsExiting] = useState(false);\n\n useEffect(() => {\n if (duration === 0) return;\n\n const timer = setTimeout(() => {\n setIsExiting(true);\n }, duration * 1000);\n\n return () => clearTimeout(timer);\n }, [duration]);\n\n // Fallback: if transition doesn't fire, remove after animation duration\n useEffect(() => {\n if (!isExiting) return;\n\n const fallbackTimer = setTimeout(() => {\n onClose();\n }, 500);\n\n return () => clearTimeout(fallbackTimer);\n }, [isExiting, onClose]);\n\n const handleTransitionEnd = () => {\n if (isExiting) {\n onClose();\n }\n };\n\n return (\n <Element<ToastItemElementType>\n as=\"div\"\n data-toast-item\n id={id}\n classNames={isExiting ? [\"dismissed\"] : []}\n onTransitionEnd={handleTransitionEnd}\n role=\"status\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n shadow=\"soft\"\n >\n {children}\n </Element>\n );\n};\nToastItem.displayName = \"ToastItem\";\n"],"names":["ToastItem","id","duration","onClose","children","isExiting","setIsExiting","useState","useEffect","timer","fallbackTimer","jsx","Element"],"mappings":";;;;AAoBO,MAAMA,IAAY,CAAC;AAAA,EACtB,IAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,SAAAC;AAAA,EACA,UAAAC;AACJ,MAAsB;AAClB,QAAM,CAACC,GAAWC,CAAY,IAAIC,EAAS,EAAK;AAEhD,SAAAC,EAAU,MAAM;AACZ,QAAIN,MAAa,EAAG;AAEpB,UAAMO,IAAQ,WAAW,MAAM;AAC3B,MAAAH,EAAa,EAAI;AAAA,IACrB,GAAGJ,IAAW,GAAI;AAElB,WAAO,MAAM,aAAaO,CAAK;AAAA,EACnC,GAAG,CAACP,CAAQ,CAAC,GAGbM,EAAU,MAAM;AACZ,QAAI,CAACH,EAAW;AAEhB,UAAMK,IAAgB,WAAW,MAAM;AACnC,MAAAP,EAAA;AAAA,IACJ,GAAG,GAAG;AAEN,WAAO,MAAM,aAAaO,CAAa;AAAA,EAC3C,GAAG,CAACL,GAAWF,CAAO,CAAC,GASnB,gBAAAQ;AAAA,IAACC;AAAA,IAAA;AAAA,MACG,IAAG;AAAA,MACH,mBAAe;AAAA,MACf,IAAAX;AAAA,MACA,YAAYI,IAAY,CAAC,WAAW,IAAI,CAAA;AAAA,MACxC,iBAZoB,MAAM;AAC9B,QAAIA,KACAF,EAAA;AAAA,MAER;AAAA,MASQ,MAAK;AAAA,MACL,aAAU;AAAA,MACV,eAAY;AAAA,MACZ,QAAO;AAAA,MAEN,UAAAC;AAAA,IAAA;AAAA,EAAA;AAGb;AACAJ,EAAU,cAAc;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ToastsProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/Toast/ToastsProvider/ToastsProvider.tsx"],"names":[],"mappings":"AACA,OAAc,EAAoD,SAAS,EAAE,MAAM,OAAO,CAAC;AAc3F,MAAM,WAAW,mBAAmB;IAChC,QAAQ,EAAK,SAAS,CAAC;IACvB,MAAS,CAAC,EAAG,KAAK,GAAG,QAAQ,CAAC;CACjC;AAGD,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAUzE,eAAO,MAAM,cAAc;4BAGxB,mBAAmB;;CAqCrB,CAAC;AAIF,eAAO,MAAM,SAAS,QAAO,aAQ5B,CAAC"}
1
+ {"version":3,"file":"ToastsProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/Toast/ToastsProvider/ToastsProvider.tsx"],"names":[],"mappings":"AACA,OAAc,EAA6D,SAAS,EAAE,MAAM,OAAO,CAAC;AAcpG,MAAM,WAAW,mBAAmB;IAChC,QAAQ,EAAK,SAAS,CAAC;IACvB,MAAS,CAAC,EAAG,KAAK,GAAG,QAAQ,CAAC;CACjC;AAGD,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAUzE,eAAO,MAAM,cAAc;4BAGxB,mBAAmB;;CAqCrB,CAAC;AAIF,eAAO,MAAM,SAAS,QAAO,aAQ5B,CAAC"}
@@ -0,0 +1,45 @@
1
+ "use client";
2
+ import { jsxs as p, jsx as n } from "react/jsx-runtime";
3
+ import { useState as T, useCallback as i, createContext as x, useMemo as f, useContext as h } from "react";
4
+ import { ToastsWrapper as v } from "../ToastsWrapper/ToastsWrapper.js";
5
+ import { ToastItem as C } from "../ToastItem/ToastItem.js";
6
+ const m = x(null), w = ({
7
+ children: e,
8
+ anchor: c = "top"
9
+ }) => {
10
+ const [u, r] = T([]), l = i((t) => {
11
+ r((o) => o.filter((s) => s.id !== t));
12
+ }, []), a = i((t, o = 4) => {
13
+ const s = `toast-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
14
+ r((d) => [...d, {
15
+ id: s,
16
+ message: t,
17
+ duration: o
18
+ }]);
19
+ }, []);
20
+ return /* @__PURE__ */ p(m.Provider, { value: f(() => ({ toast: a }), [a]), children: [
21
+ e,
22
+ /* @__PURE__ */ n(v, { anchor: c, children: u.map(({ id: t, message: o, duration: s }) => /* @__PURE__ */ n(
23
+ C,
24
+ {
25
+ id: t,
26
+ duration: s,
27
+ onClose: () => l(t),
28
+ children: o
29
+ },
30
+ t
31
+ )) })
32
+ ] });
33
+ };
34
+ w.displayName = "ToastsProvider";
35
+ const M = () => {
36
+ const e = h(m);
37
+ if (!e)
38
+ throw new Error("useToasts must be used within a ToastsProvider");
39
+ return e.toast;
40
+ };
41
+ export {
42
+ w as ToastsProvider,
43
+ M as useToasts
44
+ };
45
+ //# sourceMappingURL=ToastsProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToastsProvider.js","sources":["../../../../src/components/Toast/ToastsProvider/ToastsProvider.tsx"],"sourcesContent":["// REACT CORE ==========================================================================================================\nimport React, { createContext, useContext, useState, useCallback, useMemo, ReactNode } from \"react\";\n\n// INTERNAL ============================================================================================================\nimport { ToastsWrapper } from \"../ToastsWrapper/ToastsWrapper\";\nimport { ToastItem } from \"../ToastItem/ToastItem\";\n\n// TYPES ===============================================================================================================\ninterface InternalToast {\n id : string;\n message : string;\n duration : number;\n}\n\n// prettier-ignore\nexport interface ToastsProviderProps {\n children : ReactNode;\n anchor ? : \"top\" | \"bottom\";\n}\n\n// TOAST FUNCTION TYPE =================================================================================================\nexport type ToastFunction = (message: string, duration?: number) => void;\n\ninterface ToastsContextValue {\n toast: ToastFunction;\n}\n\n// CONTEXT =============================================================================================================\nconst ToastsContext = createContext<ToastsContextValue | null>(null);\n\n// PROVIDER ============================================================================================================\nexport const ToastsProvider = ({\n children,\n anchor = \"top\",\n}: ToastsProviderProps) => {\n const [toasts, setToasts] = useState<InternalToast[]>([]);\n\n // Remove a toast by ID\n const removeToast = useCallback((id: string) => {\n setToasts(prev => prev.filter(t => t.id !== id));\n }, []);\n\n // Main toast function\n const toast: ToastFunction = useCallback((message: string, duration: number = 4) => {\n const id = `toast-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;\n\n setToasts(prev => [...prev, {\n id,\n message,\n duration,\n }]);\n }, []);\n\n return (\n <ToastsContext.Provider value={useMemo(() => ({ toast }), [toast])}>\n {children}\n\n <ToastsWrapper anchor={anchor}>\n {toasts.map(({ id, message, duration }) => (\n <ToastItem\n key={id}\n id={id}\n duration={duration}\n onClose={() => removeToast(id)}\n >\n {message}\n </ToastItem>\n ))}\n </ToastsWrapper>\n </ToastsContext.Provider>\n );\n};\nToastsProvider.displayName = \"ToastsProvider\";\n\n// HOOK ================================================================================================================\nexport const useToasts = (): ToastFunction => {\n const context = useContext(ToastsContext);\n\n if (!context) {\n throw new Error(\"useToasts must be used within a ToastsProvider\");\n }\n\n return context.toast;\n};\n"],"names":["ToastsContext","createContext","ToastsProvider","children","anchor","toasts","setToasts","useState","removeToast","useCallback","id","prev","t","toast","message","duration","jsxs","useMemo","jsx","ToastsWrapper","ToastItem","useToasts","context","useContext"],"mappings":";;;;AA4BA,MAAMA,IAAgBC,EAAyC,IAAI,GAGtDC,IAAiB,CAAC;AAAA,EAC3B,UAAAC;AAAA,EACA,QAAAC,IAAS;AACb,MAA2B;AACvB,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAA0B,CAAA,CAAE,GAGlDC,IAAcC,EAAY,CAACC,MAAe;AAC5C,IAAAJ,EAAU,OAAQK,EAAK,OAAO,OAAKC,EAAE,OAAOF,CAAE,CAAC;AAAA,EACnD,GAAG,CAAA,CAAE,GAGCG,IAAuBJ,EAAY,CAACK,GAAiBC,IAAmB,MAAM;AAChF,UAAML,IAAK,SAAS,KAAK,IAAA,CAAK,IAAI,KAAK,OAAA,EAAS,SAAS,EAAE,EAAE,UAAU,GAAG,CAAC,CAAC;AAE5E,IAAAJ,EAAU,CAAAK,MAAQ,CAAC,GAAGA,GAAM;AAAA,MACxB,IAAAD;AAAA,MACA,SAAAI;AAAA,MACA,UAAAC;AAAA,IAAA,CACH,CAAC;AAAA,EACN,GAAG,CAAA,CAAE;AAEL,SACI,gBAAAC,EAAChB,EAAc,UAAd,EAAuB,OAAOiB,EAAQ,OAAO,EAAE,OAAAJ,EAAA,IAAU,CAACA,CAAK,CAAC,GAC5D,UAAA;AAAA,IAAAV;AAAA,IAED,gBAAAe,EAACC,GAAA,EAAc,QAAAf,GACV,UAAAC,EAAO,IAAI,CAAC,EAAE,IAAAK,GAAI,SAAAI,GAAS,UAAAC,EAAA,MACxB,gBAAAG;AAAA,MAACE;AAAA,MAAA;AAAA,QAEG,IAAAV;AAAA,QACA,UAAAK;AAAA,QACA,SAAS,MAAMP,EAAYE,CAAE;AAAA,QAE5B,UAAAI;AAAA,MAAA;AAAA,MALIJ;AAAA,IAAA,CAOZ,EAAA,CACL;AAAA,EAAA,GACJ;AAER;AACAR,EAAe,cAAc;AAGtB,MAAMmB,IAAY,MAAqB;AAC1C,QAAMC,IAAUC,EAAWvB,CAAa;AAExC,MAAI,CAACsB;AACD,UAAM,IAAI,MAAM,gDAAgD;AAGpE,SAAOA,EAAQ;AACnB;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ToastsWrapper.d.ts","sourceRoot":"","sources":["../../../../src/components/Toast/ToastsWrapper/ToastsWrapper.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,sBAAsB,CAAC;AAM9B,MAAM,WAAW,wBAAwB;IACrC,MAAO,CAAC,EAAG,KAAK,GAAG,QAAQ,CAAC;CAC/B;AAED,MAAM,MAAM,wBAAwB,GAAG,cAAc,CAAC;AACtD,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,wBAAwB,CAAC,GACzE,wBAAwB,CAAC;AAG7B,eAAO,MAAM,aAAa,sIA2BzB,CAAC"}
1
+ {"version":3,"file":"ToastsWrapper.d.ts","sourceRoot":"","sources":["../../../../src/components/Toast/ToastsWrapper/ToastsWrapper.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,sBAAsB,CAAC;AAM9B,MAAM,WAAW,wBAAwB;IACrC,MAAO,CAAC,EAAG,KAAK,GAAG,QAAQ,CAAC;CAC/B;AAED,MAAM,MAAM,wBAAwB,GAAG,cAAc,CAAC;AACtD,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,wBAAwB,CAAC,GACzE,wBAAwB,CAAC;AAG7B,eAAO,MAAM,aAAa,sIAyBzB,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { jsx as s } from "react/jsx-runtime";
3
+ import t from "react";
4
+ /* empty css */
5
+ import { Element as p } from "../../Element/Element.js";
6
+ const n = t.forwardRef(
7
+ ({
8
+ anchor: o = "top",
9
+ children: r,
10
+ ...a
11
+ }, e) => t.Children.count(r) === 0 ? null : /* @__PURE__ */ s(
12
+ p,
13
+ {
14
+ as: "section",
15
+ "data-toasts-wrapper": !0,
16
+ ref: e,
17
+ classNames: [o],
18
+ "aria-label": "Toasts",
19
+ ...a,
20
+ children: r
21
+ }
22
+ )
23
+ );
24
+ n.displayName = "ToastsWrapper";
25
+ export {
26
+ n as ToastsWrapper
27
+ };
28
+ //# sourceMappingURL=ToastsWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToastsWrapper.js","sources":["../../../../src/components/Toast/ToastsWrapper/ToastsWrapper.tsx"],"sourcesContent":["// REACT CORE ==========================================================================================================\nimport React from \"react\";\n\n// ELEMENT =============================================================================================================\nimport { CommonAndHTMLProps } from \"../../Element/constants\";\n\n// STYLES ==============================================================================================================\nimport \"./toasts-wrapper.css\";\n\n// OTHER ===============================================================================================================\nimport { Element } from \"$element\";\n\n// prettier-ignore\nexport interface ToastsWrapperCustomProps {\n anchor ? : \"top\" | \"bottom\";\n}\n\nexport type ToastsWrapperElementType = HTMLDivElement;\nexport type ToastsWrapperProps = CommonAndHTMLProps<ToastsWrapperElementType> &\n ToastsWrapperCustomProps;\n\n// COMPONENT ///////////////////////////////////////////////////////////////////////////////////////////////////////////\nexport const ToastsWrapper = React.forwardRef(\n (\n {\n anchor = \"top\",\n children,\n ...props\n }: ToastsWrapperProps,\n ref: React.Ref<ToastsWrapperElementType>\n ) => {\n const childrenCount = React.Children.count(children);\n if (childrenCount === 0) return null;\n\n return (\n <Element<ToastsWrapperElementType>\n as=\"section\"\n data-toasts-wrapper\n ref={ref}\n classNames={[anchor]}\n aria-label=\"Toasts\"\n {...props}\n >\n {children}\n </Element>\n );\n }\n);\nToastsWrapper.displayName = \"ToastsWrapper\";\n"],"names":["ToastsWrapper","React","anchor","children","props","ref","jsx","Element"],"mappings":";;;;AAsBO,MAAMA,IAAgBC,EAAM;AAAA,EAC/B,CACI;AAAA,IACI,QAAAC,IAAS;AAAA,IACT,UAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GAEPC,MAEsBJ,EAAM,SAAS,MAAME,CAAQ,MAC7B,IAAU,OAG5B,gBAAAG;AAAA,IAACC;AAAA,IAAA;AAAA,MACG,IAAG;AAAA,MACH,uBAAmB;AAAA,MACnB,KAAAF;AAAA,MACA,YAAY,CAACH,CAAM;AAAA,MACnB,cAAW;AAAA,MACV,GAAGE;AAAA,MAEH,UAAAD;AAAA,IAAA;AAAA,EAAA;AAIjB;AACAH,EAAc,cAAc;"}
@@ -9,6 +9,6 @@ export interface TooltipProps {
9
9
  position?: Position;
10
10
  zIndex?: number;
11
11
  }
12
- export declare const Tooltip: ({ children, isTooltipFor, showOn, position, zIndex, }: TooltipProps) => null;
12
+ export declare const Tooltip: ({ children, isTooltipFor, showOn, position, zIndex, }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
13
13
  export {};
14
14
  //# sourceMappingURL=Tooltip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AACA,OAAc,EAAqB,SAAS,EAAE,MAAM,OAAO,CAAC;AAI5D,OAAO,eAAe,CAAC;AAGvB,KAAK,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AACpD,KAAK,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAShC,MAAM,WAAW,YAAY;IACzB,QAAQ,EAAO,SAAS,CAAC;IACzB,YAAY,EAAG,MAAM,CAAC;IACtB,MAAW,CAAC,EAAG,MAAM,CAAC;IACtB,QAAW,CAAC,EAAG,QAAQ,CAAC;IACxB,MAAW,CAAC,EAAG,MAAM,CAAC;CACzB;AAuPD,eAAO,MAAM,OAAO,GAAI,uDAMrB,YAAY,SAuCd,CAAC"}
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AACA,OAAc,EAAoB,SAAS,EAAE,MAAM,OAAO,CAAC;AAG3D,OAAO,eAAe,CAAC;AAGvB,KAAK,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AACpD,KAAK,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAEhC,MAAM,WAAW,YAAY;IACzB,QAAQ,EAAO,SAAS,CAAC;IACzB,YAAY,EAAG,MAAM,CAAC;IACtB,MAAW,CAAC,EAAG,MAAM,CAAC;IACtB,QAAW,CAAC,EAAG,QAAQ,CAAC;IACxB,MAAW,CAAC,EAAG,MAAM,CAAC;CACzB;AAOD,eAAO,MAAM,OAAO,GAAI,uDAMrB,YAAY,4CAqFd,CAAC"}
@@ -0,0 +1,62 @@
1
+ "use client";
2
+ import { jsx as L } from "react/jsx-runtime";
3
+ import { useId as y, useEffect as g } from "react";
4
+ /* empty css */
5
+ const P = ({
6
+ children: h,
7
+ isTooltipFor: p,
8
+ showOn: c = "hover",
9
+ position: f = "top",
10
+ zIndex: m
11
+ }) => {
12
+ const u = y(), r = `tooltip-${u.replace(/:/g, "")}`, i = `--anchor-${u.replace(/:/g, "")}`;
13
+ return g(() => {
14
+ const e = document.getElementById(p), t = document.getElementById(r);
15
+ if (!e || !t) return;
16
+ e.style.setProperty("anchor-name", i), e.setAttribute("aria-describedby", r);
17
+ const n = () => {
18
+ t.matches(":popover-open") || t.showPopover();
19
+ }, o = () => {
20
+ t.matches(":popover-open") && t.hidePopover();
21
+ }, l = () => t.matches(":popover-open") ? o() : n(), a = [];
22
+ if (c === "hover")
23
+ e.addEventListener("mouseenter", n), e.addEventListener("mouseleave", o), e.addEventListener("focusin", n), e.addEventListener("focusout", o), a.push(() => {
24
+ e.removeEventListener("mouseenter", n), e.removeEventListener("mouseleave", o), e.removeEventListener("focusin", n), e.removeEventListener("focusout", o);
25
+ });
26
+ else {
27
+ e.addEventListener("click", l);
28
+ const s = (d) => {
29
+ const v = d.target;
30
+ v === e || e.contains(v) || t.contains(v) || o();
31
+ }, E = (d) => {
32
+ d.key === "Escape" && o();
33
+ };
34
+ document.addEventListener("click", s), document.addEventListener("keydown", E), a.push(() => {
35
+ e.removeEventListener("click", l), document.removeEventListener("click", s), document.removeEventListener("keydown", E);
36
+ });
37
+ }
38
+ return () => {
39
+ a.forEach((s) => s()), e.style.removeProperty("anchor-name"), e.removeAttribute("aria-describedby");
40
+ };
41
+ }, [p, c, r, i]), /* @__PURE__ */ L(
42
+ "div",
43
+ {
44
+ id: r,
45
+ "data-tooltip": !0,
46
+ "data-position": f,
47
+ "data-show-on": c,
48
+ popover: "manual",
49
+ role: "tooltip",
50
+ style: {
51
+ // CSS anchor positioning: tie this popover to the target's anchor-name.
52
+ positionAnchor: i,
53
+ ...m !== void 0 ? { zIndex: m } : {}
54
+ },
55
+ children: h
56
+ }
57
+ );
58
+ };
59
+ export {
60
+ P as Tooltip
61
+ };
62
+ //# sourceMappingURL=Tooltip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.js","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["// REACT CORE ==========================================================================================================\nimport React, { useEffect, useId, ReactNode } from \"react\";\n\n// STYLES ==============================================================================================================\nimport \"./tooltip.css\";\n\n// TYPES ===============================================================================================================\ntype Position = \"top\" | \"bottom\" | \"left\" | \"right\";\ntype ShowOn = \"click\" | \"hover\";\n\nexport interface TooltipProps {\n children : ReactNode;\n isTooltipFor : string;\n showOn ? : ShowOn;\n position ? : Position;\n zIndex ? : number;\n}\n\n// COMPONENT ===========================================================================================================\n// Each Tooltip is its own popover. Show/hide goes through the native popover\n// API; placement uses CSS anchor positioning (anchor-name / position-anchor +\n// position-area), so there's no JS getBoundingClientRect math, no scroll/resize\n// listeners, no shared singleton DOM node.\nexport const Tooltip = ({\n children,\n isTooltipFor,\n showOn = \"hover\",\n position = \"top\",\n zIndex,\n}: TooltipProps) => {\n const reactId = useId();\n const tooltipId = `tooltip-${reactId.replace(/:/g, \"\")}`;\n const anchorName = `--anchor-${reactId.replace(/:/g, \"\")}`;\n\n useEffect(() => {\n const target = document.getElementById(isTooltipFor);\n const tooltip = document.getElementById(tooltipId) as HTMLElement | null;\n if (!target || !tooltip) return;\n\n // Brand the target as the anchor. We set this dynamically rather than\n // requiring the caller to add the anchor-name themselves.\n target.style.setProperty(\"anchor-name\", anchorName);\n // Link the target to the tooltip for assistive tech (WCAG 4.1.2).\n target.setAttribute(\"aria-describedby\", tooltipId);\n\n const show = () => {\n if (!tooltip.matches(\":popover-open\")) tooltip.showPopover();\n };\n const hide = () => {\n if (tooltip.matches(\":popover-open\")) tooltip.hidePopover();\n };\n const toggle = () => (tooltip.matches(\":popover-open\") ? hide() : show());\n\n const cleanups: Array<() => void> = [];\n\n if (showOn === \"hover\") {\n // Pointer + keyboard parity. focusin/focusout cover keyboard users\n // who tab to the target.\n target.addEventListener(\"mouseenter\", show);\n target.addEventListener(\"mouseleave\", hide);\n target.addEventListener(\"focusin\", show);\n target.addEventListener(\"focusout\", hide);\n cleanups.push(() => {\n target.removeEventListener(\"mouseenter\", show);\n target.removeEventListener(\"mouseleave\", hide);\n target.removeEventListener(\"focusin\", show);\n target.removeEventListener(\"focusout\", hide);\n });\n } else {\n // click: toggle on target click, close on click anywhere else\n // (manual light-dismiss because popover=\"auto\" interacts badly with\n // re-toggling from the same target).\n target.addEventListener(\"click\", toggle);\n const handleOutside = (e: MouseEvent) => {\n const node = e.target as Node;\n if (node === target || target.contains(node) || tooltip.contains(node)) return;\n hide();\n };\n const handleEscape = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") hide();\n };\n document.addEventListener(\"click\", handleOutside);\n document.addEventListener(\"keydown\", handleEscape);\n cleanups.push(() => {\n target.removeEventListener(\"click\", toggle);\n document.removeEventListener(\"click\", handleOutside);\n document.removeEventListener(\"keydown\", handleEscape);\n });\n }\n\n return () => {\n cleanups.forEach((fn) => fn());\n target.style.removeProperty(\"anchor-name\");\n target.removeAttribute(\"aria-describedby\");\n };\n }, [ isTooltipFor, showOn, tooltipId, anchorName ]);\n\n return (\n <div\n id={tooltipId}\n data-tooltip\n data-position={position}\n data-show-on={showOn}\n popover=\"manual\"\n role=\"tooltip\"\n style={{\n // CSS anchor positioning: tie this popover to the target's anchor-name.\n [\"positionAnchor\" as keyof React.CSSProperties]: anchorName,\n ...(zIndex !== undefined ? { zIndex } : {}),\n } as React.CSSProperties}\n >\n {children}\n </div>\n );\n};\n"],"names":["Tooltip","children","isTooltipFor","showOn","position","zIndex","reactId","useId","tooltipId","anchorName","useEffect","target","tooltip","show","hide","toggle","cleanups","handleOutside","e","node","handleEscape","fn","jsx"],"mappings":";;;AAuBO,MAAMA,IAAU,CAAC;AAAA,EACpB,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,QAAAC,IAAW;AAAA,EACX,UAAAC,IAAW;AAAA,EACX,QAAAC;AACJ,MAAoB;AAChB,QAAMC,IAAYC,EAAA,GACZC,IAAY,WAAWF,EAAQ,QAAQ,MAAM,EAAE,CAAC,IAChDG,IAAa,YAAYH,EAAQ,QAAQ,MAAM,EAA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B,SAASI,CAAM,GAC1C,SAAS,oBAAoB,SAASE,CAAa,GACnD,SAAS,oBAAoB,WAAWG,CAAY;AAAA,MACxD,CAAC;AAAA,IACL;AAEA,WAAO,MAAM;AACT,MAAAJ,EAAS,QAAQ,CAACK,MAAOA,EAAA,CAAI,GAC7BV,EAAO,MAAM,eAAe,aAAa,GACzCA,EAAO,gBAAgB,kBAAkB;AAAA,IAC7C;AAAA,EACJ,GAAG,CAAET,GAAcC,GAAQK,GAAWC,CAAW,CAAC,GAG9C,gBAAAa;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,IAAId;AAAA,MACJ,gBAAY;AAAA,MACZ,iBAAeJ;AAAA,MACf,gBAAcD;AAAA,MACd,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,OAAO;AAAA;AAAA,QAEF,gBAAgDM;AAAA,QACjD,GAAIJ,MAAW,SAAY,EAAE,QAAAA,MAAW,CAAA;AAAA,MAAC;AAAA,MAG5C,UAAAJ;AAAA,IAAA;AAAA,EAAA;AAGb;"}
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import { jsx as d } from "react/jsx-runtime";
3
+ import s from "react";
4
+ import { Element as t } from "../Element/Element.js";
5
+ const i = s.forwardRef(
6
+ ({ fontStyle: a, weight: e, align: n, ...o }, f) => {
7
+ let r = [];
8
+ return e && r.push(`weight-${e}`), a && r.push(`font-${a}`), n && r.push(`text-${n}`), /* @__PURE__ */ d(t, { ref: f, classNames: r, ...o });
9
+ }
10
+ ), m = s.forwardRef((a, e) => /* @__PURE__ */ d(i, { as: "h1", ref: e, ...a }));
11
+ m.displayName = "Heading1";
12
+ const p = s.forwardRef((a, e) => /* @__PURE__ */ d(i, { as: "h2", ref: e, ...a }));
13
+ p.displayName = "Heading2";
14
+ const H = s.forwardRef((a, e) => /* @__PURE__ */ d(i, { as: "h3", ref: e, ...a }));
15
+ H.displayName = "Heading3";
16
+ const g = s.forwardRef((a, e) => /* @__PURE__ */ d(i, { as: "h4", ref: e, ...a }));
17
+ g.displayName = "Heading4";
18
+ const c = s.forwardRef((a, e) => /* @__PURE__ */ d(i, { as: "h5", ref: e, ...a }));
19
+ c.displayName = "Heading5";
20
+ const h = s.forwardRef((a, e) => /* @__PURE__ */ d(i, { as: "h6", ref: e, ...a }));
21
+ h.displayName = "Heading6";
22
+ export {
23
+ m as Heading1,
24
+ p as Heading2,
25
+ H as Heading3,
26
+ g as Heading4,
27
+ c as Heading5,
28
+ h as Heading6
29
+ };
30
+ //# sourceMappingURL=Heading.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Heading.js","sources":["../../../src/components/Typography/Heading.tsx"],"sourcesContent":["// FRAMEWORK ===========================================================================================================\nimport React from \"react\";\n\n// FICTOAN =============================================================================================================\nimport { Element } from \"../Element\";\n\n// TYPES ===============================================================================================================\nimport { CommonAndHTMLProps, WeightTypes } from \"../Element/constants\";\n\n// prettier-ignore\ninterface HeadingBaseProps {\n as ? : \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n fontStyle ? : \"sans-serif\" | \"serif\" | \"monospace\";\n weight ? : WeightTypes;\n align ? : \"left\" | \"centre\" | \"center\" | \"right\";\n}\n\nexport type HeadingElementType = HTMLHeadingElement;\nexport type HeadingProps = Omit<CommonAndHTMLProps<HeadingElementType>, keyof HeadingBaseProps> & HeadingBaseProps;\n\n// COMPONENT ///////////////////////////////////////////////////////////////////////////////////////////////////////////\nconst Heading = React.forwardRef(\n ({ fontStyle, weight, align, ...props }: HeadingProps, ref: React.Ref<HeadingElementType>) => {\n let classNames = [];\n\n if (weight) {\n classNames.push(`weight-${weight}`);\n }\n\n if (fontStyle) {\n classNames.push(`font-${fontStyle}`);\n }\n\n if (align) {\n classNames.push(`text-${align}`);\n }\n\n return <Element<HeadingElementType> ref={ref} classNames={classNames} {...props} />;\n }\n);\n\nexport const Heading1 = React.forwardRef((props: HeadingProps, ref: React.Ref<HeadingElementType>) => (\n <Heading as=\"h1\" ref={ref} {...props} />\n));\nHeading1.displayName = \"Heading1\";\n\nexport const Heading2 = React.forwardRef((props: HeadingProps, ref: React.Ref<HeadingElementType>) => (\n <Heading as=\"h2\" ref={ref} {...props} />\n));\nHeading2.displayName = \"Heading2\";\n\nexport const Heading3 = React.forwardRef((props: HeadingProps, ref: React.Ref<HeadingElementType>) => (\n <Heading as=\"h3\" ref={ref} {...props} />\n));\nHeading3.displayName = \"Heading3\";\n\nexport const Heading4 = React.forwardRef((props: HeadingProps, ref: React.Ref<HeadingElementType>) => (\n <Heading as=\"h4\" ref={ref} {...props} />\n));\nHeading4.displayName = \"Heading4\";\n\nexport const Heading5 = React.forwardRef((props: HeadingProps, ref: React.Ref<HeadingElementType>) => (\n <Heading as=\"h5\" ref={ref} {...props} />\n));\nHeading5.displayName = \"Heading5\";\n\nexport const Heading6 = React.forwardRef((props: HeadingProps, ref: React.Ref<HeadingElementType>) => (\n <Heading as=\"h6\" ref={ref} {...props} />\n));\nHeading6.displayName = \"Heading6\";\n"],"names":["Heading","React","fontStyle","weight","align","props","ref","classNames","jsx","Element","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6"],"mappings":";;;AAqBA,MAAMA,IAAUC,EAAM;AAAA,EAClB,CAAC,EAAE,WAAAC,GAAW,QAAAC,GAAQ,OAAAC,GAAO,GAAGC,EAAA,GAAuBC,MAAuC;AAC1F,QAAIC,IAAa,CAAA;AAEjB,WAAIJ,KACAI,EAAW,KAAK,UAAUJ,CAAM,EAAE,GAGlCD,KACAK,EAAW,KAAK,QAAQL,CAAS,EAAE,GAGnCE,KACAG,EAAW,KAAK,QAAQH,CAAK,EAAE,GAG5B,gBAAAI,EAACC,GAAA,EAA4B,KAAAH,GAAU,YAAAC,GAAyB,GAAGF,GAAO;AAAA,EACrF;AACJ,GAEaK,IAAWT,EAAM,WAAW,CAACI,GAAqBC,MAC3D,gBAAAE,EAACR,GAAA,EAAQ,IAAG,MAAK,KAAAM,GAAW,GAAGD,GAAO,CACzC;AACDK,EAAS,cAAc;AAEhB,MAAMC,IAAWV,EAAM,WAAW,CAACI,GAAqBC,MAC3D,gBAAAE,EAACR,GAAA,EAAQ,IAAG,MAAK,KAAAM,GAAW,GAAGD,GAAO,CACzC;AACDM,EAAS,cAAc;AAEhB,MAAMC,IAAWX,EAAM,WAAW,CAACI,GAAqBC,MAC3D,gBAAAE,EAACR,GAAA,EAAQ,IAAG,MAAK,KAAAM,GAAW,GAAGD,GAAO,CACzC;AACDO,EAAS,cAAc;AAEhB,MAAMC,IAAWZ,EAAM,WAAW,CAACI,GAAqBC,MAC3D,gBAAAE,EAACR,GAAA,EAAQ,IAAG,MAAK,KAAAM,GAAW,GAAGD,GAAO,CACzC;AACDQ,EAAS,cAAc;AAEhB,MAAMC,IAAWb,EAAM,WAAW,CAACI,GAAqBC,MAC3D,gBAAAE,EAACR,GAAA,EAAQ,IAAG,MAAK,KAAAM,GAAW,GAAGD,GAAO,CACzC;AACDS,EAAS,cAAc;AAEhB,MAAMC,IAAWd,EAAM,WAAW,CAACI,GAAqBC,MAC3D,gBAAAE,EAACR,GAAA,EAAQ,IAAG,MAAK,KAAAM,GAAW,GAAGD,GAAO,CACzC;AACDU,EAAS,cAAc;"}
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { jsx as i } from "react/jsx-runtime";
3
+ import u from "react";
4
+ import { Element as x } from "../Element/Element.js";
5
+ const a = u.forwardRef(
6
+ ({ weight: e, size: s, fontStyle: p, align: r, isSubtext: f, ...m }, o) => {
7
+ let t = [];
8
+ return e && t.push(`weight-${e}`), s && t.push(`text-${s}`), p && t.push(`font-${p}`), f && t.push("sub-text"), r && t.push(`text-${r}`), /* @__PURE__ */ i(x, { as: "p", ref: o, classNames: t, ...m });
9
+ }
10
+ );
11
+ a.displayName = "Text";
12
+ export {
13
+ a as Text
14
+ };
15
+ //# sourceMappingURL=Text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Text.js","sources":["../../../src/components/Typography/Text.tsx"],"sourcesContent":["// REACT CORE ==========================================================================================================\nimport React from \"react\";\n\n// LOCAL COMPONENTS ====================================================================================================\nimport { CommonAndHTMLProps, SpacingTypes, WeightTypes } from \"../Element/constants\";\nimport { Element } from \"$element\";\n\n// prettier-ignore\nexport interface TextCustomProps {\n fontStyle ? : \"sans-serif\" | \"serif\" | \"monospace\";\n weight ? : WeightTypes;\n size ? : SpacingTypes;\n align ? : \"left\" | \"centre\" | \"center\" | \"right\";\n isSubtext ? : boolean;\n}\n\nexport type TextElementType = HTMLParagraphElement;\nexport type TextProps = Omit<CommonAndHTMLProps<TextElementType>, keyof TextCustomProps> & TextCustomProps;\n\nexport const Text = React.forwardRef(\n (\n {weight, size, fontStyle, align, isSubtext, ...props} : TextProps,\n ref : React.Ref<TextElementType>,\n ) => {\n let classNames = [];\n\n if (weight) {\n classNames.push(`weight-${weight}`);\n }\n\n if (size) {\n classNames.push(`text-${size}`);\n }\n\n if (fontStyle) {\n classNames.push(`font-${fontStyle}`);\n }\n\n if (isSubtext) {\n classNames.push(\"sub-text\");\n }\n\n if (align) {\n classNames.push(`text-${align}`);\n }\n\n return <Element<TextElementType> as=\"p\" ref={ref} classNames={classNames} {...props} />;\n },\n);\nText.displayName = \"Text\";\n"],"names":["Text","React","weight","size","fontStyle","align","isSubtext","props","ref","classNames","Element"],"mappings":";;;AAmBO,MAAMA,IAAOC,EAAM;AAAA,EACtB,CACI,EAAC,QAAAC,GAAQ,MAAAC,GAAM,WAAAC,GAAW,OAAAC,GAAO,WAAAC,GAAW,GAAGC,EAAA,GAC/CC,MACC;AACD,QAAIC,IAAa,CAAA;AAEjB,WAAIP,KACAO,EAAW,KAAK,UAAUP,CAAM,EAAE,GAGlCC,KACAM,EAAW,KAAK,QAAQN,CAAI,EAAE,GAG9BC,KACAK,EAAW,KAAK,QAAQL,CAAS,EAAE,GAGnCE,KACAG,EAAW,KAAK,UAAU,GAG1BJ,KACAI,EAAW,KAAK,QAAQJ,CAAK,EAAE,qBAG3BK,GAAA,EAAyB,IAAG,KAAI,KAAAF,GAAU,YAAAC,GAAyB,GAAGF,GAAO;AAAA,EACzF;AACJ;AACAP,EAAK,cAAc;"}