@inspirare/design-system 0.0.24 → 0.0.26
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/dist/components/ui/alert-dialog.js +1 -1
- package/dist/components/ui/dialog.js +1 -1
- package/dist/components/ui/select.js +22 -4
- package/dist/index.css +1 -1
- package/package.json +1 -1
- package/src/components/ui/alert-dialog.tsx +1 -1
- package/src/components/ui/dialog.tsx +1 -1
- package/src/components/ui/select.test.tsx +19 -1
- package/src/components/ui/select.tsx +29 -2
- package/src/index.css +30 -0
package/package.json
CHANGED
|
@@ -52,7 +52,7 @@ function AlertDialogContent({
|
|
|
52
52
|
data-slot="alert-dialog-content"
|
|
53
53
|
data-size={size}
|
|
54
54
|
className={cn(
|
|
55
|
-
"group/alert-dialog-content fixed
|
|
55
|
+
"group/alert-dialog-content fixed inset-0 m-auto z-50 grid w-full max-h-[88dvh] h-fit gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
56
56
|
className
|
|
57
57
|
)}
|
|
58
58
|
{...props}
|
|
@@ -58,7 +58,7 @@ const DialogContent = React.forwardRef<
|
|
|
58
58
|
ref={ref}
|
|
59
59
|
data-slot="dialog-content"
|
|
60
60
|
className={cn(
|
|
61
|
-
"fixed
|
|
61
|
+
"fixed inset-0 m-auto z-50 grid w-[90vw] max-w-lg max-h-[88dvh] h-fit gap-4 rounded-2xl bg-popover/90 backdrop-blur-xl p-6 text-sm text-popover-foreground shadow-2xl ring-1 ring-border duration-200 outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
62
62
|
className
|
|
63
63
|
)}
|
|
64
64
|
{...props}
|
|
@@ -2,6 +2,7 @@ import { render } from '@testing-library/react';
|
|
|
2
2
|
import { axe } from 'jest-axe';
|
|
3
3
|
import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from "./select";
|
|
4
4
|
|
|
5
|
+
|
|
5
6
|
describe('Select Accessibility', () => {
|
|
6
7
|
it('should have no accessibility violations in basic render', async () => {
|
|
7
8
|
const Wrapper = () => (
|
|
@@ -11,4 +12,21 @@ describe('Select Accessibility', () => {
|
|
|
11
12
|
const results = await axe(container);
|
|
12
13
|
expect(results).toHaveNoViolations();
|
|
13
14
|
});
|
|
14
|
-
|
|
15
|
+
|
|
16
|
+
it('should display the default label instead of the value on initial render', () => {
|
|
17
|
+
const Wrapper = () => (
|
|
18
|
+
<Select defaultValue="dark">
|
|
19
|
+
<SelectTrigger aria-label="Select a theme" className="w-[180px]">
|
|
20
|
+
<SelectValue placeholder="Theme" />
|
|
21
|
+
</SelectTrigger>
|
|
22
|
+
<SelectContent>
|
|
23
|
+
<SelectItem value="light">Light</SelectItem>
|
|
24
|
+
<SelectItem value="dark">Dark Theme</SelectItem>
|
|
25
|
+
<SelectItem value="system">System</SelectItem>
|
|
26
|
+
</SelectContent>
|
|
27
|
+
</Select>
|
|
28
|
+
);
|
|
29
|
+
const { container } = render(<Wrapper />);
|
|
30
|
+
expect(container.textContent).toContain('Dark Theme');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -12,10 +12,37 @@ const SelectContext = React.createContext<{
|
|
|
12
12
|
} | null>(null);
|
|
13
13
|
|
|
14
14
|
function Select({ children, ...props }: React.ComponentProps<typeof SelectPrimitive.Root>) {
|
|
15
|
-
const [
|
|
15
|
+
const [dynamicLabels, setDynamicLabels] = React.useState<Record<string, string>>({});
|
|
16
16
|
|
|
17
|
+
const staticLabels = React.useMemo(() => {
|
|
18
|
+
const result: Record<string, string> = {};
|
|
19
|
+
const extract = (node: React.ReactNode) => {
|
|
20
|
+
React.Children.forEach(node, (child) => {
|
|
21
|
+
if (!React.isValidElement(child)) return;
|
|
22
|
+
if ((child as any).props && (child as any).props.value !== undefined) {
|
|
23
|
+
if ((child as any).props.children) {
|
|
24
|
+
let label = "";
|
|
25
|
+
React.Children.forEach((child as any).props.children, (grandChild) => {
|
|
26
|
+
if (typeof grandChild === "string" || typeof grandChild === "number") {
|
|
27
|
+
label += grandChild;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
if (label) result[(child as any).props.value] = label;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if ((child as any).props && (child as any).props.children) {
|
|
34
|
+
extract((child as any).props.children);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
extract(children);
|
|
39
|
+
return result;
|
|
40
|
+
}, [children]);
|
|
41
|
+
|
|
42
|
+
const labels = { ...staticLabels, ...dynamicLabels };
|
|
43
|
+
|
|
17
44
|
const registerLabel = React.useCallback((val: any, label: string) => {
|
|
18
|
-
|
|
45
|
+
setDynamicLabels((prev) => {
|
|
19
46
|
if (prev[val] === label) return prev;
|
|
20
47
|
return { ...prev, [val]: label };
|
|
21
48
|
});
|
package/src/index.css
CHANGED
|
@@ -3,6 +3,36 @@
|
|
|
3
3
|
@import "shadcn/tailwind.css";
|
|
4
4
|
@custom-variant dark (&:is(.dark *));
|
|
5
5
|
|
|
6
|
+
/* ── Universal Dialog Viewport Centering & Boundary Safety ── */
|
|
7
|
+
[data-slot="dialog-content"],
|
|
8
|
+
[data-slot="alert-dialog-content"],
|
|
9
|
+
[data-radix-dialog-content],
|
|
10
|
+
div[role="dialog"],
|
|
11
|
+
div[role="alertdialog"] {
|
|
12
|
+
position: fixed !important;
|
|
13
|
+
inset: 0 !important;
|
|
14
|
+
top: 0 !important;
|
|
15
|
+
right: 0 !important;
|
|
16
|
+
bottom: 0 !important;
|
|
17
|
+
left: 0 !important;
|
|
18
|
+
margin: auto !important;
|
|
19
|
+
max-height: 88vh !important;
|
|
20
|
+
max-height: 88dvh !important;
|
|
21
|
+
height: fit-content !important;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
[data-slot="dialog-overlay"],
|
|
25
|
+
[data-slot="alert-dialog-overlay"],
|
|
26
|
+
[data-radix-dialog-overlay] {
|
|
27
|
+
position: fixed !important;
|
|
28
|
+
inset: 0 !important;
|
|
29
|
+
top: 0 !important;
|
|
30
|
+
right: 0 !important;
|
|
31
|
+
bottom: 0 !important;
|
|
32
|
+
left: 0 !important;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
6
36
|
/* Detecção de conteúdo restrita à BIBLIOTECA. O playground do Vite
|
|
7
37
|
(App.tsx, main.tsx, demo/) só existe para desenvolvimento local e não é
|
|
8
38
|
publicado (o entry da lib é src/index.ts → components/ui/*). Sem estas
|