@wordpress/ui 0.5.1-next.v.0 → 0.6.0
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/CHANGELOG.md +5 -1
- package/build/box/box.cjs +2 -2
- package/build/box/box.cjs.map +2 -2
- package/build/button/button.cjs +18 -303
- package/build/button/button.cjs.map +3 -3
- package/build/form/primitives/constants.cjs +35 -0
- package/build/form/primitives/constants.cjs.map +7 -0
- package/build/form/primitives/field/description.cjs +6 -33
- package/build/form/primitives/field/description.cjs.map +2 -2
- package/build/form/primitives/field/details.cjs +6 -33
- package/build/form/primitives/field/details.cjs.map +2 -2
- package/build/form/primitives/field/label.cjs +6 -33
- package/build/form/primitives/field/label.cjs.map +2 -2
- package/build/form/primitives/field/root.cjs +6 -17
- package/build/form/primitives/field/root.cjs.map +2 -2
- package/build/form/primitives/fieldset/description.cjs +6 -33
- package/build/form/primitives/fieldset/description.cjs.map +2 -2
- package/build/form/primitives/fieldset/details.cjs +6 -33
- package/build/form/primitives/fieldset/details.cjs.map +2 -2
- package/build/form/primitives/fieldset/legend.cjs +6 -33
- package/build/form/primitives/fieldset/legend.cjs.map +2 -2
- package/build/form/primitives/fieldset/root.cjs +6 -16
- package/build/form/primitives/fieldset/root.cjs.map +2 -2
- package/build/form/primitives/index.cjs +8 -2
- package/build/form/primitives/index.cjs.map +2 -2
- package/build/form/primitives/input/index.cjs +31 -0
- package/build/form/primitives/input/index.cjs.map +7 -0
- package/build/form/primitives/input/input.cjs +82 -0
- package/build/form/primitives/input/input.cjs.map +7 -0
- package/build/form/primitives/input/types.cjs +19 -0
- package/build/form/primitives/input/types.cjs.map +7 -0
- package/build/form/primitives/input-layout/input-layout.cjs +12 -111
- package/build/form/primitives/input-layout/input-layout.cjs.map +3 -3
- package/build/form/primitives/input-layout/slot.cjs +6 -94
- package/build/form/primitives/input-layout/slot.cjs.map +2 -2
- package/build/form/primitives/select/index.cjs +40 -0
- package/build/form/primitives/select/index.cjs.map +7 -0
- package/build/form/primitives/select/item.cjs +98 -0
- package/build/form/primitives/select/item.cjs.map +7 -0
- package/build/form/primitives/select/popup.cjs +109 -0
- package/build/form/primitives/select/popup.cjs.map +7 -0
- package/build/form/primitives/select/root.cjs +35 -0
- package/build/form/primitives/select/root.cjs.map +7 -0
- package/build/form/primitives/select/trigger.cjs +116 -0
- package/build/form/primitives/select/trigger.cjs.map +7 -0
- package/build/form/primitives/select/types.cjs +19 -0
- package/build/form/primitives/select/types.cjs.map +7 -0
- package/build/index.cjs +19 -0
- package/build/index.cjs.map +2 -2
- package/build/lock-unlock.cjs +37 -0
- package/build/lock-unlock.cjs.map +7 -0
- package/build/stack/stack.cjs +6 -11
- package/build/stack/stack.cjs.map +2 -2
- package/build/tooltip/index.cjs +40 -0
- package/build/tooltip/index.cjs.map +7 -0
- package/build/tooltip/popup.cjs +100 -0
- package/build/tooltip/popup.cjs.map +7 -0
- package/build/tooltip/provider.cjs +35 -0
- package/build/tooltip/provider.cjs.map +7 -0
- package/build/tooltip/root.cjs +35 -0
- package/build/tooltip/root.cjs.map +7 -0
- package/build/tooltip/trigger.cjs +38 -0
- package/build/tooltip/trigger.cjs.map +7 -0
- package/build/tooltip/types.cjs +19 -0
- package/build/tooltip/types.cjs.map +7 -0
- package/build/utils/types.cjs.map +1 -1
- package/build/visually-hidden/visually-hidden.cjs +6 -19
- package/build/visually-hidden/visually-hidden.cjs.map +2 -2
- package/build-module/box/box.mjs +2 -2
- package/build-module/box/box.mjs.map +2 -2
- package/build-module/button/button.mjs +18 -303
- package/build-module/button/button.mjs.map +3 -3
- package/build-module/form/primitives/constants.mjs +10 -0
- package/build-module/form/primitives/constants.mjs.map +7 -0
- package/build-module/form/primitives/field/description.mjs +6 -33
- package/build-module/form/primitives/field/description.mjs.map +2 -2
- package/build-module/form/primitives/field/details.mjs +6 -33
- package/build-module/form/primitives/field/details.mjs.map +2 -2
- package/build-module/form/primitives/field/label.mjs +6 -33
- package/build-module/form/primitives/field/label.mjs.map +2 -2
- package/build-module/form/primitives/field/root.mjs +6 -17
- package/build-module/form/primitives/field/root.mjs.map +2 -2
- package/build-module/form/primitives/fieldset/description.mjs +6 -33
- package/build-module/form/primitives/fieldset/description.mjs.map +2 -2
- package/build-module/form/primitives/fieldset/details.mjs +6 -33
- package/build-module/form/primitives/fieldset/details.mjs.map +2 -2
- package/build-module/form/primitives/fieldset/legend.mjs +6 -33
- package/build-module/form/primitives/fieldset/legend.mjs.map +2 -2
- package/build-module/form/primitives/fieldset/root.mjs +6 -16
- package/build-module/form/primitives/fieldset/root.mjs.map +2 -2
- package/build-module/form/primitives/index.mjs +5 -1
- package/build-module/form/primitives/index.mjs.map +2 -2
- package/build-module/form/primitives/input/index.mjs +6 -0
- package/build-module/form/primitives/input/index.mjs.map +7 -0
- package/build-module/form/primitives/input/input.mjs +47 -0
- package/build-module/form/primitives/input/input.mjs.map +7 -0
- package/build-module/form/primitives/input/types.mjs +1 -0
- package/build-module/form/primitives/input/types.mjs.map +7 -0
- package/build-module/form/primitives/input-layout/input-layout.mjs +12 -111
- package/build-module/form/primitives/input-layout/input-layout.mjs.map +3 -3
- package/build-module/form/primitives/input-layout/slot.mjs +6 -94
- package/build-module/form/primitives/input-layout/slot.mjs.map +2 -2
- package/build-module/form/primitives/select/index.mjs +12 -0
- package/build-module/form/primitives/select/index.mjs.map +7 -0
- package/build-module/form/primitives/select/item.mjs +63 -0
- package/build-module/form/primitives/select/item.mjs.map +7 -0
- package/build-module/form/primitives/select/popup.mjs +76 -0
- package/build-module/form/primitives/select/popup.mjs.map +7 -0
- package/build-module/form/primitives/select/root.mjs +10 -0
- package/build-module/form/primitives/select/root.mjs.map +7 -0
- package/build-module/form/primitives/select/trigger.mjs +81 -0
- package/build-module/form/primitives/select/trigger.mjs.map +7 -0
- package/build-module/form/primitives/select/types.mjs +1 -0
- package/build-module/form/primitives/select/types.mjs.map +7 -0
- package/build-module/index.mjs +4 -0
- package/build-module/index.mjs.map +2 -2
- package/build-module/lock-unlock.mjs +11 -0
- package/build-module/lock-unlock.mjs.map +7 -0
- package/build-module/stack/stack.mjs +6 -11
- package/build-module/stack/stack.mjs.map +2 -2
- package/build-module/tooltip/index.mjs +12 -0
- package/build-module/tooltip/index.mjs.map +7 -0
- package/build-module/tooltip/popup.mjs +67 -0
- package/build-module/tooltip/popup.mjs.map +7 -0
- package/build-module/tooltip/provider.mjs +10 -0
- package/build-module/tooltip/provider.mjs.map +7 -0
- package/build-module/tooltip/root.mjs +10 -0
- package/build-module/tooltip/root.mjs.map +7 -0
- package/build-module/tooltip/trigger.mjs +13 -0
- package/build-module/tooltip/trigger.mjs.map +7 -0
- package/build-module/tooltip/types.mjs +1 -0
- package/build-module/tooltip/types.mjs.map +7 -0
- package/build-module/visually-hidden/visually-hidden.mjs +6 -19
- package/build-module/visually-hidden/visually-hidden.mjs.map +2 -2
- package/build-types/badge/stories/choosing-intent.story.d.ts +17 -0
- package/build-types/badge/stories/choosing-intent.story.d.ts.map +1 -0
- package/build-types/badge/stories/index.story.d.ts +1 -1
- package/build-types/badge/stories/index.story.d.ts.map +1 -1
- package/build-types/box/stories/index.story.d.ts +1 -1
- package/build-types/box/stories/index.story.d.ts.map +1 -1
- package/build-types/button/stories/index.story.d.ts +1 -1
- package/build-types/button/stories/index.story.d.ts.map +1 -1
- package/build-types/form/primitives/constants.d.ts +9 -0
- package/build-types/form/primitives/constants.d.ts.map +1 -0
- package/build-types/form/primitives/field/stories/index.story.d.ts +1 -1
- package/build-types/form/primitives/field/stories/index.story.d.ts.map +1 -1
- package/build-types/form/primitives/fieldset/stories/index.story.d.ts +1 -1
- package/build-types/form/primitives/fieldset/stories/index.story.d.ts.map +1 -1
- package/build-types/form/primitives/index.d.ts +2 -0
- package/build-types/form/primitives/index.d.ts.map +1 -1
- package/build-types/form/primitives/input/index.d.ts +2 -0
- package/build-types/form/primitives/input/index.d.ts.map +1 -0
- package/build-types/form/primitives/input/input.d.ts +10 -0
- package/build-types/form/primitives/input/input.d.ts.map +1 -0
- package/build-types/form/primitives/input/stories/index.story.d.ts +13 -0
- package/build-types/form/primitives/input/stories/index.story.d.ts.map +1 -0
- package/build-types/form/primitives/input/test/index.test.d.ts +2 -0
- package/build-types/form/primitives/input/test/index.test.d.ts.map +1 -0
- package/build-types/form/primitives/input/types.d.ts +27 -0
- package/build-types/form/primitives/input/types.d.ts.map +1 -0
- package/build-types/form/primitives/input-layout/stories/index.story.d.ts +1 -1
- package/build-types/form/primitives/input-layout/stories/index.story.d.ts.map +1 -1
- package/build-types/form/primitives/select/index.d.ts +5 -0
- package/build-types/form/primitives/select/index.d.ts.map +1 -0
- package/build-types/form/primitives/select/item.d.ts +7 -0
- package/build-types/form/primitives/select/item.d.ts.map +1 -0
- package/build-types/form/primitives/select/popup.d.ts +2 -0
- package/build-types/form/primitives/select/popup.d.ts.map +1 -0
- package/build-types/form/primitives/select/root.d.ts +3 -0
- package/build-types/form/primitives/select/root.d.ts.map +1 -0
- package/build-types/form/primitives/select/stories/index.story.d.ts +50 -0
- package/build-types/form/primitives/select/stories/index.story.d.ts.map +1 -0
- package/build-types/form/primitives/select/test/index.test.d.ts +2 -0
- package/build-types/form/primitives/select/test/index.test.d.ts.map +1 -0
- package/build-types/form/primitives/select/trigger.d.ts +7 -0
- package/build-types/form/primitives/select/trigger.d.ts.map +1 -0
- package/build-types/form/primitives/select/types.d.ts +42 -0
- package/build-types/form/primitives/select/types.d.ts.map +1 -0
- package/build-types/icon/stories/index.story.d.ts +1 -1
- package/build-types/icon/stories/index.story.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/lock-unlock.d.ts +2 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/build-types/stack/stories/index.story.d.ts +1 -1
- package/build-types/stack/stories/index.story.d.ts.map +1 -1
- package/build-types/tooltip/index.d.ts +6 -0
- package/build-types/tooltip/index.d.ts.map +1 -0
- package/build-types/tooltip/popup.d.ts +4 -0
- package/build-types/tooltip/popup.d.ts.map +1 -0
- package/build-types/tooltip/provider.d.ts +4 -0
- package/build-types/tooltip/provider.d.ts.map +1 -0
- package/build-types/tooltip/root.d.ts +4 -0
- package/build-types/tooltip/root.d.ts.map +1 -0
- package/build-types/tooltip/stories/index.story.d.ts +23 -0
- package/build-types/tooltip/stories/index.story.d.ts.map +1 -0
- package/build-types/tooltip/test/index.test.d.ts +2 -0
- package/build-types/tooltip/test/index.test.d.ts.map +1 -0
- package/build-types/tooltip/trigger.d.ts +4 -0
- package/build-types/tooltip/trigger.d.ts.map +1 -0
- package/build-types/tooltip/types.d.ts +18 -0
- package/build-types/tooltip/types.d.ts.map +1 -0
- package/build-types/utils/types.d.ts +0 -3
- package/build-types/utils/types.d.ts.map +1 -1
- package/build-types/visually-hidden/stories/index.story.d.ts +1 -1
- package/build-types/visually-hidden/stories/index.story.d.ts.map +1 -1
- package/package.json +12 -10
- package/src/badge/stories/choosing-intent.mdx +29 -32
- package/src/badge/stories/choosing-intent.story.tsx +129 -0
- package/src/badge/stories/index.story.tsx +1 -1
- package/src/box/box.tsx +2 -2
- package/src/box/stories/index.story.tsx +1 -1
- package/src/box/test/box.test.tsx +0 -11
- package/src/button/stories/index.story.tsx +1 -6
- package/src/button/style.module.css +2 -2
- package/src/button/test/button.test.tsx +1 -16
- package/src/form/primitives/constants.ts +10 -0
- package/src/form/primitives/field/stories/index.story.tsx +1 -1
- package/src/form/primitives/fieldset/stories/index.story.tsx +1 -1
- package/src/form/primitives/index.ts +2 -0
- package/src/form/primitives/input/index.ts +1 -0
- package/src/form/primitives/input/input.tsx +28 -0
- package/src/form/primitives/input/stories/index.story.tsx +40 -0
- package/src/form/primitives/input/style.module.css +34 -0
- package/src/form/primitives/input/test/index.test.tsx +13 -0
- package/src/form/primitives/input/types.ts +31 -0
- package/src/form/primitives/input-layout/stories/index.story.tsx +1 -1
- package/src/form/primitives/input-layout/style.module.css +5 -4
- package/src/form/primitives/select/index.ts +4 -0
- package/src/form/primitives/select/item.tsx +39 -0
- package/src/form/primitives/select/popup.tsx +55 -0
- package/src/form/primitives/select/root.tsx +6 -0
- package/src/form/primitives/select/stories/index.story.tsx +276 -0
- package/src/form/primitives/select/style.module.css +7 -0
- package/src/form/primitives/select/test/index.test.tsx +35 -0
- package/src/form/primitives/select/trigger.tsx +58 -0
- package/src/form/primitives/select/types.ts +52 -0
- package/src/icon/stories/index.story.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/lock-unlock.ts +7 -0
- package/src/stack/stories/index.story.tsx +1 -1
- package/src/stories/introduction.mdx +1 -1
- package/src/tooltip/index.ts +6 -0
- package/src/tooltip/popup.tsx +64 -0
- package/src/tooltip/provider.tsx +8 -0
- package/src/tooltip/root.tsx +8 -0
- package/src/tooltip/stories/index.story.tsx +97 -0
- package/src/tooltip/style.module.css +20 -0
- package/src/tooltip/test/index.test.tsx +87 -0
- package/src/tooltip/trigger.tsx +15 -0
- package/src/tooltip/types.ts +26 -0
- package/src/utils/css/dropdown-motion.module.css +47 -0
- package/src/utils/css/focus.module.css +1 -1
- package/src/utils/css/item-popup.module.css +127 -0
- package/src/utils/css/select-trigger.module.css +58 -0
- package/src/utils/types.ts +0 -3
- package/src/visually-hidden/stories/index.story.tsx +1 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { createRef } from '@wordpress/element';
|
|
4
|
+
import * as Tooltip from '../index';
|
|
5
|
+
import type { ProviderProps } from '../types';
|
|
6
|
+
|
|
7
|
+
// Test wrapper that sets delay={0} to avoid real-time delays in tests.
|
|
8
|
+
function TestProvider( { children, ...props }: ProviderProps ) {
|
|
9
|
+
return (
|
|
10
|
+
<Tooltip.Provider delay={ 0 } { ...props }>
|
|
11
|
+
{ children }
|
|
12
|
+
</Tooltip.Provider>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
describe( 'Tooltip', () => {
|
|
17
|
+
it( 'forwards ref', async () => {
|
|
18
|
+
const user = userEvent.setup();
|
|
19
|
+
const triggerRef = createRef< HTMLButtonElement >();
|
|
20
|
+
const popupRef = createRef< HTMLDivElement >();
|
|
21
|
+
|
|
22
|
+
render(
|
|
23
|
+
<TestProvider>
|
|
24
|
+
<Tooltip.Root>
|
|
25
|
+
<Tooltip.Trigger ref={ triggerRef }>
|
|
26
|
+
<span>Hover me</span>
|
|
27
|
+
</Tooltip.Trigger>
|
|
28
|
+
<Tooltip.Popup ref={ popupRef }>Tooltip text</Tooltip.Popup>
|
|
29
|
+
</Tooltip.Root>
|
|
30
|
+
</TestProvider>
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
// Test trigger ref before interaction
|
|
34
|
+
expect( triggerRef.current ).toBeInstanceOf( HTMLButtonElement );
|
|
35
|
+
|
|
36
|
+
// Hover over the trigger to open the tooltip
|
|
37
|
+
await user.hover( triggerRef.current! );
|
|
38
|
+
|
|
39
|
+
// Wait for the tooltip popup to appear
|
|
40
|
+
await waitFor( () => {
|
|
41
|
+
expect( popupRef.current ).toBeInstanceOf( HTMLDivElement );
|
|
42
|
+
} );
|
|
43
|
+
} );
|
|
44
|
+
|
|
45
|
+
it( 'shows tooltip on hover', async () => {
|
|
46
|
+
const user = userEvent.setup();
|
|
47
|
+
|
|
48
|
+
render(
|
|
49
|
+
<TestProvider>
|
|
50
|
+
<Tooltip.Root>
|
|
51
|
+
<Tooltip.Trigger>Hover me</Tooltip.Trigger>
|
|
52
|
+
<Tooltip.Popup>Tooltip content</Tooltip.Popup>
|
|
53
|
+
</Tooltip.Root>
|
|
54
|
+
</TestProvider>
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const trigger = screen.getByRole( 'button', { name: 'Hover me' } );
|
|
58
|
+
await user.hover( trigger );
|
|
59
|
+
|
|
60
|
+
// waitFor is used intentionally: even with delay={0}, the popup appearing
|
|
61
|
+
// is conceptually async (state change → render → portal mount). This also
|
|
62
|
+
// makes the test resilient to future internal changes in base-ui.
|
|
63
|
+
await waitFor( () => {
|
|
64
|
+
expect( screen.getByText( 'Tooltip content' ) ).toBeVisible();
|
|
65
|
+
} );
|
|
66
|
+
} );
|
|
67
|
+
|
|
68
|
+
it( 'does not show tooltip when disabled', async () => {
|
|
69
|
+
const user = userEvent.setup();
|
|
70
|
+
|
|
71
|
+
render(
|
|
72
|
+
<TestProvider>
|
|
73
|
+
<Tooltip.Root disabled>
|
|
74
|
+
<Tooltip.Trigger>Hover me</Tooltip.Trigger>
|
|
75
|
+
<Tooltip.Popup>Tooltip content</Tooltip.Popup>
|
|
76
|
+
</Tooltip.Root>
|
|
77
|
+
</TestProvider>
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const trigger = screen.getByRole( 'button', { name: 'Hover me' } );
|
|
81
|
+
await user.hover( trigger );
|
|
82
|
+
|
|
83
|
+
expect(
|
|
84
|
+
screen.queryByText( 'Tooltip content' )
|
|
85
|
+
).not.toBeInTheDocument();
|
|
86
|
+
} );
|
|
87
|
+
} );
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Tooltip } from '@base-ui/react/tooltip';
|
|
2
|
+
import { forwardRef } from '@wordpress/element';
|
|
3
|
+
import type { TriggerProps } from './types';
|
|
4
|
+
|
|
5
|
+
const Trigger = forwardRef< HTMLButtonElement, TriggerProps >(
|
|
6
|
+
function TooltipTrigger( { children, ...props }, ref ) {
|
|
7
|
+
return (
|
|
8
|
+
<Tooltip.Trigger ref={ ref } { ...props }>
|
|
9
|
+
{ children }
|
|
10
|
+
</Tooltip.Trigger>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export { Trigger };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Tooltip } from '@base-ui/react/tooltip';
|
|
3
|
+
import type { ComponentProps } from '../utils/types';
|
|
4
|
+
|
|
5
|
+
export type RootProps = Pick< Tooltip.Root.Props, 'disabled' | 'children' >;
|
|
6
|
+
|
|
7
|
+
export type ProviderProps = Pick<
|
|
8
|
+
Tooltip.Provider.Props,
|
|
9
|
+
'delay' | 'children'
|
|
10
|
+
>;
|
|
11
|
+
|
|
12
|
+
export interface TriggerProps extends ComponentProps< 'button' > {
|
|
13
|
+
/**
|
|
14
|
+
* The content to be rendered inside the component.
|
|
15
|
+
*/
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface PopupProps
|
|
20
|
+
extends ComponentProps< 'div' >,
|
|
21
|
+
Pick< Tooltip.Positioner.Props, 'align' | 'side' | 'sideOffset' > {
|
|
22
|
+
/**
|
|
23
|
+
* The content to be rendered inside the component.
|
|
24
|
+
*/
|
|
25
|
+
children?: ReactNode;
|
|
26
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Motion configuration for dropdown-like popovers.
|
|
3
|
+
* Keep constants in sync with: packages/components/src/utils/dropdown-motion.ts
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;
|
|
7
|
+
|
|
8
|
+
@layer wp-ui-utilities {
|
|
9
|
+
.dropdown-motion {
|
|
10
|
+
--wp-ui-dropdown-slide-distance: 4px;
|
|
11
|
+
--wp-ui-dropdown-slide-duration: 200ms;
|
|
12
|
+
--wp-ui-dropdown-slide-easing: cubic-bezier(0, 0, 0, 1);
|
|
13
|
+
--wp-ui-dropdown-fade-duration: 80ms;
|
|
14
|
+
--wp-ui-dropdown-fade-easing: linear;
|
|
15
|
+
|
|
16
|
+
@media not ( prefers-reduced-motion ) {
|
|
17
|
+
transition-property: transform, opacity;
|
|
18
|
+
transition-duration:
|
|
19
|
+
var(--wp-ui-dropdown-slide-duration),
|
|
20
|
+
var(--wp-ui-dropdown-fade-duration);
|
|
21
|
+
transition-timing-function:
|
|
22
|
+
var(--wp-ui-dropdown-slide-easing),
|
|
23
|
+
var(--wp-ui-dropdown-fade-easing);
|
|
24
|
+
will-change: transform, opacity;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
opacity: 0;
|
|
28
|
+
|
|
29
|
+
&[data-side="bottom"] {
|
|
30
|
+
transform: translateY(calc(-1 * var(--wp-ui-dropdown-slide-distance)));
|
|
31
|
+
}
|
|
32
|
+
&[data-side="top"] {
|
|
33
|
+
transform: translateY(var(--wp-ui-dropdown-slide-distance));
|
|
34
|
+
}
|
|
35
|
+
&[data-side="left"] {
|
|
36
|
+
transform: translateX(var(--wp-ui-dropdown-slide-distance));
|
|
37
|
+
}
|
|
38
|
+
&[data-side="right"] {
|
|
39
|
+
transform: translateX(calc(-1 * var(--wp-ui-dropdown-slide-distance)));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&[data-open]:not([data-starting-style]) {
|
|
43
|
+
opacity: 1;
|
|
44
|
+
transform: translate(0);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
.outset-ring--focus-within:focus-within,
|
|
26
26
|
.outset-ring--focus-within-except-active:focus-within:not(:has(:active)),
|
|
27
27
|
.outset-ring--focus-within-visible:focus-within:has(:focus-visible) {
|
|
28
|
-
outline-width: var(--wpds-border-width-
|
|
28
|
+
outline-width: var(--wpds-border-width-focus);
|
|
29
29
|
outline-color: var(--wpds-color-stroke-focus-brand);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;
|
|
2
|
+
|
|
3
|
+
@layer wp-ui-utilities {
|
|
4
|
+
.popup {
|
|
5
|
+
composes: dropdown-motion from "./dropdown-motion.module.css";
|
|
6
|
+
|
|
7
|
+
--wp-ui-popup-padding: 4px;
|
|
8
|
+
|
|
9
|
+
display: grid;
|
|
10
|
+
grid-template-rows: auto minmax(0, 1fr);
|
|
11
|
+
grid-template-areas: "header" "main";
|
|
12
|
+
max-height: min(var(--available-height), 480px, 60dvh);
|
|
13
|
+
min-width: var(--anchor-width);
|
|
14
|
+
max-width: var(--available-width);
|
|
15
|
+
border-radius: var(--wpds-border-radius-md);
|
|
16
|
+
border: 1px solid var(--wpds-color-stroke-surface-neutral);
|
|
17
|
+
box-shadow: var(--wpds-elevation-medium);
|
|
18
|
+
background-color: var(--wpds-color-bg-surface-neutral-strong);
|
|
19
|
+
font-family: var(--wpds-font-family-body);
|
|
20
|
+
font-size: var(--wpds-font-size-md);
|
|
21
|
+
line-height: 1.4;
|
|
22
|
+
color: var(--wpds-color-fg-interactive-neutral);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.list {
|
|
26
|
+
display: grid;
|
|
27
|
+
grid-area: main;
|
|
28
|
+
grid-template-rows: minmax(0, 1fr) auto;
|
|
29
|
+
grid-template-areas: "scrollable" "footer";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.list-scrollable-container {
|
|
33
|
+
overflow-block: auto;
|
|
34
|
+
overscroll-behavior: contain;
|
|
35
|
+
grid-area: scrollable;
|
|
36
|
+
scroll-padding-block: var(--wp-ui-popup-padding);
|
|
37
|
+
|
|
38
|
+
&:not(:empty) {
|
|
39
|
+
padding-block: var(--wp-ui-popup-padding);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.list-footer {
|
|
44
|
+
grid-area: footer;
|
|
45
|
+
padding-block: var(--wp-ui-popup-padding);
|
|
46
|
+
|
|
47
|
+
.list-scrollable-container:not(:empty) + & {
|
|
48
|
+
border-block-start: 1px solid var(--wpds-color-stroke-surface-neutral);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* TODO: Use padding token */
|
|
53
|
+
.item {
|
|
54
|
+
--wp-ui-popup-item-height: 40px;
|
|
55
|
+
--wp-ui-popup-item-padding-inline: 12px;
|
|
56
|
+
--wp-ui-popup-item-padding-block: 4px;
|
|
57
|
+
|
|
58
|
+
display: grid;
|
|
59
|
+
grid-template-columns: 24px 1fr;
|
|
60
|
+
align-items: center;
|
|
61
|
+
justify-content: flex-start;
|
|
62
|
+
gap: var(--wpds-dimension-gap-2xs);
|
|
63
|
+
min-height: var(--wp-ui-popup-item-height);
|
|
64
|
+
border-radius: var(--wpds-border-radius-sm);
|
|
65
|
+
user-select: none;
|
|
66
|
+
margin-inline: var(--wp-ui-popup-padding);
|
|
67
|
+
padding-block: var(--wp-ui-popup-item-padding-block);
|
|
68
|
+
|
|
69
|
+
/* Optically adjust the prefix icon to a more balanced position. */
|
|
70
|
+
padding-inline-start: calc(var(--wp-ui-popup-item-padding-inline) - 4px);
|
|
71
|
+
padding-inline-end: var(--wp-ui-popup-item-padding-inline);
|
|
72
|
+
|
|
73
|
+
&.is-size-compact {
|
|
74
|
+
--wp-ui-popup-item-height: 32px;
|
|
75
|
+
--wp-ui-popup-item-padding-inline: 8px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&.is-size-small {
|
|
79
|
+
--wp-ui-popup-item-height: 24px;
|
|
80
|
+
--wp-ui-popup-item-padding-inline: 8px;
|
|
81
|
+
--wp-ui-popup-item-padding-block: 2px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&:not([data-selected]) {
|
|
85
|
+
.item-indicator-icon {
|
|
86
|
+
opacity: 0;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&[data-highlighted]:not([aria-disabled="true"]) {
|
|
91
|
+
background-color: var(--wpds-color-bg-interactive-brand-weak-active);
|
|
92
|
+
color: var(--wpds-color-fg-interactive-neutral);
|
|
93
|
+
|
|
94
|
+
@media ( forced-colors: active ) {
|
|
95
|
+
outline: 1px solid Highlight;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&[aria-disabled="true"] {
|
|
100
|
+
color: var(--wpds-color-fg-interactive-neutral-disabled);
|
|
101
|
+
|
|
102
|
+
@media ( forced-colors: active ) {
|
|
103
|
+
color: GrayText;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.item-indicator {
|
|
109
|
+
justify-self: center;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.empty {
|
|
113
|
+
--wp-ui-popup-empty-min-height: 40px;
|
|
114
|
+
--wp-ui-popup-empty-padding-inline: 12px;
|
|
115
|
+
|
|
116
|
+
grid-area: main;
|
|
117
|
+
display: flex;
|
|
118
|
+
align-items: center;
|
|
119
|
+
padding-inline: var(--wp-ui-popup-empty-padding-inline);
|
|
120
|
+
color: var(--wpds-color-fg-content-neutral-weak);
|
|
121
|
+
|
|
122
|
+
&:not(:empty) {
|
|
123
|
+
min-height: var(--wp-ui-popup-empty-min-height);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;
|
|
2
|
+
|
|
3
|
+
@layer wp-ui-utilities {
|
|
4
|
+
.trigger-wrapper {
|
|
5
|
+
&.is-minimal {
|
|
6
|
+
width: fit-content;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.trigger {
|
|
11
|
+
display: flex;
|
|
12
|
+
justify-content: space-between;
|
|
13
|
+
align-items: center;
|
|
14
|
+
gap: var(--wpds-dimension-gap-2xs);
|
|
15
|
+
width: 100%;
|
|
16
|
+
padding-block: 4px;
|
|
17
|
+
|
|
18
|
+
/* Optically adjust the caret to a more balanced position. */
|
|
19
|
+
padding-inline-start: var(--wp-ui-input-layout-padding-inline);
|
|
20
|
+
padding-inline-end: calc(var(--wp-ui-input-layout-padding-inline) - 4px);
|
|
21
|
+
|
|
22
|
+
background-color: transparent;
|
|
23
|
+
border: none;
|
|
24
|
+
color: var(--wpds-color-fg-interactive-neutral);
|
|
25
|
+
font-family: inherit;
|
|
26
|
+
font-size: inherit;
|
|
27
|
+
line-height: 1.4;
|
|
28
|
+
text-align: start;
|
|
29
|
+
user-select: none;
|
|
30
|
+
|
|
31
|
+
&.is-minimal {
|
|
32
|
+
width: auto;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&:focus {
|
|
36
|
+
outline: none; /* handled by InputLayout component */
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&[data-disabled] {
|
|
40
|
+
background-color: var(--wpds-color-bg-interactive-neutral-weak-disabled);
|
|
41
|
+
color: var(--wpds-color-fg-interactive-neutral-disabled);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.trigger-value {
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
text-overflow: ellipsis;
|
|
48
|
+
white-space: nowrap;
|
|
49
|
+
|
|
50
|
+
&.is-placeholder {
|
|
51
|
+
color: var(--wpds-color-fg-interactive-neutral-disabled);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.trigger-caret {
|
|
56
|
+
flex: 0 0 auto;
|
|
57
|
+
}
|
|
58
|
+
}
|
package/src/utils/types.ts
CHANGED