@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,129 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { Badge } from '../index';
|
|
3
|
+
import { Stack } from '../../stack';
|
|
4
|
+
|
|
5
|
+
const meta: Meta< typeof Badge > = {
|
|
6
|
+
title: 'Design System/Components/Badge/Choosing intent',
|
|
7
|
+
component: Badge,
|
|
8
|
+
decorators: [
|
|
9
|
+
( Story ) => (
|
|
10
|
+
<Stack direction="row" gap="xs" wrap="wrap">
|
|
11
|
+
<Story />
|
|
12
|
+
</Stack>
|
|
13
|
+
),
|
|
14
|
+
],
|
|
15
|
+
parameters: {
|
|
16
|
+
controls: { disable: true },
|
|
17
|
+
},
|
|
18
|
+
tags: [ '!dev' /* Hide individual story pages from sidebar */ ],
|
|
19
|
+
};
|
|
20
|
+
export default meta;
|
|
21
|
+
|
|
22
|
+
type Story = StoryObj< typeof Badge >;
|
|
23
|
+
|
|
24
|
+
export const AllIntents: Story = {
|
|
25
|
+
render: () => (
|
|
26
|
+
<>
|
|
27
|
+
<Badge intent="high">high</Badge>
|
|
28
|
+
<Badge intent="medium">medium</Badge>
|
|
29
|
+
<Badge intent="low">low</Badge>
|
|
30
|
+
<Badge intent="stable">stable</Badge>
|
|
31
|
+
<Badge intent="informational">informational</Badge>
|
|
32
|
+
<Badge intent="draft">draft</Badge>
|
|
33
|
+
<Badge intent="none">none</Badge>
|
|
34
|
+
</>
|
|
35
|
+
),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const High: Story = {
|
|
39
|
+
render: () => (
|
|
40
|
+
<>
|
|
41
|
+
<Badge intent="high">Payment declined</Badge>
|
|
42
|
+
<Badge intent="high">Security issue</Badge>
|
|
43
|
+
</>
|
|
44
|
+
),
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const Medium: Story = {
|
|
48
|
+
render: () => (
|
|
49
|
+
<>
|
|
50
|
+
<Badge intent="medium">Approval required</Badge>
|
|
51
|
+
<Badge intent="medium">Review needed</Badge>
|
|
52
|
+
</>
|
|
53
|
+
),
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const Low: Story = {
|
|
57
|
+
render: () => (
|
|
58
|
+
<>
|
|
59
|
+
<Badge intent="low">Pending</Badge>
|
|
60
|
+
<Badge intent="low">Queued</Badge>
|
|
61
|
+
</>
|
|
62
|
+
),
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const Informational: Story = {
|
|
66
|
+
render: () => (
|
|
67
|
+
<>
|
|
68
|
+
<Badge intent="informational">Scheduled</Badge>
|
|
69
|
+
<Badge intent="informational">Beta</Badge>
|
|
70
|
+
</>
|
|
71
|
+
),
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const Draft: Story = {
|
|
75
|
+
render: () => (
|
|
76
|
+
<>
|
|
77
|
+
<Badge intent="draft">Draft</Badge>
|
|
78
|
+
<Badge intent="draft">Unpublished</Badge>
|
|
79
|
+
</>
|
|
80
|
+
),
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const Stable: Story = {
|
|
84
|
+
render: () => (
|
|
85
|
+
<>
|
|
86
|
+
<Badge intent="stable">Healthy</Badge>
|
|
87
|
+
<Badge intent="stable">Active</Badge>
|
|
88
|
+
</>
|
|
89
|
+
),
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const None: Story = {
|
|
93
|
+
render: () => (
|
|
94
|
+
<>
|
|
95
|
+
<Badge intent="none">Inactive</Badge>
|
|
96
|
+
<Badge intent="none">Expired</Badge>
|
|
97
|
+
</>
|
|
98
|
+
),
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const CommentStatus: Story = {
|
|
102
|
+
render: () => (
|
|
103
|
+
<>
|
|
104
|
+
<Badge intent="none">Approved</Badge>
|
|
105
|
+
<Badge intent="medium">Approval required</Badge>
|
|
106
|
+
</>
|
|
107
|
+
),
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export const PageStatus: Story = {
|
|
111
|
+
render: () => (
|
|
112
|
+
<>
|
|
113
|
+
<Badge intent="none">Published</Badge>
|
|
114
|
+
<Badge intent="low">Pending</Badge>
|
|
115
|
+
<Badge intent="draft">Draft</Badge>
|
|
116
|
+
<Badge intent="informational">Scheduled</Badge>
|
|
117
|
+
<Badge intent="informational">Private</Badge>
|
|
118
|
+
</>
|
|
119
|
+
),
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const PluginStatus: Story = {
|
|
123
|
+
render: () => (
|
|
124
|
+
<>
|
|
125
|
+
<Badge intent="stable">Active</Badge>
|
|
126
|
+
<Badge intent="none">Inactive</Badge>
|
|
127
|
+
</>
|
|
128
|
+
),
|
|
129
|
+
};
|
package/src/box/box.tsx
CHANGED
|
@@ -96,11 +96,11 @@ export const Box = forwardRef< HTMLDivElement, BoxProps >( function Box(
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
if ( borderRadius ) {
|
|
99
|
-
style.borderRadius = `var(--wpds-border-radius-${ target }-${ borderRadius }, var(--wpds-border-radius
|
|
99
|
+
style.borderRadius = `var(--wpds-border-radius-${ target }-${ borderRadius }, var(--wpds-border-radius-${ borderRadius }))`;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
if ( borderWidth ) {
|
|
103
|
-
style.borderWidth = `var(--wpds-border-width-${ target }-${ borderWidth }, var(--wpds-border-width
|
|
103
|
+
style.borderWidth = `var(--wpds-border-width-${ target }-${ borderWidth }, var(--wpds-border-width-${ borderWidth }))`;
|
|
104
104
|
style.borderStyle = 'solid';
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { render, screen } from '@testing-library/react';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
2
|
import { createRef } from '@wordpress/element';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
3
|
import { Box } from '../box';
|
|
15
4
|
|
|
16
5
|
describe( 'Box', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, useState } from '@wordpress/element';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react-
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
3
|
import { cog } from '@wordpress/icons';
|
|
4
4
|
import { Button } from '../index';
|
|
5
5
|
|
|
@@ -131,11 +131,6 @@ export const AllTonesAndVariants: Story = {
|
|
|
131
131
|
{ ...args }
|
|
132
132
|
tone={ tone }
|
|
133
133
|
variant={ variant }
|
|
134
|
-
// Disabling because this lint rule was meant for the
|
|
135
|
-
// `@wordpress/components` Button, but is being applied here.
|
|
136
|
-
// TODO: rework the lint rule so that it checks the package
|
|
137
|
-
// where the Button comes from.
|
|
138
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
139
134
|
disabled
|
|
140
135
|
/>
|
|
141
136
|
</div>
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
border-style: solid;
|
|
40
40
|
border-width: 1px;
|
|
41
41
|
border-color: var(--wp-ui-button-border-color);
|
|
42
|
-
border-radius: var(--wpds-border-radius-
|
|
42
|
+
border-radius: var(--wpds-border-radius-sm);
|
|
43
43
|
background-color: var(--wp-ui-button-background-color);
|
|
44
44
|
background-clip: padding-box;
|
|
45
45
|
font-family: var(--wpds-font-family-body);
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
height: var(--wp-ui-button-font-size);
|
|
103
103
|
aspect-ratio: 1;
|
|
104
104
|
|
|
105
|
-
border: var(--wpds-border-width-
|
|
105
|
+
border: var(--wpds-border-width-focus) solid;
|
|
106
106
|
border-block-start-color: var(--wp-ui-button-foreground-color);
|
|
107
107
|
border-inline-end-color: var(--wp-ui-button-foreground-color);
|
|
108
108
|
border-block-end-color: transparent;
|
|
@@ -25,11 +25,6 @@ describe( 'Button', () => {
|
|
|
25
25
|
|
|
26
26
|
const onClickMock = jest.fn();
|
|
27
27
|
render(
|
|
28
|
-
// Disabling because this lint rule was meant for the
|
|
29
|
-
// `@wordpress/components` Button, but is being applied here.
|
|
30
|
-
// TODO: rework the lint rule so that it checks the package
|
|
31
|
-
// where the Button comes from.
|
|
32
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
33
28
|
<Button disabled onClick={ onClickMock }>
|
|
34
29
|
Click me
|
|
35
30
|
</Button>
|
|
@@ -57,12 +52,6 @@ describe( 'Button', () => {
|
|
|
57
52
|
|
|
58
53
|
it( 'can be enabled explicitly when loading', () => {
|
|
59
54
|
render(
|
|
60
|
-
// Disabling because this lint rule was meant for the
|
|
61
|
-
// `@wordpress/components` Button, but is being applied here.
|
|
62
|
-
// TODO: rework the lint rule so that it checks the package
|
|
63
|
-
// where the Button comes from.
|
|
64
|
-
// TODO: Additional improvement in the original lint rule: only error if disabled=true?
|
|
65
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
66
55
|
<Button loading disabled={ false }>
|
|
67
56
|
Click me
|
|
68
57
|
</Button>
|
|
@@ -76,11 +65,7 @@ describe( 'Button', () => {
|
|
|
76
65
|
|
|
77
66
|
it( 'supports custom render prop while retaining the default focusable when disabled behavior', () => {
|
|
78
67
|
render(
|
|
79
|
-
//
|
|
80
|
-
// `@wordpress/components` Button, but is being applied here.
|
|
81
|
-
// TODO: rework the lint rule so that it checks the package
|
|
82
|
-
// where the Button comes from.
|
|
83
|
-
// eslint-disable-next-line jsx-a11y/anchor-has-content, no-restricted-syntax
|
|
68
|
+
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
84
69
|
<Button render={ <a href="/" /> } nativeButton={ false } disabled>
|
|
85
70
|
Click me
|
|
86
71
|
</Button>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Select as _Select } from '@base-ui/react/select';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared positioning props for item popups (Select, Combobox, etc.).
|
|
5
|
+
*/
|
|
6
|
+
export const ITEM_POPUP_POSITIONER_PROPS = {
|
|
7
|
+
align: 'start',
|
|
8
|
+
sideOffset: 8,
|
|
9
|
+
collisionPadding: 12,
|
|
10
|
+
} satisfies Partial< _Select.Positioner.Props >;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Input } from './input';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Input as _Input } from '@base-ui/react/input';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { forwardRef } from '@wordpress/element';
|
|
4
|
+
import focusStyles from '../../../utils/css/focus.module.css';
|
|
5
|
+
import styles from './style.module.css';
|
|
6
|
+
import type { InputProps } from './types';
|
|
7
|
+
import { InputLayout } from '../input-layout';
|
|
8
|
+
|
|
9
|
+
export const Input = forwardRef< HTMLInputElement, InputProps >( function Input(
|
|
10
|
+
{ className, size = 'default', prefix, suffix, style, ...restProps },
|
|
11
|
+
ref
|
|
12
|
+
) {
|
|
13
|
+
return (
|
|
14
|
+
<InputLayout
|
|
15
|
+
className={ clsx(
|
|
16
|
+
focusStyles[ 'outset-ring--focus-within' ],
|
|
17
|
+
className
|
|
18
|
+
) }
|
|
19
|
+
style={ style }
|
|
20
|
+
size={ size }
|
|
21
|
+
visuallyDisabled={ restProps.disabled }
|
|
22
|
+
prefix={ prefix }
|
|
23
|
+
suffix={ suffix }
|
|
24
|
+
>
|
|
25
|
+
<_Input ref={ ref } className={ styles.input } { ...restProps } />
|
|
26
|
+
</InputLayout>
|
|
27
|
+
);
|
|
28
|
+
} );
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { Input, InputLayout } from '../../../..';
|
|
3
|
+
|
|
4
|
+
const meta: Meta< typeof Input > = {
|
|
5
|
+
title: 'Design System/Components/Form/Primitives/Input',
|
|
6
|
+
component: Input,
|
|
7
|
+
argTypes: {
|
|
8
|
+
defaultValue: { control: false },
|
|
9
|
+
onValueChange: { action: 'onValueChange' },
|
|
10
|
+
value: { control: false },
|
|
11
|
+
type: { control: 'text' },
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default meta;
|
|
15
|
+
|
|
16
|
+
type Story = StoryObj< typeof Input >;
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
placeholder: 'Placeholder',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The `InputLayout.Slot` component can be used to add standard padding in
|
|
26
|
+
* the `prefix` or `suffix` slot.
|
|
27
|
+
*/
|
|
28
|
+
export const WithPrefix: Story = {
|
|
29
|
+
args: {
|
|
30
|
+
placeholder: 'username',
|
|
31
|
+
prefix: <InputLayout.Slot>@</InputLayout.Slot>,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const Disabled: Story = {
|
|
36
|
+
args: {
|
|
37
|
+
...Default.args,
|
|
38
|
+
disabled: true,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;
|
|
2
|
+
|
|
3
|
+
@layer wp-ui-components {
|
|
4
|
+
.input {
|
|
5
|
+
padding-block: var(--wp-ui-input-padding-block, 0);
|
|
6
|
+
padding-inline: var(--wp-ui-input-layout-padding-inline, 0);
|
|
7
|
+
width: 100%;
|
|
8
|
+
background: transparent;
|
|
9
|
+
border: none;
|
|
10
|
+
outline: none;
|
|
11
|
+
color: var(--wpds-color-fg-interactive-neutral);
|
|
12
|
+
font-family: inherit;
|
|
13
|
+
font-size: inherit;
|
|
14
|
+
line-height: inherit;
|
|
15
|
+
|
|
16
|
+
&::placeholder {
|
|
17
|
+
color: var(--wpds-color-fg-interactive-neutral-disabled);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&:disabled,
|
|
21
|
+
&[aria-disabled="true"] {
|
|
22
|
+
color: var(--wpds-color-fg-interactive-neutral-disabled);
|
|
23
|
+
|
|
24
|
+
@media ( forced-colors: active ) {
|
|
25
|
+
color: GrayText;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&[type="email"],
|
|
30
|
+
&[type="url"] {
|
|
31
|
+
direction: ltr; /* maintain LTR in RTL languages */
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { render } from '@testing-library/react';
|
|
2
|
+
import { createRef } from '@wordpress/element';
|
|
3
|
+
import { Input } from '../index';
|
|
4
|
+
|
|
5
|
+
describe( 'Input', () => {
|
|
6
|
+
it( 'forwards ref', () => {
|
|
7
|
+
const ref = createRef< HTMLInputElement >();
|
|
8
|
+
|
|
9
|
+
render( <Input ref={ ref } /> );
|
|
10
|
+
|
|
11
|
+
expect( ref.current ).toBeInstanceOf( HTMLInputElement );
|
|
12
|
+
} );
|
|
13
|
+
} );
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Input } from '@base-ui/react/input';
|
|
2
|
+
import type { InputLayoutProps } from '../input-layout/types';
|
|
3
|
+
import type { ComponentProps } from '../../../utils/types';
|
|
4
|
+
|
|
5
|
+
export type InputProps = Omit<
|
|
6
|
+
ComponentProps< typeof Input >,
|
|
7
|
+
'value' | 'defaultValue' | 'type' | 'disabled' | 'prefix' | 'size'
|
|
8
|
+
> &
|
|
9
|
+
Pick< InputLayoutProps, 'prefix' | 'suffix' > & {
|
|
10
|
+
/**
|
|
11
|
+
* Whether the field is disabled.
|
|
12
|
+
*/
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
} & {
|
|
15
|
+
/**
|
|
16
|
+
* The type of the input element.
|
|
17
|
+
*/
|
|
18
|
+
type?: Input.Props[ 'type' ];
|
|
19
|
+
/**
|
|
20
|
+
* The default value to use in uncontrolled mode.
|
|
21
|
+
*/
|
|
22
|
+
defaultValue?: Input.Props[ 'defaultValue' ];
|
|
23
|
+
/**
|
|
24
|
+
* The value to use in controlled mode.
|
|
25
|
+
*/
|
|
26
|
+
value?: Input.Props[ 'value' ];
|
|
27
|
+
/**
|
|
28
|
+
* The size of the field.
|
|
29
|
+
*/
|
|
30
|
+
size?: Exclude< InputLayoutProps[ 'size' ], 'small' >;
|
|
31
|
+
};
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
display: flex;
|
|
9
9
|
height: 40px;
|
|
10
10
|
background-color: var(--wpds-color-bg-interactive-neutral-weak);
|
|
11
|
-
border-width: var(--wpds-border-width-
|
|
11
|
+
border-width: var(--wpds-border-width-xs);
|
|
12
12
|
border-style: solid;
|
|
13
13
|
border-color: var(--wpds-color-stroke-interactive-neutral);
|
|
14
|
-
border-radius: var(--wpds-border-radius-
|
|
14
|
+
border-radius: var(--wpds-border-radius-sm);
|
|
15
15
|
font-family: var(--wpds-font-family-body);
|
|
16
16
|
font-size: max(var(--wpds-font-size-md), 16px); /* avoid mobile zoom */
|
|
17
17
|
line-height: 1;
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
height: 24px;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
&.is-disabled
|
|
36
|
+
&.is-disabled,
|
|
37
|
+
&:has([data-can-disable-input-layout][data-disabled]) {
|
|
37
38
|
background-color: var(--wpds-color-bg-interactive-neutral-weak-disabled);
|
|
38
39
|
border-color: var(--wpds-color-stroke-interactive-neutral-disabled);
|
|
39
40
|
color: var(--wpds-color-fg-interactive-neutral-disabled);
|
|
@@ -53,7 +54,7 @@
|
|
|
53
54
|
outline: none;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
&:hover:not(.is-disabled, .is-borderless) {
|
|
57
|
+
&:hover:not(.is-disabled, :has([data-can-disable-input-layout][data-disabled]), .is-borderless) {
|
|
57
58
|
border-color: var(--wpds-color-stroke-interactive-neutral-active);
|
|
58
59
|
}
|
|
59
60
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Select as _Select } from '@base-ui/react/select';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { forwardRef } from '@wordpress/element';
|
|
4
|
+
import { check } from '@wordpress/icons';
|
|
5
|
+
import itemPopupStyles from '../../../utils/css/item-popup.module.css';
|
|
6
|
+
import resetStyles from '../../../utils/css/resets.module.css';
|
|
7
|
+
import { Icon } from '../../../icon';
|
|
8
|
+
import type { SelectItemProps } from './types';
|
|
9
|
+
|
|
10
|
+
export const Item = forwardRef< HTMLDivElement, SelectItemProps >(
|
|
11
|
+
function Item(
|
|
12
|
+
{ className, value, size = 'default', children = value, ...restProps },
|
|
13
|
+
ref
|
|
14
|
+
) {
|
|
15
|
+
return (
|
|
16
|
+
<_Select.Item
|
|
17
|
+
className={ clsx(
|
|
18
|
+
resetStyles[ 'box-sizing' ],
|
|
19
|
+
itemPopupStyles.item,
|
|
20
|
+
itemPopupStyles[ `is-size-${ size }` ],
|
|
21
|
+
className
|
|
22
|
+
) }
|
|
23
|
+
value={ value }
|
|
24
|
+
ref={ ref }
|
|
25
|
+
{ ...restProps }
|
|
26
|
+
>
|
|
27
|
+
<Icon
|
|
28
|
+
icon={ check }
|
|
29
|
+
className={ clsx(
|
|
30
|
+
itemPopupStyles[ 'item-indicator' ],
|
|
31
|
+
itemPopupStyles[ 'item-indicator-icon' ]
|
|
32
|
+
) }
|
|
33
|
+
size={ size === 'small' ? 20 : 24 }
|
|
34
|
+
/>
|
|
35
|
+
<_Select.ItemText>{ children }</_Select.ItemText>
|
|
36
|
+
</_Select.Item>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Select as _Select } from '@base-ui/react/select';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { forwardRef } from '@wordpress/element';
|
|
4
|
+
import {
|
|
5
|
+
type ThemeProvider as ThemeProviderType,
|
|
6
|
+
privateApis as themePrivateApis,
|
|
7
|
+
} from '@wordpress/theme';
|
|
8
|
+
import { unlock } from '../../../lock-unlock';
|
|
9
|
+
import itemPopupStyles from '../../../utils/css/item-popup.module.css';
|
|
10
|
+
import resetStyles from '../../../utils/css/resets.module.css';
|
|
11
|
+
import styles from './style.module.css';
|
|
12
|
+
import type { SelectPopupProps } from './types';
|
|
13
|
+
import { ITEM_POPUP_POSITIONER_PROPS } from '../constants';
|
|
14
|
+
|
|
15
|
+
const ThemeProvider: typeof ThemeProviderType =
|
|
16
|
+
unlock( themePrivateApis ).ThemeProvider;
|
|
17
|
+
|
|
18
|
+
export const Popup = forwardRef< HTMLDivElement, SelectPopupProps >(
|
|
19
|
+
function Popup( { className, children, style, ...restProps }, ref ) {
|
|
20
|
+
return (
|
|
21
|
+
<_Select.Portal>
|
|
22
|
+
<_Select.Positioner
|
|
23
|
+
{ ...ITEM_POPUP_POSITIONER_PROPS }
|
|
24
|
+
alignItemWithTrigger={ false }
|
|
25
|
+
style={ style }
|
|
26
|
+
className={ clsx(
|
|
27
|
+
resetStyles[ 'box-sizing' ],
|
|
28
|
+
styles.positioner,
|
|
29
|
+
className
|
|
30
|
+
) }
|
|
31
|
+
>
|
|
32
|
+
<ThemeProvider>
|
|
33
|
+
<_Select.Popup
|
|
34
|
+
ref={ ref }
|
|
35
|
+
className={ itemPopupStyles.popup }
|
|
36
|
+
{ ...restProps }
|
|
37
|
+
>
|
|
38
|
+
<_Select.List className={ itemPopupStyles.list }>
|
|
39
|
+
<div
|
|
40
|
+
className={
|
|
41
|
+
itemPopupStyles[
|
|
42
|
+
'list-scrollable-container'
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
>
|
|
46
|
+
{ children }
|
|
47
|
+
</div>
|
|
48
|
+
</_Select.List>
|
|
49
|
+
</_Select.Popup>
|
|
50
|
+
</ThemeProvider>
|
|
51
|
+
</_Select.Positioner>
|
|
52
|
+
</_Select.Portal>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
);
|