@wordpress/ui 0.6.0 → 0.7.1-next.v.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.
Files changed (147) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/build/badge/badge.cjs +1 -1
  3. package/build/badge/badge.cjs.map +2 -2
  4. package/build/box/box.cjs +3 -7
  5. package/build/box/box.cjs.map +2 -2
  6. package/build/button/button.cjs +3 -3
  7. package/build/button/button.cjs.map +2 -2
  8. package/build/form/primitives/fieldset/root.cjs +3 -3
  9. package/build/form/primitives/fieldset/root.cjs.map +2 -2
  10. package/build/form/primitives/input-layout/input-layout.cjs +3 -3
  11. package/build/form/primitives/input-layout/input-layout.cjs.map +2 -2
  12. package/build/form/primitives/input-layout/slot.cjs +3 -3
  13. package/build/form/primitives/input-layout/slot.cjs.map +2 -2
  14. package/build/form/primitives/select/item.cjs +3 -3
  15. package/build/form/primitives/select/item.cjs.map +2 -2
  16. package/build/form/primitives/select/popup.cjs +3 -3
  17. package/build/form/primitives/select/popup.cjs.map +2 -2
  18. package/build/form/primitives/select/trigger.cjs +3 -3
  19. package/build/form/primitives/select/trigger.cjs.map +2 -2
  20. package/build/icon-button/icon-button.cjs +103 -0
  21. package/build/icon-button/icon-button.cjs.map +7 -0
  22. package/build/icon-button/index.cjs +31 -0
  23. package/build/icon-button/index.cjs.map +7 -0
  24. package/build/icon-button/types.cjs +19 -0
  25. package/build/icon-button/types.cjs.map +7 -0
  26. package/build/index.cjs +5 -0
  27. package/build/index.cjs.map +2 -2
  28. package/build/tabs/index.cjs +40 -0
  29. package/build/tabs/index.cjs.map +7 -0
  30. package/build/tabs/list.cjs +145 -0
  31. package/build/tabs/list.cjs.map +7 -0
  32. package/build/tabs/panel.cjs +67 -0
  33. package/build/tabs/panel.cjs.map +7 -0
  34. package/build/tabs/root.cjs +38 -0
  35. package/build/tabs/root.cjs.map +7 -0
  36. package/build/tabs/tab.cjs +71 -0
  37. package/build/tabs/tab.cjs.map +7 -0
  38. package/build/tabs/types.cjs +19 -0
  39. package/build/tabs/types.cjs.map +7 -0
  40. package/build/tooltip/popup.cjs +3 -3
  41. package/build/tooltip/popup.cjs.map +2 -2
  42. package/build-module/badge/badge.mjs +1 -1
  43. package/build-module/badge/badge.mjs.map +2 -2
  44. package/build-module/box/box.mjs +3 -7
  45. package/build-module/box/box.mjs.map +2 -2
  46. package/build-module/button/button.mjs +3 -3
  47. package/build-module/button/button.mjs.map +2 -2
  48. package/build-module/form/primitives/fieldset/root.mjs +3 -3
  49. package/build-module/form/primitives/fieldset/root.mjs.map +2 -2
  50. package/build-module/form/primitives/input-layout/input-layout.mjs +3 -3
  51. package/build-module/form/primitives/input-layout/input-layout.mjs.map +2 -2
  52. package/build-module/form/primitives/input-layout/slot.mjs +3 -3
  53. package/build-module/form/primitives/input-layout/slot.mjs.map +2 -2
  54. package/build-module/form/primitives/select/item.mjs +3 -3
  55. package/build-module/form/primitives/select/item.mjs.map +2 -2
  56. package/build-module/form/primitives/select/popup.mjs +3 -3
  57. package/build-module/form/primitives/select/popup.mjs.map +2 -2
  58. package/build-module/form/primitives/select/trigger.mjs +3 -3
  59. package/build-module/form/primitives/select/trigger.mjs.map +2 -2
  60. package/build-module/icon-button/icon-button.mjs +68 -0
  61. package/build-module/icon-button/icon-button.mjs.map +7 -0
  62. package/build-module/icon-button/index.mjs +6 -0
  63. package/build-module/icon-button/index.mjs.map +7 -0
  64. package/build-module/icon-button/types.mjs +1 -0
  65. package/build-module/icon-button/types.mjs.map +7 -0
  66. package/build-module/index.mjs +3 -0
  67. package/build-module/index.mjs.map +2 -2
  68. package/build-module/tabs/index.mjs +12 -0
  69. package/build-module/tabs/index.mjs.map +7 -0
  70. package/build-module/tabs/list.mjs +110 -0
  71. package/build-module/tabs/list.mjs.map +7 -0
  72. package/build-module/tabs/panel.mjs +32 -0
  73. package/build-module/tabs/panel.mjs.map +7 -0
  74. package/build-module/tabs/root.mjs +13 -0
  75. package/build-module/tabs/root.mjs.map +7 -0
  76. package/build-module/tabs/tab.mjs +36 -0
  77. package/build-module/tabs/tab.mjs.map +7 -0
  78. package/build-module/tabs/types.mjs +1 -0
  79. package/build-module/tabs/types.mjs.map +7 -0
  80. package/build-module/tooltip/popup.mjs +3 -3
  81. package/build-module/tooltip/popup.mjs.map +2 -2
  82. package/build-types/box/box.d.ts.map +1 -1
  83. package/build-types/box/stories/index.story.d.ts.map +1 -1
  84. package/build-types/button/stories/index.story.d.ts +1 -2
  85. package/build-types/button/stories/index.story.d.ts.map +1 -1
  86. package/build-types/form/primitives/field/stories/index.story.d.ts +0 -1
  87. package/build-types/form/primitives/field/stories/index.story.d.ts.map +1 -1
  88. package/build-types/form/primitives/select/stories/index.story.d.ts +0 -1
  89. package/build-types/form/primitives/select/stories/index.story.d.ts.map +1 -1
  90. package/build-types/icon-button/icon-button.d.ts +13 -0
  91. package/build-types/icon-button/icon-button.d.ts.map +1 -0
  92. package/build-types/icon-button/index.d.ts +2 -0
  93. package/build-types/icon-button/index.d.ts.map +1 -0
  94. package/build-types/icon-button/stories/index.story.d.ts +19 -0
  95. package/build-types/icon-button/stories/index.story.d.ts.map +1 -0
  96. package/build-types/icon-button/test/index.test.d.ts +2 -0
  97. package/build-types/icon-button/test/index.test.d.ts.map +1 -0
  98. package/build-types/icon-button/types.d.ts +36 -0
  99. package/build-types/icon-button/types.d.ts.map +1 -0
  100. package/build-types/index.d.ts +2 -0
  101. package/build-types/index.d.ts.map +1 -1
  102. package/build-types/tabs/index.d.ts +6 -0
  103. package/build-types/tabs/index.d.ts.map +1 -0
  104. package/build-types/tabs/list.d.ts +16 -0
  105. package/build-types/tabs/list.d.ts.map +1 -0
  106. package/build-types/tabs/panel.d.ts +15 -0
  107. package/build-types/tabs/panel.d.ts.map +1 -0
  108. package/build-types/tabs/root.d.ts +15 -0
  109. package/build-types/tabs/root.d.ts.map +1 -0
  110. package/build-types/tabs/stories/index.story.d.ts +13 -0
  111. package/build-types/tabs/stories/index.story.d.ts.map +1 -0
  112. package/build-types/tabs/tab.d.ts +15 -0
  113. package/build-types/tabs/tab.d.ts.map +1 -0
  114. package/build-types/tabs/test/index.test.d.ts +2 -0
  115. package/build-types/tabs/test/index.test.d.ts.map +1 -0
  116. package/build-types/tabs/types.d.ts +33 -0
  117. package/build-types/tabs/types.d.ts.map +1 -0
  118. package/package.json +11 -9
  119. package/src/badge/badge.tsx +1 -1
  120. package/src/box/box.tsx +4 -15
  121. package/src/box/stories/index.story.tsx +9 -1
  122. package/src/button/stories/index.story.tsx +3 -16
  123. package/src/button/style.module.css +6 -3
  124. package/src/form/primitives/field/stories/index.story.tsx +0 -1
  125. package/src/form/primitives/fieldset/style.module.css +1 -1
  126. package/src/form/primitives/input-layout/style.module.css +5 -8
  127. package/src/form/primitives/select/stories/index.story.tsx +0 -1
  128. package/src/icon-button/icon-button.tsx +64 -0
  129. package/src/icon-button/index.ts +1 -0
  130. package/src/icon-button/stories/index.story.tsx +128 -0
  131. package/src/icon-button/style.module.css +9 -0
  132. package/src/icon-button/test/index.test.tsx +86 -0
  133. package/src/icon-button/types.ts +38 -0
  134. package/src/index.ts +2 -0
  135. package/src/tabs/index.ts +6 -0
  136. package/src/tabs/list.tsx +130 -0
  137. package/src/tabs/panel.tsx +23 -0
  138. package/src/tabs/root.tsx +15 -0
  139. package/src/tabs/stories/best-practices.mdx +85 -0
  140. package/src/tabs/stories/index.story.tsx +363 -0
  141. package/src/tabs/style.module.css +269 -0
  142. package/src/tabs/tab.tsx +29 -0
  143. package/src/tabs/test/index.test.tsx +2260 -0
  144. package/src/tabs/types.ts +36 -0
  145. package/src/tooltip/style.module.css +2 -2
  146. package/src/utils/css/item-popup.module.css +1 -1
  147. package/src/utils/css/select-trigger.module.css +1 -1
@@ -0,0 +1,269 @@
1
+ @layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;
2
+
3
+ @layer wp-ui-components {
4
+ .tablist {
5
+ display: flex;
6
+ align-items: stretch;
7
+ overflow-inline: auto;
8
+ overscroll-behavior-inline: none;
9
+
10
+ --direction-factor: 1;
11
+ --direction-start: left;
12
+ --direction-end: right;
13
+
14
+ &:dir(rtl) {
15
+ --direction-factor: -1;
16
+ --direction-start: right;
17
+ --direction-end: left;
18
+ }
19
+
20
+ position: relative;
21
+
22
+ &[data-orientation="horizontal"] {
23
+ --fade-width: 4rem;
24
+ --fade-gradient-base: transparent 0%, #000 var(--fade-width);
25
+ --fade-gradient-composed: var(--fade-gradient-base), #000 60%, transparent 50%;
26
+
27
+ width: fit-content;
28
+
29
+ &.is-overflowing-first {
30
+ mask-image: linear-gradient(to var(--direction-end), var(--fade-gradient-base));
31
+ }
32
+
33
+ &.is-overflowing-last {
34
+ mask-image: linear-gradient(to var(--direction-start), var(--fade-gradient-base));
35
+ }
36
+
37
+ &.is-overflowing-first.is-overflowing-last {
38
+ mask-image:
39
+ linear-gradient(to right, var(--fade-gradient-composed)),
40
+ linear-gradient(to left, var(--fade-gradient-composed));
41
+ }
42
+
43
+ &.is-minimal-variant {
44
+ gap: 1rem;
45
+ }
46
+ }
47
+
48
+ &[data-orientation="vertical"] {
49
+ flex-direction: column;
50
+ }
51
+ }
52
+
53
+ .indicator {
54
+ @media not ( prefers-reduced-motion ) {
55
+ transition-property:
56
+ translate,
57
+ width,
58
+ height,
59
+ border-radius,
60
+ border-block;
61
+ transition-duration: 0.2s;
62
+ transition-timing-function: ease-out;
63
+ }
64
+
65
+ position: absolute;
66
+ pointer-events: none;
67
+
68
+ /* Windows high contrast mode. */
69
+ outline: 2px solid transparent;
70
+ outline-offset: -1px;
71
+
72
+ &[data-orientation="horizontal"] {
73
+ z-index: 1;
74
+ /* stylelint-disable-next-line plugin/use-logical-properties-and-values -- Physical properties are necessary for the indicator to work as expected. */
75
+ left: 0;
76
+ bottom: 0;
77
+ height: var(--wpds-border-width-focus);
78
+
79
+ width: var(--active-tab-width);
80
+ translate: var(--active-tab-left) 0;
81
+ background-color: var(--wpds-color-stroke-interactive-neutral-strong);
82
+ }
83
+
84
+ &[data-orientation="vertical"] {
85
+ z-index: 0;
86
+ border-radius: var(--wpds-border-radius-sm);
87
+ top: 0;
88
+ /* stylelint-disable-next-line plugin/use-logical-properties-and-values -- Physical properties are necessary for the indicator to work as expected. */
89
+ left: 50%;
90
+ width: 100%;
91
+ height: var(--active-tab-height);
92
+ translate: -50% var(--active-tab-top);
93
+ background-color: var(--wpds-color-bg-interactive-neutral-weak-active);
94
+ }
95
+
96
+ .tablist[data-select-on-move="true"]:has(:focus-visible)
97
+ &[data-orientation="vertical"] {
98
+ box-sizing: border-box;
99
+ border:
100
+ var(--wpds-border-width-focus) solid
101
+ var(--wpds-color-stroke-focus-brand);
102
+ }
103
+ }
104
+
105
+ .tab {
106
+ /* Resets */
107
+ border-radius: 0;
108
+ background: transparent;
109
+ border: none;
110
+ box-shadow: none;
111
+ outline: none; /* Focus ring applied to the ::after pseudo-element */
112
+ padding: 0;
113
+
114
+ /* Positioning */
115
+ z-index: 1;
116
+ flex: 1 0 auto;
117
+ position: relative;
118
+ display: flex;
119
+ align-items: center;
120
+
121
+ /* Appearance */
122
+ cursor: pointer;
123
+
124
+ /* Typography (TODO: replace with theme tokens when available) */
125
+ font-family: sans-serif;
126
+ font-size: 13px;
127
+ white-space: nowrap;
128
+
129
+ /* Characters in some languages (e.g. Japanese) may have a native higher line-height. */
130
+
131
+ line-height: 1.2;
132
+ font-weight: 400;
133
+ color: var(--wpds-color-fg-interactive-neutral);
134
+
135
+ &[data-disabled] {
136
+ cursor: default;
137
+ color: var(--wpds-color-fg-interactive-neutral-disabled);
138
+
139
+ @media ( forced-colors: active ) {
140
+ color: GrayText;
141
+ }
142
+ }
143
+
144
+ &:not([data-disabled]):is(:hover, :focus-visible) {
145
+ color: var(--wpds-color-fg-interactive-neutral-active);
146
+ }
147
+
148
+ /* Focus indicator. */
149
+ &::after {
150
+ position: absolute;
151
+ z-index: -1;
152
+ pointer-events: none;
153
+
154
+ /* Outline works for Windows high contrast mode as well. */
155
+ outline:
156
+ var(--wpds-border-width-focus) solid
157
+ var(--wpds-color-stroke-focus-brand);
158
+ border-radius: var(--wpds-border-radius-sm);
159
+
160
+ /* Animation */
161
+ opacity: 0;
162
+
163
+ @media not ( prefers-reduced-motion ) {
164
+ transition: opacity 0.1s linear;
165
+ }
166
+ }
167
+
168
+ &:focus-visible::after {
169
+ opacity: 1;
170
+ }
171
+
172
+ [data-orientation="horizontal"] & {
173
+ padding-inline: var(--wpds-dimension-padding-lg);
174
+ height: 48px; /* TODO: use semantic size/height tokens when available */
175
+ scroll-margin: 24px;
176
+
177
+ &::after {
178
+ content: "";
179
+ inset: var(--wpds-dimension-padding-md);
180
+ }
181
+ }
182
+
183
+ .is-minimal-variant[data-orientation="horizontal"] & {
184
+ padding-inline: 0;
185
+
186
+ &::after {
187
+ /*
188
+ * Prevent clipping the focus ring at the tablist edge.
189
+ * Use rounding, as the focus ring width may have sub-pixel values
190
+ * depending on the screen pixel ratio.
191
+ */
192
+ inset-inline: round(up, var(--wpds-border-width-focus), 1px);
193
+ }
194
+ }
195
+
196
+ [data-orientation="vertical"] & {
197
+ padding: var(--wpds-dimension-padding-sm) var(--wpds-dimension-padding-md);
198
+ min-height: 40px; /* TODO: use semantic size/height tokens when available */
199
+ }
200
+
201
+ [data-orientation="vertical"][data-select-on-move="false"] &::after {
202
+ content: "";
203
+ inset: var(--wpds-border-width-focus); /* TODO: Use or create new control/interactive padding token */
204
+ }
205
+ }
206
+
207
+ .tab-children {
208
+ flex-grow: 1;
209
+
210
+ display: flex;
211
+ align-items: center;
212
+
213
+ [data-orientation="horizontal"] & {
214
+ justify-content: center;
215
+ }
216
+
217
+ [data-orientation="vertical"] & {
218
+ justify-content: start;
219
+ }
220
+ }
221
+
222
+ .tab-chevron {
223
+ flex-shrink: 0;
224
+ margin-inline-end: calc(var(--wpds-dimension-gap-xs) * -1);
225
+
226
+ [data-orientation="horizontal"] & {
227
+ display: none;
228
+ }
229
+ opacity: 0;
230
+
231
+ [role="tab"]:is([aria-selected="true"], :focus-visible, :hover) & {
232
+ opacity: 1;
233
+ }
234
+
235
+ /*
236
+ * The chevron is transitioned into existence when selectOnMove is enabled,
237
+ * because otherwise it looks jarring, as it shows up outside of the focus
238
+ * indicator that's being animated at the same time.
239
+ */
240
+ @media not ( prefers-reduced-motion ) {
241
+ [data-select-on-move="true"]
242
+ [role="tab"]:is([aria-selected="true"])
243
+ & {
244
+ transition: opacity 0.15s 0.15s linear;
245
+ }
246
+ }
247
+
248
+ &:dir(rtl) {
249
+ rotate: 180deg;
250
+ }
251
+ }
252
+
253
+ .tabpanel {
254
+ &:focus {
255
+ box-shadow: none;
256
+ outline: none;
257
+ }
258
+
259
+ &:focus-visible {
260
+ box-shadow:
261
+ 0 0 0 var(--wpds-border-width-focus)
262
+ var(--wpds-color-stroke-focus-brand);
263
+
264
+ /* Windows high contrast mode. */
265
+ outline: 2px solid transparent;
266
+ outline-offset: 0;
267
+ }
268
+ }
269
+ }
@@ -0,0 +1,29 @@
1
+ import { forwardRef } from '@wordpress/element';
2
+ import clsx from 'clsx';
3
+ import { Tabs as _Tabs } from '@base-ui/react/tabs';
4
+ import { chevronRight } from '@wordpress/icons';
5
+ import { Icon } from '../icon';
6
+ import styles from './style.module.css';
7
+ import type { TabProps } from './types';
8
+
9
+ /**
10
+ * An individual interactive tab button that toggles the corresponding panel.
11
+ *
12
+ * `Tabs` is a collection of React components that combine to render
13
+ * an [ARIA-compliant tabs pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/).
14
+ */
15
+ export const Tab = forwardRef< HTMLButtonElement, TabProps >( function Tab(
16
+ { className, children, ...otherProps },
17
+ forwardedRef
18
+ ) {
19
+ return (
20
+ <_Tabs.Tab
21
+ ref={ forwardedRef }
22
+ className={ clsx( styles.tab, className ) }
23
+ { ...otherProps }
24
+ >
25
+ <span className={ styles[ 'tab-children' ] }>{ children }</span>
26
+ <Icon icon={ chevronRight } className={ styles[ 'tab-chevron' ] } />
27
+ </_Tabs.Tab>
28
+ );
29
+ } );