@intlayer/design-system 8.7.11 → 8.7.13
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/README.md +1 -1
- package/dist/esm/components/DictionaryEditor/NodeWrapper/BooleanWrapper.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +2 -0
- package/dist/esm/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +1 -1
- package/dist/esm/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
- package/dist/esm/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +1 -1
- package/dist/esm/components/Form/elements/SwitchSelectorElement.mjs +1 -1
- package/dist/esm/components/IDE/Code.mjs +4 -1
- package/dist/esm/components/IDE/Code.mjs.map +1 -1
- package/dist/esm/components/IDE/CodeBlockClient.mjs.map +1 -1
- package/dist/esm/components/IDE/CodeBlockHighlight.mjs +2 -2
- package/dist/esm/components/IDE/CodeBlockHighlight.mjs.map +1 -1
- package/dist/esm/components/IDE/CodeBlockShiki.mjs +1 -1
- package/dist/esm/components/IDE/CodeBlockShiki.mjs.map +1 -1
- package/dist/esm/components/Input/Checkbox.mjs +13 -13
- package/dist/esm/components/Input/Checkbox.mjs.map +1 -1
- package/dist/esm/components/Link/Link.mjs +3 -3
- package/dist/esm/components/Link/Link.mjs.map +1 -1
- package/dist/esm/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs +2 -1
- package/dist/esm/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs.map +1 -1
- package/dist/esm/components/Navbar/index.mjs.map +1 -1
- package/dist/esm/components/Popover/static.mjs +1 -1
- package/dist/esm/components/Popover/static.mjs.map +1 -1
- package/dist/esm/components/SwitchSelector/SwitchSelector.mjs +127 -0
- package/dist/esm/components/SwitchSelector/SwitchSelector.mjs.map +1 -0
- package/dist/esm/components/SwitchSelector/VerticalSwitchSelector.mjs +105 -0
- package/dist/esm/components/SwitchSelector/VerticalSwitchSelector.mjs.map +1 -0
- package/dist/esm/components/SwitchSelector/index.mjs +3 -145
- package/dist/esm/components/SwitchSelector/useSwitchSelector.mjs +44 -0
- package/dist/esm/components/SwitchSelector/useSwitchSelector.mjs.map +1 -0
- package/dist/esm/components/index.mjs +3 -2
- package/dist/esm/hooks/index.mjs +2 -2
- package/dist/esm/hooks/reactQuery.mjs +41 -12
- package/dist/esm/hooks/reactQuery.mjs.map +1 -1
- package/dist/esm/hooks/useAuth/useOAuth2.mjs +3 -3
- package/dist/esm/hooks/useAuth/useOAuth2.mjs.map +1 -1
- package/dist/esm/hooks/useAuth/useSession.mjs +7 -5
- package/dist/esm/hooks/useAuth/useSession.mjs.map +1 -1
- package/dist/esm/hooks/useItemSelector.mjs +41 -23
- package/dist/esm/hooks/useItemSelector.mjs.map +1 -1
- package/dist/esm/providers/ReactQueryProvider.mjs +56 -21
- package/dist/esm/providers/ReactQueryProvider.mjs.map +1 -1
- package/dist/types/components/Badge/index.d.ts +2 -2
- package/dist/types/components/Button/Button.d.ts +4 -4
- package/dist/types/components/CollapsibleTable/CollapsibleTable.d.ts +2 -2
- package/dist/types/components/Container/index.d.ts +6 -6
- package/dist/types/components/IDE/Code.d.ts +2 -2
- package/dist/types/components/IDE/Code.d.ts.map +1 -1
- package/dist/types/components/IDE/CodeBlockClient.d.ts +3 -3
- package/dist/types/components/IDE/CodeBlockClient.d.ts.map +1 -1
- package/dist/types/components/IDE/CodeBlockHighlight.d.ts +2 -1
- package/dist/types/components/IDE/CodeBlockHighlight.d.ts.map +1 -1
- package/dist/types/components/IDE/CodeBlockShiki.d.ts +2 -2
- package/dist/types/components/IDE/CodeBlockShiki.d.ts.map +1 -1
- package/dist/types/components/Input/Checkbox.d.ts +1 -1
- package/dist/types/components/Input/Checkbox.d.ts.map +1 -1
- package/dist/types/components/Link/Link.d.ts +3 -3
- package/dist/types/components/Navbar/index.d.ts.map +1 -1
- package/dist/types/components/SwitchSelector/SwitchSelector.d.ts +56 -0
- package/dist/types/components/SwitchSelector/SwitchSelector.d.ts.map +1 -0
- package/dist/types/components/SwitchSelector/VerticalSwitchSelector.d.ts +22 -0
- package/dist/types/components/SwitchSelector/VerticalSwitchSelector.d.ts.map +1 -0
- package/dist/types/components/SwitchSelector/index.d.ts +3 -74
- package/dist/types/components/SwitchSelector/useSwitchSelector.d.ts +27 -0
- package/dist/types/components/SwitchSelector/useSwitchSelector.d.ts.map +1 -0
- package/dist/types/components/Tag/index.d.ts +2 -2
- package/dist/types/components/index.d.ts +3 -2
- package/dist/types/hooks/index.d.ts +2 -2
- package/dist/types/hooks/reactQuery.d.ts +4 -1
- package/dist/types/hooks/reactQuery.d.ts.map +1 -1
- package/dist/types/hooks/useAuth/useOAuth2.d.ts.map +1 -1
- package/dist/types/providers/ReactQueryProvider.d.ts +5 -2
- package/dist/types/providers/ReactQueryProvider.d.ts.map +1 -1
- package/package.json +24 -21
- package/dist/esm/components/SwitchSelector/index.mjs.map +0 -1
- package/dist/types/components/SwitchSelector/index.d.ts.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/hooks/useItemSelector.ts
|
|
6
6
|
const selectorDefault = (option) => option?.getAttribute("aria-selected") === "true";
|
|
@@ -24,47 +24,60 @@ const useItemSelector = (optionsRefs, { selector = selectorDefault, isHoverable
|
|
|
24
24
|
}
|
|
25
25
|
} else targetElement = optionsRefs.current.find(selector) ?? null;
|
|
26
26
|
if (!targetElement) {
|
|
27
|
-
if (orientation === "vertical")
|
|
28
|
-
const verticalPrev =
|
|
27
|
+
if (orientation === "vertical") {
|
|
28
|
+
const verticalPrev = lastPositionRef.current;
|
|
29
29
|
const newPosition = {
|
|
30
30
|
top: verticalPrev?.top ?? 0,
|
|
31
31
|
height: verticalPrev?.height ?? 0,
|
|
32
32
|
opacity: 0
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
if (verticalPrev?.opacity !== 0) {
|
|
35
|
+
setChoiceIndicatorPosition(newPosition);
|
|
36
|
+
lastPositionRef.current = newPosition;
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
const horizontalPrev = lastPositionRef.current;
|
|
39
40
|
const newPosition = {
|
|
40
41
|
left: horizontalPrev?.left ?? 0,
|
|
41
42
|
width: horizontalPrev?.width ?? 0,
|
|
42
43
|
opacity: 0
|
|
43
44
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
if (horizontalPrev?.opacity !== 0) {
|
|
46
|
+
setChoiceIndicatorPosition(newPosition);
|
|
47
|
+
lastPositionRef.current = newPosition;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
47
50
|
return;
|
|
48
51
|
}
|
|
49
52
|
if (orientation === "vertical") {
|
|
53
|
+
const top = targetElement.offsetTop;
|
|
54
|
+
const height = targetElement.offsetHeight;
|
|
50
55
|
const newPosition = {
|
|
51
|
-
top
|
|
52
|
-
height
|
|
56
|
+
top,
|
|
57
|
+
height,
|
|
53
58
|
opacity: 1
|
|
54
59
|
};
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
const prev = lastPositionRef.current;
|
|
61
|
+
if (!prev || prev.top !== top || prev.height !== height || prev.opacity !== 1) {
|
|
62
|
+
setChoiceIndicatorPosition(newPosition);
|
|
63
|
+
lastPositionRef.current = newPosition;
|
|
64
|
+
}
|
|
57
65
|
} else {
|
|
66
|
+
const left = targetElement.offsetLeft;
|
|
67
|
+
const width = targetElement.offsetWidth;
|
|
58
68
|
const newPosition = {
|
|
59
|
-
left
|
|
60
|
-
width
|
|
69
|
+
left,
|
|
70
|
+
width,
|
|
61
71
|
opacity: 1
|
|
62
72
|
};
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
const prev = lastPositionRef.current;
|
|
74
|
+
if (!prev || prev.left !== left || prev.width !== width || prev.opacity !== 1) {
|
|
75
|
+
setChoiceIndicatorPosition(newPosition);
|
|
76
|
+
lastPositionRef.current = newPosition;
|
|
77
|
+
}
|
|
65
78
|
}
|
|
66
79
|
};
|
|
67
|
-
|
|
80
|
+
useLayoutEffect(() => {
|
|
68
81
|
calculatePosition();
|
|
69
82
|
window.addEventListener("resize", calculatePosition);
|
|
70
83
|
window.addEventListener("DOMContentLoaded", calculatePosition);
|
|
@@ -72,14 +85,18 @@ const useItemSelector = (optionsRefs, { selector = selectorDefault, isHoverable
|
|
|
72
85
|
optionsRefs.current.forEach((option) => {
|
|
73
86
|
if (option) {
|
|
74
87
|
const observer = new MutationObserver((mutations) => {
|
|
75
|
-
for (const mutation of mutations) if (mutation.type === "attributes" && mutation.attributeName === "aria-selected") {
|
|
88
|
+
for (const mutation of mutations) if (mutation.type === "attributes" && (mutation.attributeName === "aria-selected" || mutation.attributeName === "data-active" || mutation.attributeName === "data-indicator")) {
|
|
76
89
|
calculatePosition();
|
|
77
90
|
break;
|
|
78
91
|
}
|
|
79
92
|
});
|
|
80
93
|
observer.observe(option, {
|
|
81
94
|
attributes: true,
|
|
82
|
-
attributeFilter: [
|
|
95
|
+
attributeFilter: [
|
|
96
|
+
"aria-selected",
|
|
97
|
+
"data-active",
|
|
98
|
+
"data-indicator"
|
|
99
|
+
]
|
|
83
100
|
});
|
|
84
101
|
mutationObservers.push(observer);
|
|
85
102
|
}
|
|
@@ -133,7 +150,8 @@ const useItemSelector = (optionsRefs, { selector = selectorDefault, isHoverable
|
|
|
133
150
|
selector,
|
|
134
151
|
hoveredItem,
|
|
135
152
|
itemsLength,
|
|
136
|
-
orientation
|
|
153
|
+
orientation,
|
|
154
|
+
isHoverable
|
|
137
155
|
]);
|
|
138
156
|
return {
|
|
139
157
|
choiceIndicatorPosition,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useItemSelector.mjs","names":[],"sources":["../../../src/hooks/useItemSelector.ts"],"sourcesContent":["'use client';\n\nimport { type RefObject, useEffect, useRef, useState } from 'react';\n\nexport type ItemSelectorOrientation = 'horizontal' | 'vertical';\n\ntype HorizontalStyleState = {\n left: number;\n width: number;\n opacity: number;\n};\n\ntype VerticalStyleState = {\n top: number;\n height: number;\n opacity: number;\n};\n\ntype StyleState = HorizontalStyleState | VerticalStyleState;\n\nconst selectorDefault = (option: HTMLElement) =>\n option?.getAttribute('aria-selected') === 'true';\n\ntype Options = {\n selector?: (option: HTMLElement, index: number) => boolean;\n isHoverable?: boolean;\n orientation?: ItemSelectorOrientation;\n};\n\nexport const useItemSelector = (\n optionsRefs: RefObject<HTMLElement[]>,\n {\n selector = selectorDefault,\n isHoverable = false,\n orientation = 'horizontal',\n }: Options = {\n selector: selectorDefault,\n isHoverable: false,\n orientation: 'horizontal',\n }\n) => {\n const [choiceIndicatorPosition, setChoiceIndicatorPosition] =\n useState<StyleState | null>(null);\n\n const [hoveredItem, setHoveredItem] = useState<HTMLElement | null>(null);\n const hideTimeoutRef = useRef<NodeJS.Timeout | null>(null);\n const lastPositionRef = useRef<StyleState | null>(null);\n\n const itemsLength = optionsRefs.current.length;\n\n const calculatePosition = () => {\n let targetElement: HTMLElement | null = null;\n\n if (hoveredItem) {\n targetElement = hoveredItem;\n // Clear any pending hide timeout when hovering over an item\n if (hideTimeoutRef.current) {\n clearTimeout(hideTimeoutRef.current);\n hideTimeoutRef.current = null;\n }\n } else {\n targetElement = optionsRefs.current.find(selector) ?? null;\n }\n\n if (!targetElement) {\n // Keep previous position but set opacity to 0\n if (orientation === 'vertical') {\n setChoiceIndicatorPosition((prev) => {\n const verticalPrev = prev as VerticalStyleState | null;\n const newPosition: VerticalStyleState = {\n top: verticalPrev?.top ?? 0,\n height: verticalPrev?.height ?? 0,\n opacity: 0,\n };\n lastPositionRef.current = newPosition;\n return newPosition;\n });\n } else {\n setChoiceIndicatorPosition((prev) => {\n const horizontalPrev = prev as HorizontalStyleState | null;\n const newPosition: HorizontalStyleState = {\n left: horizontalPrev?.left ?? 0,\n width: horizontalPrev?.width ?? 0,\n opacity: 0,\n };\n lastPositionRef.current = newPosition;\n return newPosition;\n });\n }\n return;\n }\n\n if (orientation === 'vertical') {\n const top = targetElement.offsetTop;\n const height = targetElement.offsetHeight;\n\n const newPosition = {\n top,\n height,\n opacity: 1,\n };\n setChoiceIndicatorPosition(newPosition);\n lastPositionRef.current = newPosition;\n } else {\n const left = targetElement.offsetLeft;\n const width = targetElement.offsetWidth;\n\n const newPosition = {\n left,\n width,\n opacity: 1,\n };\n setChoiceIndicatorPosition(newPosition);\n lastPositionRef.current = newPosition;\n }\n };\n\n useEffect(() => {\n calculatePosition();\n\n // Event listeners for window events\n window.addEventListener('resize', calculatePosition);\n window.addEventListener('DOMContentLoaded', calculatePosition);\n\n // MutationObserver to watch for 'aria-selected' changes\n const mutationObservers: MutationObserver[] = [];\n\n optionsRefs.current.forEach((option) => {\n if (option) {\n const observer = new MutationObserver((mutations) => {\n for (const mutation of mutations) {\n if (\n mutation.type === 'attributes' &&\n mutation.attributeName === 'aria-selected'\n ) {\n calculatePosition();\n break;\n }\n }\n });\n\n observer.observe(option, {\n attributes: true,\n attributeFilter: ['aria-selected'],\n });\n\n mutationObservers.push(observer);\n }\n });\n\n // ResizeObserver to watch for size changes\n const resizeObservers: ResizeObserver[] = [];\n\n const observeSize = (element: HTMLElement) => {\n if (!element) return;\n const resizeObserver = new ResizeObserver(() => {\n calculatePosition();\n });\n resizeObserver.observe(element);\n resizeObservers.push(resizeObserver);\n };\n\n // Observe the selected item\n const selectedItem = optionsRefs.current.find(selector) ?? null;\n\n if (selectedItem) {\n observeSize(selectedItem);\n }\n\n // Observe the hovered item\n if (hoveredItem) {\n observeSize(hoveredItem);\n }\n\n // Add hover event listeners\n const handleMouseEnter = (event: Event) => {\n // Clear any pending hide timeout\n if (hideTimeoutRef.current) {\n clearTimeout(hideTimeoutRef.current);\n hideTimeoutRef.current = null;\n }\n setHoveredItem(event.currentTarget as HTMLElement);\n };\n\n const handleMouseLeave = () => {\n // Clear any existing timeout\n if (hideTimeoutRef.current) {\n clearTimeout(hideTimeoutRef.current);\n }\n\n // Keep the indicator at its current position for 150ms\n // before removing the hovered item\n hideTimeoutRef.current = setTimeout(() => {\n setHoveredItem(null);\n }, 150); // 150ms delay before hiding\n };\n\n if (isHoverable) {\n optionsRefs.current.forEach((option) => {\n option?.addEventListener('mouseenter', handleMouseEnter, {\n passive: true,\n });\n option?.addEventListener('mouseleave', handleMouseLeave, {\n passive: true,\n });\n });\n }\n\n return () => {\n // Clear any pending hide timeout\n if (hideTimeoutRef.current) {\n clearTimeout(hideTimeoutRef.current);\n }\n\n // Cleanup window event listeners\n window.removeEventListener('resize', calculatePosition);\n window.removeEventListener('DOMContentLoaded', calculatePosition);\n\n // Disconnect MutationObservers\n mutationObservers.forEach((observer) => {\n observer.disconnect();\n });\n\n // Disconnect ResizeObservers\n resizeObservers.forEach((observer) => {\n observer.disconnect();\n });\n\n // Remove hover event listeners\n optionsRefs.current.forEach((option) => {\n option?.removeEventListener('mouseenter', handleMouseEnter);\n option?.removeEventListener('mouseleave', handleMouseLeave);\n });\n };\n }, [optionsRefs, selector, hoveredItem, itemsLength, orientation]);\n\n return { choiceIndicatorPosition, calculatePosition, orientation };\n};\n"],"mappings":";;;;;AAoBA,MAAM,mBAAmB,WACvB,QAAQ,aAAa,gBAAgB,KAAK;AAQ5C,MAAa,mBACX,aACA,EACE,WAAW,iBACX,cAAc,OACd,cAAc,iBACH;CACX,UAAU;CACV,aAAa;CACb,aAAa;CACd,KACE;CACH,MAAM,CAAC,yBAAyB,8BAC9B,SAA4B,KAAK;CAEnC,MAAM,CAAC,aAAa,kBAAkB,SAA6B,KAAK;CACxE,MAAM,iBAAiB,OAA8B,KAAK;CAC1D,MAAM,k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AAyB;EAAmB;EAAa"}
|
|
1
|
+
{"version":3,"file":"useItemSelector.mjs","names":[],"sources":["../../../src/hooks/useItemSelector.ts"],"sourcesContent":["'use client';\n\nimport { type RefObject, useLayoutEffect, useRef, useState } from 'react';\n\nexport type ItemSelectorOrientation = 'horizontal' | 'vertical';\n\ntype HorizontalStyleState = {\n left: number;\n width: number;\n opacity: number;\n};\n\ntype VerticalStyleState = {\n top: number;\n height: number;\n opacity: number;\n};\n\ntype StyleState = HorizontalStyleState | VerticalStyleState;\n\nconst selectorDefault = (option: HTMLElement) =>\n option?.getAttribute('aria-selected') === 'true';\n\ntype Options = {\n selector?: (option: HTMLElement, index: number) => boolean;\n isHoverable?: boolean;\n orientation?: ItemSelectorOrientation;\n};\n\nexport const useItemSelector = (\n optionsRefs: RefObject<HTMLElement[]>,\n {\n selector = selectorDefault,\n isHoverable = false,\n orientation = 'horizontal',\n }: Options = {\n selector: selectorDefault,\n isHoverable: false,\n orientation: 'horizontal',\n }\n) => {\n const [choiceIndicatorPosition, setChoiceIndicatorPosition] =\n useState<StyleState | null>(null);\n\n const [hoveredItem, setHoveredItem] = useState<HTMLElement | null>(null);\n const hideTimeoutRef = useRef<NodeJS.Timeout | null>(null);\n const lastPositionRef = useRef<StyleState | null>(null);\n\n const itemsLength = optionsRefs.current.length;\n\n const calculatePosition = () => {\n let targetElement: HTMLElement | null = null;\n\n if (hoveredItem) {\n targetElement = hoveredItem;\n // Clear any pending hide timeout when hovering over an item\n if (hideTimeoutRef.current) {\n clearTimeout(hideTimeoutRef.current);\n hideTimeoutRef.current = null;\n }\n } else {\n targetElement = optionsRefs.current.find(selector) ?? null;\n }\n\n if (!targetElement) {\n // Keep previous position but set opacity to 0\n if (orientation === 'vertical') {\n const verticalPrev =\n lastPositionRef.current as VerticalStyleState | null;\n const newPosition: VerticalStyleState = {\n top: verticalPrev?.top ?? 0,\n height: verticalPrev?.height ?? 0,\n opacity: 0,\n };\n\n if (verticalPrev?.opacity !== 0) {\n setChoiceIndicatorPosition(newPosition);\n lastPositionRef.current = newPosition;\n }\n } else {\n const horizontalPrev =\n lastPositionRef.current as HorizontalStyleState | null;\n const newPosition: HorizontalStyleState = {\n left: horizontalPrev?.left ?? 0,\n width: horizontalPrev?.width ?? 0,\n opacity: 0,\n };\n\n if (horizontalPrev?.opacity !== 0) {\n setChoiceIndicatorPosition(newPosition);\n lastPositionRef.current = newPosition;\n }\n }\n return;\n }\n\n if (orientation === 'vertical') {\n const top = targetElement.offsetTop;\n const height = targetElement.offsetHeight;\n\n const newPosition = {\n top,\n height,\n opacity: 1,\n };\n\n const prev = lastPositionRef.current as VerticalStyleState | null;\n\n if (\n !prev ||\n prev.top !== top ||\n prev.height !== height ||\n prev.opacity !== 1\n ) {\n setChoiceIndicatorPosition(newPosition);\n lastPositionRef.current = newPosition;\n }\n } else {\n const left = targetElement.offsetLeft;\n const width = targetElement.offsetWidth;\n\n const newPosition = {\n left,\n width,\n opacity: 1,\n };\n\n const prev = lastPositionRef.current as HorizontalStyleState | null;\n\n if (\n !prev ||\n prev.left !== left ||\n prev.width !== width ||\n prev.opacity !== 1\n ) {\n setChoiceIndicatorPosition(newPosition);\n lastPositionRef.current = newPosition;\n }\n }\n };\n\n useLayoutEffect(() => {\n calculatePosition();\n\n // Event listeners for window events\n window.addEventListener('resize', calculatePosition);\n window.addEventListener('DOMContentLoaded', calculatePosition);\n\n // MutationObserver to watch for 'aria-selected' changes\n const mutationObservers: MutationObserver[] = [];\n\n optionsRefs.current.forEach((option) => {\n if (option) {\n const observer = new MutationObserver((mutations) => {\n for (const mutation of mutations) {\n if (\n mutation.type === 'attributes' &&\n (mutation.attributeName === 'aria-selected' ||\n mutation.attributeName === 'data-active' ||\n mutation.attributeName === 'data-indicator')\n ) {\n calculatePosition();\n break;\n }\n }\n });\n\n observer.observe(option, {\n attributes: true,\n attributeFilter: ['aria-selected', 'data-active', 'data-indicator'],\n });\n\n mutationObservers.push(observer);\n }\n });\n\n // ResizeObserver to watch for size changes\n const resizeObservers: ResizeObserver[] = [];\n\n const observeSize = (element: HTMLElement) => {\n if (!element) return;\n const resizeObserver = new ResizeObserver(() => {\n calculatePosition();\n });\n resizeObserver.observe(element);\n resizeObservers.push(resizeObserver);\n };\n\n // Observe the selected item\n const selectedItem = optionsRefs.current.find(selector) ?? null;\n\n if (selectedItem) {\n observeSize(selectedItem);\n }\n\n // Observe the hovered item\n if (hoveredItem) {\n observeSize(hoveredItem);\n }\n\n // Add hover event listeners\n const handleMouseEnter = (event: Event) => {\n // Clear any pending hide timeout\n if (hideTimeoutRef.current) {\n clearTimeout(hideTimeoutRef.current);\n hideTimeoutRef.current = null;\n }\n setHoveredItem(event.currentTarget as HTMLElement);\n };\n\n const handleMouseLeave = () => {\n // Clear any existing timeout\n if (hideTimeoutRef.current) {\n clearTimeout(hideTimeoutRef.current);\n }\n\n // Keep the indicator at its current position for 150ms\n // before removing the hovered item\n hideTimeoutRef.current = setTimeout(() => {\n setHoveredItem(null);\n }, 150); // 150ms delay before hiding\n };\n\n if (isHoverable) {\n optionsRefs.current.forEach((option) => {\n option?.addEventListener('mouseenter', handleMouseEnter, {\n passive: true,\n });\n option?.addEventListener('mouseleave', handleMouseLeave, {\n passive: true,\n });\n });\n }\n\n return () => {\n // Clear any pending hide timeout\n if (hideTimeoutRef.current) {\n clearTimeout(hideTimeoutRef.current);\n }\n\n // Cleanup window event listeners\n window.removeEventListener('resize', calculatePosition);\n window.removeEventListener('DOMContentLoaded', calculatePosition);\n\n // Disconnect MutationObservers\n mutationObservers.forEach((observer) => {\n observer.disconnect();\n });\n\n // Disconnect ResizeObservers\n resizeObservers.forEach((observer) => {\n observer.disconnect();\n });\n\n // Remove hover event listeners\n optionsRefs.current.forEach((option) => {\n option?.removeEventListener('mouseenter', handleMouseEnter);\n option?.removeEventListener('mouseleave', handleMouseLeave);\n });\n };\n }, [\n optionsRefs,\n selector,\n hoveredItem,\n itemsLength,\n orientation,\n isHoverable,\n ]);\n\n return { choiceIndicatorPosition, calculatePos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GpD,MAAM,yBAAyB;AAE7B,OAAI,eAAe,QACjB,cAAa,eAAe,QAAQ;AAKtC,kBAAe,UAAU,iBAAiB;AACxC,mBAAe,KAAK;MACnB,IAAI;;AAGT,MAAI,YACF,aAAY,QAAQ,SAAS,WAAW;AACtC,WAAQ,iBAAiB,cAAc,kBAAkB,EACvD,SAAS,MACV,CAAC;AACF,WAAQ,iBAAiB,cAAc,kBAAkB,EACvD,SAAS,MACV,CAAC;IACF;AAGJ,eAAa;AAEX,OAAI,eAAe,QACjB,cAAa,eAAe,QAAQ;AAItC,UAAO,oBAAoB,UAAU,kBAAkB;AACvD,UAAO,oBAAoB,oBAAoB,kBAAkB;AAGjE,qBAAkB,SAAS,aAAa;AACtC,aAAS,YAAY;KACrB;AAGF,mBAAgB,SAAS,aAAa;AACpC,aAAS,YAAY;KACrB;AAGF,eAAY,QAAQ,SAAS,WAAW;AACtC,YAAQ,oBAAoB,cAAc,iBAAiB;AAC3D,YAAQ,oBAAoB,cAAc,iBAAiB;KAC3D;;IAEH;EACD;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,QAAO;EAAE;EAAyB;EAAmB;EAAa"}
|
|
@@ -1,22 +1,38 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useToast } from "../components/Toaster/useToast.mjs";
|
|
4
|
+
import { createAsyncStoragePersister } from "@tanstack/query-async-storage-persister";
|
|
4
5
|
import { MutationCache, QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
6
|
+
import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client";
|
|
5
7
|
import { useRef } from "react";
|
|
6
8
|
import { jsx } from "react/jsx-runtime";
|
|
7
9
|
|
|
8
10
|
//#region src/providers/ReactQueryProvider.tsx
|
|
11
|
+
const PERSIST_MAX_AGE = 1e3 * 60 * 60 * 24;
|
|
12
|
+
const PERSIST_BUSTER = "v1";
|
|
9
13
|
const defaultQueryOptions = {
|
|
10
14
|
queries: {
|
|
11
15
|
retry: 1,
|
|
12
16
|
staleTime: 30 * 1e3,
|
|
13
|
-
gcTime:
|
|
17
|
+
gcTime: PERSIST_MAX_AGE,
|
|
14
18
|
refetchOnMount: true,
|
|
15
19
|
refetchOnWindowFocus: false,
|
|
16
20
|
refetchOnReconnect: false
|
|
17
21
|
},
|
|
18
22
|
mutations: { retry: 0 }
|
|
19
23
|
};
|
|
24
|
+
const persister = createAsyncStoragePersister({
|
|
25
|
+
storage: typeof window !== "undefined" ? {
|
|
26
|
+
getItem: (key) => Promise.resolve(window.localStorage.getItem(key)),
|
|
27
|
+
setItem: (key, value) => Promise.resolve(window.localStorage.setItem(key, value)),
|
|
28
|
+
removeItem: (key) => Promise.resolve(window.localStorage.removeItem(key))
|
|
29
|
+
} : {
|
|
30
|
+
getItem: () => Promise.resolve(null),
|
|
31
|
+
setItem: () => Promise.resolve(),
|
|
32
|
+
removeItem: () => Promise.resolve()
|
|
33
|
+
},
|
|
34
|
+
key: "intlayer-rq-cache"
|
|
35
|
+
});
|
|
20
36
|
const formatErrorCode = (errorCode) => errorCode.split("_").join(" ");
|
|
21
37
|
/**
|
|
22
38
|
* Hook to handle error logging and toast notifications
|
|
@@ -64,29 +80,48 @@ const useToastEvents = () => {
|
|
|
64
80
|
};
|
|
65
81
|
};
|
|
66
82
|
const getQueryClient = () => new QueryClient({ defaultOptions: defaultQueryOptions });
|
|
67
|
-
const ReactQueryProvider = ({ children }) => {
|
|
83
|
+
const ReactQueryProvider = ({ children, client }) => {
|
|
68
84
|
const { onError, onSuccess } = useToastEvents();
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
const handlersRef = useRef({
|
|
86
|
+
onSuccess,
|
|
87
|
+
onError
|
|
88
|
+
});
|
|
89
|
+
handlersRef.current = {
|
|
90
|
+
onSuccess,
|
|
91
|
+
onError
|
|
92
|
+
};
|
|
93
|
+
const clientRef = useRef(client ?? null);
|
|
94
|
+
if (!clientRef.current) clientRef.current = new QueryClient({
|
|
95
|
+
defaultOptions: defaultQueryOptions,
|
|
96
|
+
mutationCache: new MutationCache()
|
|
97
|
+
});
|
|
98
|
+
const wiredRef = useRef(false);
|
|
99
|
+
if (!wiredRef.current) {
|
|
100
|
+
wiredRef.current = true;
|
|
101
|
+
const cache = clientRef.current.getMutationCache();
|
|
102
|
+
cache.config.onSuccess = (data, variables, onMutateResult, mutation, context) => handlersRef.current.onSuccess?.(data, variables, onMutateResult, mutation, context);
|
|
103
|
+
cache.config.onError = (error, variables, onMutateResult, mutation, context) => handlersRef.current.onError?.(error, variables, onMutateResult, mutation, context);
|
|
104
|
+
cache.config.onSettled = (_data, _error, _variables, _onMutateResult, mutation) => {
|
|
105
|
+
if (mutation.meta?.invalidateQueries) mutation.meta.invalidateQueries.forEach((queryKey) => {
|
|
106
|
+
clientRef.current?.invalidateQueries({ queryKey });
|
|
107
|
+
});
|
|
108
|
+
if (mutation.meta?.resetQueries) mutation.meta.resetQueries.forEach((queryKey) => {
|
|
109
|
+
clientRef.current?.resetQueries({ queryKey });
|
|
110
|
+
});
|
|
111
|
+
};
|
|
87
112
|
}
|
|
88
|
-
return /* @__PURE__ */ jsx(QueryClientProvider, {
|
|
113
|
+
if (client) return /* @__PURE__ */ jsx(QueryClientProvider, {
|
|
114
|
+
client: clientRef.current,
|
|
115
|
+
children
|
|
116
|
+
});
|
|
117
|
+
return /* @__PURE__ */ jsx(PersistQueryClientProvider, {
|
|
89
118
|
client: clientRef.current,
|
|
119
|
+
persistOptions: {
|
|
120
|
+
persister,
|
|
121
|
+
maxAge: PERSIST_MAX_AGE,
|
|
122
|
+
buster: PERSIST_BUSTER,
|
|
123
|
+
dehydrateOptions: { shouldDehydrateQuery: (query) => query.state.status === "success" }
|
|
124
|
+
},
|
|
90
125
|
children
|
|
91
126
|
});
|
|
92
127
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactQueryProvider.mjs","names":[],"sources":["../../../src/providers/ReactQueryProvider.tsx"],"sourcesContent":["'use client';\n\nimport {\n type DefaultOptions,\n MutationCache,\n QueryClient,\n QueryClientProvider,\n type QueryKey,\n type UseMutationOptions,\n} from '@tanstack/react-query';\nimport { type FC, type PropsWithChildren, useRef } from 'react';\nimport { useToast } from '../components/Toaster';\n\nconst defaultQueryOptions: DefaultOptions = {\n queries: {\n retry: 1,\n // Keep data fresh for 30 seconds to avoid unnecessary refetches during navigation\n staleTime: 30 * 1000,\n //
|
|
1
|
+
{"version":3,"file":"ReactQueryProvider.mjs","names":[],"sources":["../../../src/providers/ReactQueryProvider.tsx"],"sourcesContent":["'use client';\n\nimport { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister';\nimport {\n type DefaultOptions,\n MutationCache,\n QueryClient,\n QueryClientProvider,\n type QueryKey,\n type UseMutationOptions,\n} from '@tanstack/react-query';\nimport { PersistQueryClientProvider } from '@tanstack/react-query-persist-client';\nimport { type FC, type PropsWithChildren, useRef } from 'react';\nimport { useToast } from '../components/Toaster';\n\nconst PERSIST_MAX_AGE = 1000 * 60 * 60 * 24; // 24h\n// Bump to invalidate every persisted cache after a breaking change in query shapes\nconst PERSIST_BUSTER = 'v1';\n\nconst defaultQueryOptions: DefaultOptions = {\n queries: {\n retry: 1,\n // Keep data fresh for 30 seconds to avoid unnecessary refetches during navigation\n staleTime: 30 * 1000,\n // gcTime must be >= persist maxAge, otherwise restored entries are dropped on rehydrate\n gcTime: PERSIST_MAX_AGE,\n // Only refetch on mount if data is stale (not every single mount)\n refetchOnMount: true,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n },\n mutations: {\n retry: 0,\n },\n};\n\nconst browserLocalStorage = {\n getItem: (key: string) => Promise.resolve(window.localStorage.getItem(key)),\n setItem: (key: string, value: string) =>\n Promise.resolve(window.localStorage.setItem(key, value)),\n removeItem: (key: string) =>\n Promise.resolve(window.localStorage.removeItem(key)),\n};\n\nconst noopStorage = {\n getItem: () => Promise.resolve(null),\n setItem: () => Promise.resolve(),\n removeItem: () => Promise.resolve(),\n};\n\nconst persister = createAsyncStoragePersister({\n storage: typeof window !== 'undefined' ? browserLocalStorage : noopStorage,\n key: 'intlayer-rq-cache',\n});\n\nconst SHOW_ERROR_CODE = false;\n\ndeclare module '@tanstack/react-query' {\n interface Register {\n mutationMeta: {\n onSuccess?: UseMutationOptions['onSuccess'];\n onError?: UseMutationOptions['onError'];\n invalidateQueries?: QueryKey[];\n resetQueries?: QueryKey[];\n };\n }\n}\n\nconst formatErrorCode = (errorCode: string) => errorCode.split('_').join(' ');\n\n/**\n * Hook to handle error logging and toast notifications\n */\nconst useToastEvents = () => {\n const { toast } = useToast();\n\n const onError: MutationCache['config']['onError'] = (error: any) => {\n const parsed = (() => {\n try {\n if (typeof error === 'string') return JSON.parse(error);\n if (error instanceof Error) return JSON.parse(error.message);\n } catch (_) {}\n return error;\n })();\n\n [parsed].flat().forEach((err: any) => {\n // Check for nested error object (standard in your API responses: { statusCode, error: { ... } })\n const apiError = err?.error ?? err;\n\n if (apiError?.code === 'RATE_LIMIT_EXCEEDED_UNAUTHENTICATED') {\n toast({\n title: apiError.message,\n variant: 'error',\n });\n return;\n }\n\n toast({\n title: formatErrorCode(\n SHOW_ERROR_CODE\n ? (apiError?.code ?? err?.code)\n : (apiError?.title ?? err?.title ?? 'Error')\n ),\n description:\n apiError?.message ??\n err?.message ??\n String(apiError ?? 'An error occurred'),\n variant: 'error',\n });\n });\n };\n\n const onSuccess: MutationCache['config']['onSuccess'] = (data: any) => {\n if (data?.error) {\n toast({\n title: formatErrorCode(data.error.title ?? data.error.code ?? 'Error'),\n description:\n data.error.message ?? data.error.code ?? 'An error occurred',\n variant: 'error',\n });\n }\n\n if (data?.message) {\n toast({\n title: data.message,\n description: data.description,\n variant: 'success',\n });\n }\n };\n\n return {\n onError,\n onSuccess,\n };\n};\n\nexport const getQueryClient = () =>\n new QueryClient({ defaultOptions: defaultQueryOptions });\n\ninterface ReactQueryProviderProps {\n client?: QueryClient;\n}\n\nexport const ReactQueryProvider: FC<\n PropsWithChildren<ReactQueryProviderProps>\n> = ({ children, client }) => {\n const { onError, onSuccess } = useToastEvents();\n // Keep handlers in a ref so the cache config (set once below) always calls\n // the latest closures from useToastEvents without needing re-wiring.\n const handlersRef = useRef({ onSuccess, onError });\n handlersRef.current = { onSuccess, onError };\n\n const clientRef = useRef<QueryClient>(client ?? null);\n\n if (!clientRef.current) {\n clientRef.current = new QueryClient({\n defaultOptions: defaultQueryOptions,\n mutationCache: new MutationCache(),\n });\n }\n\n // Wire toast handlers + meta-driven invalidation onto whatever client we\n // ended up with. Required even when the client is created externally (e.g.\n // via getQueryClient() in TanStack Router context), since the externally\n // created client ships with a bare MutationCache.\n const wiredRef = useRef(false);\n if (!wiredRef.current) {\n wiredRef.current = true;\n const cache = clientRef.current.getMutationCache();\n cache.config.onSuccess = (\n data,\n variables,\n onMutateResult,\n mutation,\n context\n ) =>\n handlersRef.current.onSuccess?.(\n data,\n variables,\n onMutateResult,\n mutation,\n context\n );\n cache.config.onError = (\n error,\n variables,\n onMutateResult,\n mutation,\n context\n ) =>\n handlersRef.current.onError?.(\n error,\n variables,\n onMutateResult,\n mutation,\n context\n );\n cache.config.onSettled = (\n _data,\n _error,\n _variables,\n _onMutateResult,\n mutation\n ) => {\n if (mutation.meta?.invalidateQueries) {\n mutation.meta.invalidateQueries.forEach((queryKey) => {\n clientRef.current?.invalidateQueries({ queryKey });\n });\n }\n\n if (mutation.meta?.resetQueries) {\n mutation.meta.resetQueries.forEach((queryKey) => {\n clientRef.current?.resetQueries({ queryKey });\n });\n }\n };\n }\n\n if (client) {\n return (\n <QueryClientProvider client={clientRef.current}>\n {children}\n </QueryClientProvider>\n );\n }\n\n return (\n <PersistQueryClientProvider\n client={clientRef.current}\n persistOptions={{\n persister,\n maxAge: PERSIST_MAX_AGE,\n buster: PERSIST_BUSTER,\n dehydrateOptions: {\n shouldDehydrateQuery: (query) => query.state.status === 'success',\n },\n }}\n >\n {children}\n </PersistQueryClientProvider>\n );\n};\n"],"mappings":";;;;;;;;;;AAeA,MAAM,kBAAkB,MAAO,KAAK,KAAK;AAEzC,MAAM,iBAAiB;AAEvB,MAAM,sBAAsC;CAC1C,SAAS;EACP,OAAO;EAEP,WAAW,KAAK;EAEhB,QAAQ;EAER,gBAAgB;EAChB,sBAAsB;EACtB,oBAAoB;EACrB;CACD,WAAW,EACT,OAAO,GACR;CACF;AAgBD,MAAM,YAAY,4BAA4B;CAC5C,SAAS,OAAO,WAAW,cAAc;EAdzC,UAAU,QAAgB,QAAQ,QAAQ,OAAO,aAAa,QAAQ,IAAI,CAAC;EAC3E,UAAU,KAAa,UACrB,QAAQ,QAAQ,OAAO,aAAa,QAAQ,KAAK,MAAM,CAAC;EAC1D,aAAa,QACX,QAAQ,QAAQ,OAAO,aAAa,WAAW,IAAI,CAAC;EAUM,GAAG;EAN/D,eAAe,QAAQ,QAAQ,KAAK;EACpC,eAAe,QAAQ,SAAS;EAChC,kBAAkB,QAAQ,SAAS;EAIuC;CAC1E,KAAK;CACN,CAAC;AAeF,MAAM,mBAAmB,cAAsB,UAAU,MAAM,IAAI,CAAC,KAAK,IAAI;;;;AAK7E,MAAM,uBAAuB;CAC3B,MAAM,EAAE,UAAU,UAAU;CAE5B,MAAM,WAA+C,UAAe;AASlE,UARsB;AACpB,OAAI;AACF,QAAI,OAAO,UAAU,SAAU,QAAO,KAAK,MAAM,MAAM;AACvD,QAAI,iBAAiB,MAAO,QAAO,KAAK,MAAM,MAAM,QAAQ;YACrD,GAAG;AACZ,UAAO;MAGF,CAAC,CAAC,MAAM,CAAC,SAAS,QAAa;GAEpC,MAAM,WAAW,KAAK,SAAS;AAE/B,OAAI,UAAU,SAAS,uCAAuC;AAC5D,UAAM;KACJ,OAAO,SAAS;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AS,KAAK,kBAAkB,SAAS,aAAa;AACpD,cAAU,SAAS,kBAAkB,EAAE,UAAU,CAAC;KAClD;AAGJ,OAAI,SAAS,MAAM,aACjB,UAAS,KAAK,aAAa,SAAS,aAAa;AAC/C,cAAU,SAAS,aAAa,EAAE,UAAU,CAAC;KAC7C;;;AAKR,KAAI,OACF,QACE,oBAAC,qBAAD;EAAqB,QAAQ,UAAU;EACpC;EACmB;AAI1B,QACE,oBAAC,4BAAD;EACE,QAAQ,UAAU;EAClB,gBAAgB;GACd;GACA,QAAQ;GACR,QAAQ;GACR,kBAAkB,EAChB,uBAAuB,UAAU,MAAM,MAAM,WAAW,WACzD;GACF;EAEA;EAC0B"}
|
|
@@ -43,8 +43,8 @@ declare enum BadgeSize {
|
|
|
43
43
|
* @description Defines the styling variants for different badge combinations
|
|
44
44
|
*/
|
|
45
45
|
declare const badgeVariants: (props?: {
|
|
46
|
-
color?: "
|
|
47
|
-
variant?: "none" | "default" | "
|
|
46
|
+
color?: "text" | "error" | "custom" | "primary" | "secondary" | "destructive" | "neutral" | "light" | "dark" | "success";
|
|
47
|
+
variant?: "none" | "default" | "hoverable" | "outline";
|
|
48
48
|
size?: "sm" | "md" | "lg";
|
|
49
49
|
} & _$class_variance_authority_types0.ClassProp) => string;
|
|
50
50
|
/**
|
|
@@ -61,10 +61,10 @@ declare enum ButtonTextAlign {
|
|
|
61
61
|
*/
|
|
62
62
|
declare const buttonVariants: (props?: {
|
|
63
63
|
size?: "sm" | "md" | "lg" | "xl" | "icon-sm" | "icon-md" | "icon-lg" | "icon-xl";
|
|
64
|
-
color?: "
|
|
65
|
-
roundedSize?: "
|
|
66
|
-
variant?: "
|
|
67
|
-
textAlign?: "left" | "
|
|
64
|
+
color?: "text" | "error" | "custom" | "primary" | "secondary" | "destructive" | "neutral" | "light" | "dark" | "text-inverse" | "success" | "card" | "current";
|
|
65
|
+
roundedSize?: "sm" | "md" | "lg" | "xl" | "2xl" | "none" | "3xl" | "full" | "4xl" | "5xl";
|
|
66
|
+
variant?: "none" | "default" | "input" | "invisible-link" | "hoverable" | "outline" | "link" | "fade";
|
|
67
|
+
textAlign?: "left" | "right" | "center";
|
|
68
68
|
isFullWidth?: boolean;
|
|
69
69
|
} & _$class_variance_authority_types0.ClassProp) => string;
|
|
70
70
|
/**
|
|
@@ -5,8 +5,8 @@ import { VariantProps } from "class-variance-authority";
|
|
|
5
5
|
//#region src/components/CollapsibleTable/CollapsibleTable.d.ts
|
|
6
6
|
declare const collapsibleTableVariants: (props?: {
|
|
7
7
|
size?: "sm" | "md" | "lg" | "xl" | "full";
|
|
8
|
-
variant?: "default" | "
|
|
9
|
-
spacing?: "
|
|
8
|
+
variant?: "default" | "ghost" | "dark" | "outlined";
|
|
9
|
+
spacing?: "sm" | "md" | "lg" | "none" | "auto";
|
|
10
10
|
} & _$class_variance_authority_types0.ClassProp) => string;
|
|
11
11
|
interface CollapsibleTableProps extends Omit<HTMLAttributes<HTMLElement>, 'title'>, VariantProps<typeof collapsibleTableVariants> {
|
|
12
12
|
/** Table title displayed in the header */
|
|
@@ -8,14 +8,14 @@ import { VariantProps } from "class-variance-authority";
|
|
|
8
8
|
* Provides flexible styling options for background, padding, borders, and layout
|
|
9
9
|
*/
|
|
10
10
|
declare const containerVariants: (props?: {
|
|
11
|
-
roundedSize?: "
|
|
12
|
-
transparency?: "
|
|
13
|
-
padding?: "
|
|
11
|
+
roundedSize?: "sm" | "md" | "lg" | "xl" | "2xl" | "none" | "3xl" | "full" | "4xl";
|
|
12
|
+
transparency?: "xs" | "sm" | "md" | "lg" | "xl" | "none" | "full";
|
|
13
|
+
padding?: "sm" | "md" | "lg" | "xl" | "2xl" | "none";
|
|
14
14
|
separator?: "both" | "without" | "x" | "y";
|
|
15
|
-
border?: "
|
|
15
|
+
border?: "none" | "with";
|
|
16
16
|
borderColor?: "error" | "success" | "text" | "primary" | "secondary" | "neutral" | "card" | "warning";
|
|
17
|
-
background?: "
|
|
18
|
-
gap?: "
|
|
17
|
+
background?: "none" | "with" | "hoverable";
|
|
18
|
+
gap?: "sm" | "md" | "lg" | "xl" | "2xl" | "none";
|
|
19
19
|
} & _$class_variance_authority_types0.ClassProp) => string;
|
|
20
20
|
/** Available rounded corner sizes for the container */
|
|
21
21
|
declare enum ContainerRoundedSize {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CodeFormat, ContentDeclarationFormat, PackageManager } from "./CodeContext.js";
|
|
2
|
-
import { FC, HTMLAttributes } from "react";
|
|
2
|
+
import { FC, HTMLAttributes, ReactNode } from "react";
|
|
3
3
|
import { BundledLanguage } from "shiki/bundle/web";
|
|
4
4
|
|
|
5
5
|
//#region src/components/IDE/Code.d.ts
|
|
@@ -10,7 +10,7 @@ type CodeCompAttributes = {
|
|
|
10
10
|
contentDeclarationFormat?: ContentDeclarationFormat | string | string[];
|
|
11
11
|
};
|
|
12
12
|
type CodeCompProps = {
|
|
13
|
-
children:
|
|
13
|
+
children: ReactNode;
|
|
14
14
|
fileName?: string;
|
|
15
15
|
language: BundledLanguage;
|
|
16
16
|
isDarkMode?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Code.d.ts","names":[],"sources":["../../../../src/components/IDE/Code.tsx"],"mappings":";;;;;KAsBY,kBAAA;EACV,QAAA;EACA,cAAA,GAAiB,cAAA,EAFW;EAI5B,UAAA,GAAa,UAAA;EACb,wBAAA,GAA2B,wBAAA;AAAA;AAAA,KAGxB,aAAA;EACH,QAAA;
|
|
1
|
+
{"version":3,"file":"Code.d.ts","names":[],"sources":["../../../../src/components/IDE/Code.tsx"],"mappings":";;;;;KAsBY,kBAAA;EACV,QAAA;EACA,cAAA,GAAiB,cAAA,EAFW;EAI5B,UAAA,GAAa,UAAA;EACb,wBAAA,GAA2B,wBAAA;AAAA;AAAA,KAGxB,aAAA;EACH,QAAA,EAAU,SAAA;EACV,QAAA;EACA,QAAA,EAAU,eAAA;EACV,UAAA;EACA,UAAA;EACA,eAAA;EACA,UAAA;AAAA,IACE,kBAAA,GACF,cAAA,CAAe,cAAA;AAAA,cAwBJ,IAAA,EAAM,EAAA,CAAG,aAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { FC, HTMLAttributes } from "react";
|
|
1
|
+
import { FC, HTMLAttributes, ReactNode } from "react";
|
|
2
2
|
import { BundledLanguage, BundledLanguage as CodeLanguage } from "shiki/bundle/web";
|
|
3
3
|
|
|
4
4
|
//#region src/components/IDE/CodeBlockClient.d.ts
|
|
5
5
|
declare const CodeDefault: FC<{
|
|
6
|
-
children:
|
|
6
|
+
children: ReactNode;
|
|
7
7
|
}>;
|
|
8
8
|
type CodeBlockProps = {
|
|
9
|
-
children:
|
|
9
|
+
children: React.ReactNode;
|
|
10
10
|
lang: BundledLanguage;
|
|
11
11
|
isDarkMode?: boolean;
|
|
12
12
|
isEditable?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlockClient.d.ts","names":[],"sources":["../../../../src/components/IDE/CodeBlockClient.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"CodeBlockClient.d.ts","names":[],"sources":["../../../../src/components/IDE/CodeBlockClient.tsx"],"mappings":";;;;cAYa,WAAA,EAAa,EAAA;EAAK,QAAA,EAAU,SAAA;AAAA;AAAA,KA0B7B,cAAA;EACV,QAAA,EAAU,KAAA,CAAM,SAAA;EAChB,IAAA,EAAM,eAAA;EACN,UAAA;EACA,UAAA;EACA,QAAA,IAAY,OAAA;AAAA,IACV,IAAA,CAAK,cAAA,CAAe,cAAA;AAAA,cAEX,SAAA,EAAW,EAAA,CAAG,cAAA"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { CodeFormat } from "./CodeContext.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
2
3
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
4
|
import { BundledLanguage } from "shiki/bundle/web";
|
|
4
5
|
|
|
5
6
|
//#region src/components/IDE/CodeBlockHighlight.d.ts
|
|
6
7
|
type Props = {
|
|
7
|
-
/** Raw TypeScript source code (the canonical "source of truth"). */children:
|
|
8
|
+
/** Raw TypeScript source code (the canonical "source of truth"). */children: ReactNode; /** Language of the source (e.g. 'tsx', 'typescript'). */
|
|
8
9
|
originalLang: BundledLanguage; /** Currently selected format: 'typescript' | 'esm' | 'commonjs'. */
|
|
9
10
|
targetFormat: Exclude<CodeFormat, 'json'>;
|
|
10
11
|
isDarkMode?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlockHighlight.d.ts","names":[],"sources":["../../../../src/components/IDE/CodeBlockHighlight.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CodeBlockHighlight.d.ts","names":[],"sources":["../../../../src/components/IDE/CodeBlockHighlight.tsx"],"mappings":";;;;;;KAcK,KAAA;EAMmB,oEAJtB,QAAA,EAAU,SAAA,EAIW;EAFrB,YAAA,EAAc,eAAA,EAFd;EAIA,YAAA,EAAc,OAAA,CAAQ,UAAA;EACtB,UAAA;AAAA;AAAA,cAmBW,kBAAA;EAAsB,QAAA;EAAA,YAAA;EAAA,YAAA;EAAA;AAAA,GAKhC,KAAA,KAAK,oBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { FC } from "react";
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
2
|
import { BundledLanguage } from "shiki/bundle/web";
|
|
3
3
|
|
|
4
4
|
//#region src/components/IDE/CodeBlockShiki.d.ts
|
|
5
5
|
type CodeBlockShikiProps = {
|
|
6
|
-
children:
|
|
6
|
+
children: ReactNode;
|
|
7
7
|
lang: BundledLanguage;
|
|
8
8
|
isDarkMode?: boolean;
|
|
9
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlockShiki.d.ts","names":[],"sources":["../../../../src/components/IDE/CodeBlockShiki.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"CodeBlockShiki.d.ts","names":[],"sources":["../../../../src/components/IDE/CodeBlockShiki.tsx"],"mappings":";;;;KAyJY,mBAAA;EACV,QAAA,EAAU,SAAA;EACV,IAAA,EAAM,eAAA;EACN,UAAA;AAAA;AAAA,cAGW,cAAA,EAAgB,EAAA,CAAG,mBAAA"}
|
|
@@ -6,7 +6,7 @@ import { VariantProps } from "class-variance-authority";
|
|
|
6
6
|
declare const checkboxVariants: (props?: {
|
|
7
7
|
variant?: "default";
|
|
8
8
|
size?: "xs" | "sm" | "md" | "lg";
|
|
9
|
-
color?: "error" | "success" | "
|
|
9
|
+
color?: "error" | "success" | "text" | "custom" | "primary" | "secondary" | "destructive" | "neutral" | "light" | "dark";
|
|
10
10
|
validationStyleEnabled?: "enabled" | "disabled";
|
|
11
11
|
} & _$class_variance_authority_types0.ClassProp) => string;
|
|
12
12
|
declare enum CheckboxSize {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.d.ts","names":[],"sources":["../../../../src/components/Input/Checkbox.tsx"],"mappings":";;;;;cASa,gBAAA,GAAgB,KAAA;;;;;
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","names":[],"sources":["../../../../src/components/Input/Checkbox.tsx"],"mappings":";;;;;cASa,gBAAA,GAAgB,KAAA;;;;;IAkE5B,iCAAA,CAAA,SAAA;AAAA,aAEW,YAAA;EACV,EAAA;EACA,EAAA;EACA,EAAA;EACA,EAAA;AAAA;AAAA,aAGU,aAAA;EACV,OAAA;EACA,SAAA;EACA,WAAA;EACA,OAAA;EACA,KAAA;EACA,IAAA;EACA,IAAA;EACA,KAAA;EACA,OAAA;EACA,MAAA;AAAA;AAAA,KAGU,aAAA,GAAgB,IAAA,CAC1B,iBAAA,CAAkB,mBAAA,CAAoB,gBAAA,GAAmB,gBAAA;EAGzD,IAAA;EACA,sBAAA;EACA,KAAA,GAAQ,SAAA;AAAA,IACN,IAAA,CACA,YAAA,QAAoB,gBAAA;EAGpB,IAAA,GAAO,YAAA,MAAkB,YAAA;EACzB,KAAA,GAAQ,aAAA,MAAmB,aAAA;EAC3B,cAAA;AAAA;AAAA,cA6BS,QAAA,EAAU,EAAA,CAAG,aAAA"}
|
|
@@ -53,9 +53,9 @@ declare enum LinkUnderlined {
|
|
|
53
53
|
FALSE = "false"
|
|
54
54
|
}
|
|
55
55
|
declare const linkVariants: (props?: {
|
|
56
|
-
variant?: "default" | "invisible-link" | "
|
|
57
|
-
roundedSize?: "
|
|
58
|
-
color?: "
|
|
56
|
+
variant?: "default" | "invisible-link" | "button" | "button-outlined" | "hoverable";
|
|
57
|
+
roundedSize?: "sm" | "md" | "lg" | "xl" | "2xl" | "none" | "3xl" | "full";
|
|
58
|
+
color?: "text" | "error" | "custom" | "primary" | "secondary" | "destructive" | "neutral" | "light" | "dark" | "text-inverse" | "success";
|
|
59
59
|
size?: "sm" | "md" | "lg" | "xl" | "custom";
|
|
60
60
|
underlined?: boolean | LinkUnderlined.DEFAULT;
|
|
61
61
|
} & _$class_variance_authority_types0.ClassProp) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/components/Navbar/index.tsx"],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/components/Navbar/index.tsx"],"mappings":";;;;;;;;;;;;KAYK,WAAA,WAAsB,oBAAA;uDAEzB,IAAA,EAAM,SAAA,EAFH;EAIH,cAAA,EAAgB,CAAA,SAJF;EAMd,eAAA,GAAkB,YAAA,CAAa,CAAA,KAJzB;EAMN,iBAAA,GAAoB,SAAA,EAFW;EAI/B,iBAAA,GAAoB,YAAA,CAAa,CAAA,KAFb;EAIpB,oBAAA,GAAuB,SAAA,EAFH;EAIpB,oBAAA,GAAuB,YAAA,CAAa,CAAA,KAAA;EAEpC,iBAAA,GAAoB,SAAA,EAAA;EAEpB,gBAAA,GAAmB,SAAA,EAAS;EAE5B,cAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,MAAA,aAAoB,oBAAA;EAAsB,IAAA;EAAA,iBAAA;EAAA,eAAA;EAAA,iBAAA;EAAA,oBAAA;EAAA,oBAAA;EAAA,iBAAA;EAAA,gBAAA;EAAA,cAAA;EAAA;AAAA,GAWpD,WAAA,CAAY,CAAA,MAAE,oBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import * as _$class_variance_authority_types0 from "class-variance-authority/types";
|
|
3
|
+
import { VariantProps } from "class-variance-authority";
|
|
4
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/components/SwitchSelector/SwitchSelector.d.ts
|
|
7
|
+
type SwitchSelectorChoice<T = boolean> = {
|
|
8
|
+
content: ReactNode;
|
|
9
|
+
value: T;
|
|
10
|
+
} & HTMLAttributes<HTMLButtonElement>;
|
|
11
|
+
type SwitchSelectorChoices<T> = SwitchSelectorChoice<T>[];
|
|
12
|
+
declare const defaultChoices: SwitchSelectorChoices<boolean>;
|
|
13
|
+
declare enum SwitchSelectorColor {
|
|
14
|
+
PRIMARY = "primary",
|
|
15
|
+
SECONDARY = "secondary",
|
|
16
|
+
DESTRUCTIVE = "destructive",
|
|
17
|
+
NEUTRAL = "neutral",
|
|
18
|
+
LIGHT = "light",
|
|
19
|
+
DARK = "dark",
|
|
20
|
+
TEXT = "text"
|
|
21
|
+
}
|
|
22
|
+
declare enum SwitchSelectorSize {
|
|
23
|
+
SM = "sm",
|
|
24
|
+
MD = "md",
|
|
25
|
+
LG = "lg"
|
|
26
|
+
}
|
|
27
|
+
type SwitchSelectorBaseProps<T = boolean> = {
|
|
28
|
+
choices?: SwitchSelectorChoices<T>;
|
|
29
|
+
value?: T;
|
|
30
|
+
defaultValue?: T;
|
|
31
|
+
onChange?: (choice: T) => void;
|
|
32
|
+
className?: string;
|
|
33
|
+
itemClassName?: string;
|
|
34
|
+
hoverable?: boolean;
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
};
|
|
38
|
+
type SwitchSelectorProps<T = boolean> = SwitchSelectorBaseProps<T> & VariantProps<typeof switchSelectorVariant> & VariantProps<typeof choiceVariant>;
|
|
39
|
+
declare const switchSelectorVariant: (props?: {
|
|
40
|
+
color?: "text" | "primary" | "secondary" | "destructive" | "neutral" | "light" | "dark";
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
} & _$class_variance_authority_types0.ClassProp) => string;
|
|
43
|
+
declare const choiceVariant: (props?: {
|
|
44
|
+
size?: "sm" | "md" | "lg";
|
|
45
|
+
} & _$class_variance_authority_types0.ClassProp) => string;
|
|
46
|
+
declare const indicatorVariant: (props?: {
|
|
47
|
+
color?: "text" | "primary" | "secondary" | "destructive" | "neutral" | "light" | "dark";
|
|
48
|
+
} & _$class_variance_authority_types0.ClassProp) => string;
|
|
49
|
+
/**
|
|
50
|
+
* Component that allows the user to select one of the provided choices.
|
|
51
|
+
* This component is horizontal.
|
|
52
|
+
*/
|
|
53
|
+
declare const SwitchSelector: <T>(props: SwitchSelectorProps<T>) => _$react_jsx_runtime0.JSX.Element;
|
|
54
|
+
//#endregion
|
|
55
|
+
export { SwitchSelector, SwitchSelectorBaseProps, SwitchSelectorChoice, SwitchSelectorChoices, SwitchSelectorColor, SwitchSelectorProps, SwitchSelectorSize, choiceVariant, defaultChoices, indicatorVariant, switchSelectorVariant };
|
|
56
|
+
//# sourceMappingURL=SwitchSelector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwitchSelector.d.ts","names":[],"sources":["../../../../src/components/SwitchSelector/SwitchSelector.tsx"],"mappings":";;;;;;KAOY,oBAAA;EACV,OAAA,EAAS,SAAA;EACT,KAAA,EAAO,CAAA;AAAA,IACL,cAAA,CAAe,iBAAA;AAAA,KACP,qBAAA,MAA2B,oBAAA,CAAqB,CAAA;AAAA,cAE/C,cAAA,EAAgB,qBAAA;AAAA,aAKjB,mBAAA;EACV,OAAA;EACA,SAAA;EACA,WAAA;EACA,OAAA;EACA,KAAA;EACA,IAAA;EACA,IAAA;AAAA;AAAA,aAGU,kBAAA;EACV,EAAA;EACA,EAAA;EACA,EAAA;AAAA;AAAA,KAGU,uBAAA;EACV,OAAA,GAAU,qBAAA,CAAsB,CAAA;EAChC,KAAA,GAAQ,CAAA;EACR,YAAA,GAAe,CAAA;EACf,QAAA,IAAY,MAAA,EAAQ,CAAA;EACpB,SAAA;EACA,aAAA;EACA,SAAA;EACA,QAAA;EAAA,CACC,GAAA;AAAA;AAAA,KAGS,mBAAA,gBAAmC,uBAAA,CAAwB,CAAA,IACrE,YAAA,QAAoB,qBAAA,IACpB,YAAA,QAAoB,aAAA;AAAA,cAET,qBAAA,GAAqB,KAAA;;;IAwBjC,iCAAA,CAAA,SAAA;AAAA,cAEY,aAAA,GAAa,KAAA;;IAczB,iCAAA,CAAA,SAAA;AAAA,cAEY,gBAAA,GAAgB,KAAA;;IAsB5B,iCAAA,CAAA,SAAA;;;;;cAMY,cAAA,MAAsB,KAAA,EAAO,mBAAA,CAAoB,CAAA,MAAE,oBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SwitchSelectorBaseProps } from "./SwitchSelector.js";
|
|
2
|
+
import * as _$class_variance_authority_types0 from "class-variance-authority/types";
|
|
3
|
+
import { VariantProps } from "class-variance-authority";
|
|
4
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/components/SwitchSelector/VerticalSwitchSelector.d.ts
|
|
7
|
+
declare const verticalSwitchSelectorVariant: (props?: {
|
|
8
|
+
color?: "text" | "primary" | "secondary" | "destructive" | "neutral" | "light" | "dark";
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
} & _$class_variance_authority_types0.ClassProp) => string;
|
|
11
|
+
declare const verticalChoiceVariant: (props?: {
|
|
12
|
+
size?: "sm" | "md" | "lg";
|
|
13
|
+
} & _$class_variance_authority_types0.ClassProp) => string;
|
|
14
|
+
type VerticalSwitchSelectorProps<T = boolean> = SwitchSelectorBaseProps<T> & VariantProps<typeof verticalSwitchSelectorVariant> & VariantProps<typeof verticalChoiceVariant>;
|
|
15
|
+
/**
|
|
16
|
+
* Component that allows the user to select one of the provided choices.
|
|
17
|
+
* This component is vertical.
|
|
18
|
+
*/
|
|
19
|
+
declare const VerticalSwitchSelector: <T>(props: VerticalSwitchSelectorProps<T>) => _$react_jsx_runtime0.JSX.Element;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { VerticalSwitchSelector, VerticalSwitchSelectorProps };
|
|
22
|
+
//# sourceMappingURL=VerticalSwitchSelector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VerticalSwitchSelector.d.ts","names":[],"sources":["../../../../src/components/SwitchSelector/VerticalSwitchSelector.tsx"],"mappings":";;;;;;cAaM,6BAAA,GAA6B,KAAA;;;IAwBlC,iCAAA,CAAA,SAAA;AAAA,cAEK,qBAAA,GAAqB,KAAA;;IAc1B,iCAAA,CAAA,SAAA;AAAA,KA0BW,2BAAA,gBACV,uBAAA,CAAwB,CAAA,IACtB,YAAA,QAAoB,6BAAA,IACpB,YAAA,QAAoB,qBAAA;;;;;cAMX,sBAAA,MACX,KAAA,EAAO,2BAAA,CAA4B,CAAA,MAAE,oBAAA,CAAA,GAAA,CAAA,OAAA"}
|