@wordpress/ui 0.6.1-next.v.0 → 0.7.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 (297) hide show
  1. package/AGENTS.md +9 -0
  2. package/CHANGELOG.md +32 -1
  3. package/CLAUDE.md +1 -0
  4. package/README.md +13 -12
  5. package/build/badge/badge.cjs +37 -62
  6. package/build/badge/badge.cjs.map +4 -4
  7. package/build/button/button.cjs +3 -3
  8. package/build/button/button.cjs.map +2 -2
  9. package/build/dialog/action.cjs +46 -0
  10. package/build/dialog/action.cjs.map +7 -0
  11. package/build/dialog/close-icon.cjs +57 -0
  12. package/build/dialog/close-icon.cjs.map +7 -0
  13. package/build/dialog/context.cjs +76 -0
  14. package/build/dialog/context.cjs.map +7 -0
  15. package/build/dialog/footer.cjs +64 -0
  16. package/build/dialog/footer.cjs.map +7 -0
  17. package/build/dialog/header.cjs +64 -0
  18. package/build/dialog/header.cjs.map +7 -0
  19. package/build/dialog/index.cjs +52 -0
  20. package/build/dialog/index.cjs.map +7 -0
  21. package/build/dialog/popup.cjs +77 -0
  22. package/build/dialog/popup.cjs.map +7 -0
  23. package/build/dialog/root.cjs +35 -0
  24. package/build/dialog/root.cjs.map +7 -0
  25. package/build/dialog/title.cjs +76 -0
  26. package/build/dialog/title.cjs.map +7 -0
  27. package/build/dialog/trigger.cjs +38 -0
  28. package/build/dialog/trigger.cjs.map +7 -0
  29. package/build/dialog/types.cjs +19 -0
  30. package/build/dialog/types.cjs.map +7 -0
  31. package/build/form/primitives/field/root.cjs +1 -1
  32. package/build/form/primitives/field/root.cjs.map +1 -1
  33. package/build/form/primitives/fieldset/root.cjs +3 -3
  34. package/build/form/primitives/fieldset/root.cjs.map +2 -2
  35. package/build/form/primitives/index.cjs +5 -2
  36. package/build/form/primitives/index.cjs.map +2 -2
  37. package/build/form/primitives/input-layout/input-layout.cjs +3 -3
  38. package/build/form/primitives/input-layout/input-layout.cjs.map +2 -2
  39. package/build/form/primitives/input-layout/slot.cjs +3 -3
  40. package/build/form/primitives/input-layout/slot.cjs.map +2 -2
  41. package/build/form/primitives/select/item.cjs +3 -3
  42. package/build/form/primitives/select/item.cjs.map +2 -2
  43. package/build/form/primitives/select/popup.cjs +3 -3
  44. package/build/form/primitives/select/popup.cjs.map +2 -2
  45. package/build/form/primitives/select/trigger.cjs +3 -3
  46. package/build/form/primitives/select/trigger.cjs.map +2 -2
  47. package/build/{box → form/primitives/textarea}/index.cjs +7 -7
  48. package/build/form/primitives/textarea/index.cjs.map +7 -0
  49. package/build/form/primitives/textarea/textarea.cjs +90 -0
  50. package/build/form/primitives/textarea/textarea.cjs.map +7 -0
  51. package/build/form/primitives/textarea/types.cjs +19 -0
  52. package/build/form/primitives/textarea/types.cjs.map +7 -0
  53. package/build/icon-button/icon-button.cjs +104 -0
  54. package/build/icon-button/icon-button.cjs.map +7 -0
  55. package/build/icon-button/index.cjs +31 -0
  56. package/build/icon-button/index.cjs.map +7 -0
  57. package/build/icon-button/types.cjs +19 -0
  58. package/build/icon-button/types.cjs.map +7 -0
  59. package/build/index.cjs +8 -2
  60. package/build/index.cjs.map +2 -2
  61. package/build/tabs/index.cjs +40 -0
  62. package/build/tabs/index.cjs.map +7 -0
  63. package/build/tabs/list.cjs +145 -0
  64. package/build/tabs/list.cjs.map +7 -0
  65. package/build/tabs/panel.cjs +67 -0
  66. package/build/tabs/panel.cjs.map +7 -0
  67. package/build/tabs/root.cjs +38 -0
  68. package/build/tabs/root.cjs.map +7 -0
  69. package/build/tabs/tab.cjs +71 -0
  70. package/build/tabs/tab.cjs.map +7 -0
  71. package/build/{box → tabs}/types.cjs +1 -1
  72. package/build/tabs/types.cjs.map +7 -0
  73. package/build/tooltip/popup.cjs +3 -3
  74. package/build/tooltip/popup.cjs.map +2 -2
  75. package/build-module/badge/badge.mjs +27 -62
  76. package/build-module/badge/badge.mjs.map +3 -3
  77. package/build-module/button/button.mjs +3 -3
  78. package/build-module/button/button.mjs.map +2 -2
  79. package/build-module/dialog/action.mjs +21 -0
  80. package/build-module/dialog/action.mjs.map +7 -0
  81. package/build-module/dialog/close-icon.mjs +32 -0
  82. package/build-module/dialog/close-icon.mjs.map +7 -0
  83. package/build-module/dialog/context.mjs +57 -0
  84. package/build-module/dialog/context.mjs.map +7 -0
  85. package/build-module/dialog/footer.mjs +29 -0
  86. package/build-module/dialog/footer.mjs.map +7 -0
  87. package/build-module/dialog/header.mjs +29 -0
  88. package/build-module/dialog/header.mjs.map +7 -0
  89. package/build-module/dialog/index.mjs +20 -0
  90. package/build-module/dialog/index.mjs.map +7 -0
  91. package/build-module/dialog/popup.mjs +44 -0
  92. package/build-module/dialog/popup.mjs.map +7 -0
  93. package/build-module/dialog/root.mjs +10 -0
  94. package/build-module/dialog/root.mjs.map +7 -0
  95. package/build-module/dialog/title.mjs +41 -0
  96. package/build-module/dialog/title.mjs.map +7 -0
  97. package/build-module/dialog/trigger.mjs +13 -0
  98. package/build-module/dialog/trigger.mjs.map +7 -0
  99. package/build-module/form/primitives/field/root.mjs +1 -1
  100. package/build-module/form/primitives/field/root.mjs.map +1 -1
  101. package/build-module/form/primitives/fieldset/root.mjs +3 -3
  102. package/build-module/form/primitives/fieldset/root.mjs.map +2 -2
  103. package/build-module/form/primitives/index.mjs +3 -1
  104. package/build-module/form/primitives/index.mjs.map +2 -2
  105. package/build-module/form/primitives/input-layout/input-layout.mjs +3 -3
  106. package/build-module/form/primitives/input-layout/input-layout.mjs.map +2 -2
  107. package/build-module/form/primitives/input-layout/slot.mjs +3 -3
  108. package/build-module/form/primitives/input-layout/slot.mjs.map +2 -2
  109. package/build-module/form/primitives/select/item.mjs +3 -3
  110. package/build-module/form/primitives/select/item.mjs.map +2 -2
  111. package/build-module/form/primitives/select/popup.mjs +3 -3
  112. package/build-module/form/primitives/select/popup.mjs.map +2 -2
  113. package/build-module/form/primitives/select/trigger.mjs +3 -3
  114. package/build-module/form/primitives/select/trigger.mjs.map +2 -2
  115. package/build-module/form/primitives/textarea/index.mjs +6 -0
  116. package/build-module/form/primitives/textarea/index.mjs.map +7 -0
  117. package/build-module/form/primitives/textarea/textarea.mjs +55 -0
  118. package/build-module/form/primitives/textarea/textarea.mjs.map +7 -0
  119. package/build-module/form/primitives/textarea/types.mjs +1 -0
  120. package/build-module/form/primitives/textarea/types.mjs.map +7 -0
  121. package/build-module/icon-button/icon-button.mjs +69 -0
  122. package/build-module/icon-button/icon-button.mjs.map +7 -0
  123. package/build-module/icon-button/index.mjs +6 -0
  124. package/build-module/icon-button/index.mjs.map +7 -0
  125. package/build-module/icon-button/types.mjs +1 -0
  126. package/build-module/icon-button/types.mjs.map +7 -0
  127. package/build-module/index.mjs +5 -1
  128. package/build-module/index.mjs.map +2 -2
  129. package/build-module/tabs/index.mjs +12 -0
  130. package/build-module/tabs/index.mjs.map +7 -0
  131. package/build-module/tabs/list.mjs +110 -0
  132. package/build-module/tabs/list.mjs.map +7 -0
  133. package/build-module/tabs/panel.mjs +32 -0
  134. package/build-module/tabs/panel.mjs.map +7 -0
  135. package/build-module/tabs/root.mjs +13 -0
  136. package/build-module/tabs/root.mjs.map +7 -0
  137. package/build-module/tabs/tab.mjs +36 -0
  138. package/build-module/tabs/tab.mjs.map +7 -0
  139. package/build-module/tabs/types.mjs +1 -0
  140. package/build-module/tabs/types.mjs.map +7 -0
  141. package/build-module/tooltip/popup.mjs +3 -3
  142. package/build-module/tooltip/popup.mjs.map +2 -2
  143. package/build-types/badge/badge.d.ts +1 -2
  144. package/build-types/badge/badge.d.ts.map +1 -1
  145. package/build-types/button/stories/index.story.d.ts +1 -2
  146. package/build-types/button/stories/index.story.d.ts.map +1 -1
  147. package/build-types/dialog/action.d.ts +8 -0
  148. package/build-types/dialog/action.d.ts.map +1 -0
  149. package/build-types/dialog/close-icon.d.ts +8 -0
  150. package/build-types/dialog/close-icon.d.ts.map +1 -0
  151. package/build-types/dialog/context.d.ts +25 -0
  152. package/build-types/dialog/context.d.ts.map +1 -0
  153. package/build-types/dialog/footer.d.ts +8 -0
  154. package/build-types/dialog/footer.d.ts.map +1 -0
  155. package/build-types/dialog/header.d.ts +8 -0
  156. package/build-types/dialog/header.d.ts.map +1 -0
  157. package/build-types/dialog/index.d.ts +10 -0
  158. package/build-types/dialog/index.d.ts.map +1 -0
  159. package/build-types/dialog/popup.d.ts +8 -0
  160. package/build-types/dialog/popup.d.ts.map +1 -0
  161. package/build-types/dialog/root.d.ts +10 -0
  162. package/build-types/dialog/root.d.ts.map +1 -0
  163. package/build-types/dialog/stories/index.story.d.ts +18 -0
  164. package/build-types/dialog/stories/index.story.d.ts.map +1 -0
  165. package/build-types/dialog/test/index.test.d.ts +2 -0
  166. package/build-types/dialog/test/index.test.d.ts.map +1 -0
  167. package/build-types/dialog/title.d.ts +12 -0
  168. package/build-types/dialog/title.d.ts.map +1 -0
  169. package/build-types/dialog/trigger.d.ts +7 -0
  170. package/build-types/dialog/trigger.d.ts.map +1 -0
  171. package/build-types/dialog/types.d.ts +77 -0
  172. package/build-types/dialog/types.d.ts.map +1 -0
  173. package/build-types/form/primitives/field/stories/index.story.d.ts +0 -1
  174. package/build-types/form/primitives/field/stories/index.story.d.ts.map +1 -1
  175. package/build-types/form/primitives/index.d.ts +1 -0
  176. package/build-types/form/primitives/index.d.ts.map +1 -1
  177. package/build-types/form/primitives/input/input.d.ts +1 -1
  178. package/build-types/form/primitives/select/stories/index.story.d.ts +0 -1
  179. package/build-types/form/primitives/select/stories/index.story.d.ts.map +1 -1
  180. package/build-types/form/primitives/textarea/index.d.ts +2 -0
  181. package/build-types/form/primitives/textarea/index.d.ts.map +1 -0
  182. package/build-types/form/primitives/textarea/stories/index.story.d.ts +13 -0
  183. package/build-types/form/primitives/textarea/stories/index.story.d.ts.map +1 -0
  184. package/build-types/form/primitives/textarea/test/index.test.d.ts +2 -0
  185. package/build-types/form/primitives/textarea/test/index.test.d.ts.map +1 -0
  186. package/build-types/form/primitives/textarea/textarea.d.ts +4 -0
  187. package/build-types/form/primitives/textarea/textarea.d.ts.map +1 -0
  188. package/build-types/form/primitives/textarea/types.d.ts +11 -0
  189. package/build-types/form/primitives/textarea/types.d.ts.map +1 -0
  190. package/build-types/icon-button/icon-button.d.ts +13 -0
  191. package/build-types/icon-button/icon-button.d.ts.map +1 -0
  192. package/build-types/icon-button/index.d.ts +2 -0
  193. package/build-types/icon-button/index.d.ts.map +1 -0
  194. package/build-types/icon-button/stories/index.story.d.ts +19 -0
  195. package/build-types/icon-button/stories/index.story.d.ts.map +1 -0
  196. package/build-types/icon-button/test/index.test.d.ts +2 -0
  197. package/build-types/icon-button/test/index.test.d.ts.map +1 -0
  198. package/build-types/icon-button/types.d.ts +36 -0
  199. package/build-types/icon-button/types.d.ts.map +1 -0
  200. package/build-types/index.d.ts +3 -1
  201. package/build-types/index.d.ts.map +1 -1
  202. package/build-types/stack/stories/index.story.d.ts.map +1 -1
  203. package/build-types/tabs/index.d.ts +6 -0
  204. package/build-types/tabs/index.d.ts.map +1 -0
  205. package/build-types/tabs/list.d.ts +16 -0
  206. package/build-types/tabs/list.d.ts.map +1 -0
  207. package/build-types/tabs/panel.d.ts +15 -0
  208. package/build-types/tabs/panel.d.ts.map +1 -0
  209. package/build-types/tabs/root.d.ts +15 -0
  210. package/build-types/tabs/root.d.ts.map +1 -0
  211. package/build-types/tabs/stories/index.story.d.ts +13 -0
  212. package/build-types/tabs/stories/index.story.d.ts.map +1 -0
  213. package/build-types/tabs/tab.d.ts +15 -0
  214. package/build-types/tabs/tab.d.ts.map +1 -0
  215. package/build-types/tabs/test/index.test.d.ts +2 -0
  216. package/build-types/tabs/test/index.test.d.ts.map +1 -0
  217. package/build-types/tabs/types.d.ts +33 -0
  218. package/build-types/tabs/types.d.ts.map +1 -0
  219. package/package.json +12 -10
  220. package/src/badge/badge.tsx +19 -78
  221. package/src/badge/stories/choosing-intent.story.tsx +1 -1
  222. package/src/badge/style.module.css +48 -0
  223. package/src/button/stories/index.story.tsx +3 -16
  224. package/src/button/style.module.css +23 -12
  225. package/src/dialog/action.tsx +22 -0
  226. package/src/dialog/close-icon.tsx +32 -0
  227. package/src/dialog/context.tsx +113 -0
  228. package/src/dialog/footer.tsx +26 -0
  229. package/src/dialog/header.tsx +26 -0
  230. package/src/dialog/index.ts +10 -0
  231. package/src/dialog/popup.tsx +46 -0
  232. package/src/dialog/root.tsx +14 -0
  233. package/src/dialog/stories/index.story.tsx +177 -0
  234. package/src/dialog/style.module.css +114 -0
  235. package/src/dialog/test/index.test.tsx +309 -0
  236. package/src/dialog/title.tsx +39 -0
  237. package/src/dialog/trigger.tsx +14 -0
  238. package/src/dialog/types.ts +93 -0
  239. package/src/form/primitives/field/root.tsx +1 -1
  240. package/src/form/primitives/field/stories/index.story.tsx +0 -1
  241. package/src/form/primitives/fieldset/style.module.css +1 -1
  242. package/src/form/primitives/index.ts +1 -0
  243. package/src/form/primitives/input-layout/style.module.css +5 -8
  244. package/src/form/primitives/select/stories/index.story.tsx +0 -1
  245. package/src/form/primitives/select/test/index.test.tsx +0 -2
  246. package/src/form/primitives/textarea/index.ts +1 -0
  247. package/src/form/primitives/textarea/stories/index.story.tsx +40 -0
  248. package/src/form/primitives/textarea/style.module.css +22 -0
  249. package/src/form/primitives/textarea/test/index.test.tsx +143 -0
  250. package/src/form/primitives/textarea/textarea.tsx +51 -0
  251. package/src/form/primitives/textarea/types.ts +18 -0
  252. package/src/icon-button/icon-button.tsx +65 -0
  253. package/src/icon-button/index.ts +1 -0
  254. package/src/icon-button/stories/index.story.tsx +128 -0
  255. package/src/icon-button/style.module.css +16 -0
  256. package/src/icon-button/test/index.test.tsx +86 -0
  257. package/src/icon-button/types.ts +38 -0
  258. package/src/index.ts +3 -1
  259. package/src/stack/stories/index.story.tsx +4 -5
  260. package/src/tabs/index.ts +6 -0
  261. package/src/tabs/list.tsx +130 -0
  262. package/src/tabs/panel.tsx +23 -0
  263. package/src/tabs/root.tsx +15 -0
  264. package/src/tabs/stories/best-practices.mdx +85 -0
  265. package/src/tabs/stories/index.story.tsx +363 -0
  266. package/src/tabs/style.module.css +269 -0
  267. package/src/tabs/tab.tsx +29 -0
  268. package/src/tabs/test/index.test.tsx +2260 -0
  269. package/src/tabs/types.ts +36 -0
  270. package/src/tooltip/style.module.css +3 -3
  271. package/src/utils/css/item-popup.module.css +2 -2
  272. package/src/utils/css/select-trigger.module.css +1 -1
  273. package/build/box/box.cjs +0 -88
  274. package/build/box/box.cjs.map +0 -7
  275. package/build/box/index.cjs.map +0 -7
  276. package/build/box/types.cjs.map +0 -7
  277. package/build-module/box/box.mjs +0 -63
  278. package/build-module/box/box.mjs.map +0 -7
  279. package/build-module/box/index.mjs +0 -6
  280. package/build-module/box/index.mjs.map +0 -7
  281. package/build-types/box/box.d.ts +0 -7
  282. package/build-types/box/box.d.ts.map +0 -1
  283. package/build-types/box/index.d.ts +0 -2
  284. package/build-types/box/index.d.ts.map +0 -1
  285. package/build-types/box/stories/index.story.d.ts +0 -8
  286. package/build-types/box/stories/index.story.d.ts.map +0 -1
  287. package/build-types/box/test/box.test.d.ts +0 -2
  288. package/build-types/box/test/box.test.d.ts.map +0 -1
  289. package/build-types/box/types.d.ts +0 -46
  290. package/build-types/box/types.d.ts.map +0 -1
  291. package/src/box/box.tsx +0 -118
  292. package/src/box/index.ts +0 -1
  293. package/src/box/stories/index.story.tsx +0 -41
  294. package/src/box/test/box.test.tsx +0 -29
  295. package/src/box/types.ts +0 -61
  296. /package/build-module/{box → dialog}/types.mjs +0 -0
  297. /package/build-module/{box → dialog}/types.mjs.map +0 -0
@@ -0,0 +1,36 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { Tabs as _Tabs } from '@base-ui/react/tabs';
3
+ import type { ComponentProps } from '../utils/types';
4
+
5
+ export type TabRootProps = ComponentProps< typeof _Tabs.Root > & {
6
+ /**
7
+ * The content to be rendered inside the component.
8
+ */
9
+ children?: ReactNode;
10
+ };
11
+
12
+ export type TabListProps = ComponentProps< typeof _Tabs.List > & {
13
+ /**
14
+ * The content to be rendered inside the component.
15
+ */
16
+ children?: ReactNode;
17
+ /**
18
+ * The visual variant of the tab list.
19
+ * @default "default"
20
+ */
21
+ variant?: 'minimal' | 'default';
22
+ };
23
+
24
+ export type TabProps = ComponentProps< typeof _Tabs.Tab > & {
25
+ /**
26
+ * The content to be rendered inside the component.
27
+ */
28
+ children?: ReactNode;
29
+ };
30
+
31
+ export type TabPanelProps = ComponentProps< typeof _Tabs.Panel > & {
32
+ /**
33
+ * The content to be rendered inside the component.
34
+ */
35
+ children?: ReactNode;
36
+ };
@@ -8,13 +8,13 @@
8
8
  .popup {
9
9
  background-color: var(--wpds-color-bg-surface-neutral-strong);
10
10
  padding:
11
- var(--wpds-dimension-padding-surface-2xs)
12
- var(--wpds-dimension-padding-surface-xs);
11
+ var(--wpds-dimension-padding-xs)
12
+ var(--wpds-dimension-padding-sm);
13
13
  border-radius: var(--wpds-border-radius-sm);
14
14
  font-family: var(--wpds-font-family-body);
15
15
  font-size: var(--wpds-font-size-sm);
16
16
  line-height: 1.4; /* TODO: use DS token for line height */
17
17
  color: var(--wpds-color-fg-content-neutral);
18
- box-shadow: var(--wpds-elevation-small);
18
+ box-shadow: var(--wpds-elevation-sm);
19
19
  }
20
20
  }
@@ -14,7 +14,7 @@
14
14
  max-width: var(--available-width);
15
15
  border-radius: var(--wpds-border-radius-md);
16
16
  border: 1px solid var(--wpds-color-stroke-surface-neutral);
17
- box-shadow: var(--wpds-elevation-medium);
17
+ box-shadow: var(--wpds-elevation-md);
18
18
  background-color: var(--wpds-color-bg-surface-neutral-strong);
19
19
  font-family: var(--wpds-font-family-body);
20
20
  font-size: var(--wpds-font-size-md);
@@ -59,7 +59,7 @@
59
59
  grid-template-columns: 24px 1fr;
60
60
  align-items: center;
61
61
  justify-content: flex-start;
62
- gap: var(--wpds-dimension-gap-2xs);
62
+ gap: var(--wpds-dimension-gap-xs);
63
63
  min-height: var(--wp-ui-popup-item-height);
64
64
  border-radius: var(--wpds-border-radius-sm);
65
65
  user-select: none;
@@ -11,7 +11,7 @@
11
11
  display: flex;
12
12
  justify-content: space-between;
13
13
  align-items: center;
14
- gap: var(--wpds-dimension-gap-2xs);
14
+ gap: var(--wpds-dimension-gap-xs);
15
15
  width: 100%;
16
16
  padding-block: 4px;
17
17
 
package/build/box/box.cjs DELETED
@@ -1,88 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/ui/src/box/box.tsx
21
- var box_exports = {};
22
- __export(box_exports, {
23
- Box: () => Box
24
- });
25
- module.exports = __toCommonJS(box_exports);
26
- var import_react = require("@base-ui/react");
27
- var import_element = require("@wordpress/element");
28
- var import_jsx_runtime = require("react/jsx-runtime");
29
- var DEFAULT_RENDER = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...props });
30
- var capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
31
- var getSpacingValue = (property, target, value) => `var(--wpds-dimension-${property}-${target}-${value}, var(--wpds-dimension-${property}-surface-${value}))`;
32
- var getDimensionVariantStyles = (property, target, value) => typeof value !== "object" ? { [property]: getSpacingValue(property, target, value) } : Object.keys(value).reduce(
33
- (result, key) => ({
34
- ...result,
35
- [property + capitalize(key)]: getSpacingValue(
36
- property,
37
- target,
38
- value[key]
39
- )
40
- }),
41
- {}
42
- );
43
- var Box = (0, import_element.forwardRef)(function Box2({
44
- target = "surface",
45
- backgroundColor,
46
- color,
47
- padding,
48
- borderRadius,
49
- borderWidth,
50
- borderColor,
51
- render = DEFAULT_RENDER,
52
- ...props
53
- }, ref) {
54
- const style = {};
55
- if (backgroundColor) {
56
- style.backgroundColor = `var(--wpds-color-bg-${target}-${backgroundColor}, var(--wpds-color-bg-surface-${backgroundColor}))`;
57
- }
58
- if (color) {
59
- style.color = `var(--wpds-color-fg-${target}-${color}, var(--wpds-color-fg-content-${color}))`;
60
- }
61
- if (padding) {
62
- Object.assign(
63
- style,
64
- getDimensionVariantStyles("padding", target, padding)
65
- );
66
- }
67
- if (borderRadius) {
68
- style.borderRadius = `var(--wpds-border-radius-${target}-${borderRadius}, var(--wpds-border-radius-${borderRadius}))`;
69
- }
70
- if (borderWidth) {
71
- style.borderWidth = `var(--wpds-border-width-${target}-${borderWidth}, var(--wpds-border-width-${borderWidth}))`;
72
- style.borderStyle = "solid";
73
- }
74
- if (borderColor) {
75
- style.borderColor = `var(--wpds-color-stroke-${target}-${borderColor}, var(--wpds-color-stroke-surface-${borderColor}))`;
76
- }
77
- const element = (0, import_react.useRender)({
78
- render,
79
- ref,
80
- props: (0, import_react.mergeProps)(props, { style })
81
- });
82
- return element;
83
- });
84
- // Annotate the CommonJS export names for ESM import in node:
85
- 0 && (module.exports = {
86
- Box
87
- });
88
- //# sourceMappingURL=box.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/box/box.tsx"],
4
- "sourcesContent": ["import { useRender, mergeProps } from '@base-ui/react';\nimport { forwardRef } from '@wordpress/element';\nimport { type BoxProps } from './types';\n\n/**\n * Default render function that renders a div element with the given props.\n */\nconst DEFAULT_RENDER = ( props: React.ComponentPropsWithoutRef< 'div' > ) => (\n\t<div { ...props } />\n);\n\n/**\n * Capitalizes the first character of a string.\n */\nconst capitalize = ( str: string ): string =>\n\tstr.charAt( 0 ).toUpperCase() + str.slice( 1 );\n\n/**\n * Converts a size token name to a CSS design token property reference (with\n * fallback).\n *\n * @param property The CSS property name.\n * @param target The design system token target.\n * @param value The size token name.\n * @return A CSS value string with variable references.\n */\nconst getSpacingValue = (\n\tproperty: string,\n\ttarget: string,\n\tvalue: string\n): string =>\n\t`var(--wpds-dimension-${ property }-${ target }-${ value }, var(--wpds-dimension-${ property }-surface-${ value }))`;\n\n/**\n * Generates CSS styles for properties with optionally directional values,\n * normalizing single values and objects with directional keys for logical\n * properties.\n *\n * @param property The CSS property name from BoxProps.\n * @param target The design system token target.\n * @param value The property value (single or object with directional keys).\n * @return A CSSProperties object with the computed styles.\n */\nconst getDimensionVariantStyles = < T extends keyof BoxProps >(\n\tproperty: T,\n\ttarget: string,\n\tvalue: NonNullable< BoxProps[ T ] >\n): React.CSSProperties =>\n\ttypeof value !== 'object'\n\t\t? { [ property ]: getSpacingValue( property, target, value ) }\n\t\t: Object.keys( value ).reduce(\n\t\t\t\t( result, key ) => ( {\n\t\t\t\t\t...result,\n\t\t\t\t\t[ property + capitalize( key ) ]: getSpacingValue(\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\ttarget,\n\t\t\t\t\t\tvalue[ key ]\n\t\t\t\t\t),\n\t\t\t\t} ),\n\t\t\t\t{} as Record< string, string >\n\t\t );\n\n/**\n * A low-level visual primitive that provides an interface for applying design\n * token-based customization for background, text, padding, and more.\n */\nexport const Box = forwardRef< HTMLDivElement, BoxProps >( function Box(\n\t{\n\t\ttarget = 'surface',\n\t\tbackgroundColor,\n\t\tcolor,\n\t\tpadding,\n\t\tborderRadius,\n\t\tborderWidth,\n\t\tborderColor,\n\t\trender = DEFAULT_RENDER,\n\t\t...props\n\t},\n\tref\n) {\n\tconst style: React.CSSProperties = {};\n\n\tif ( backgroundColor ) {\n\t\tstyle.backgroundColor = `var(--wpds-color-bg-${ target }-${ backgroundColor }, var(--wpds-color-bg-surface-${ backgroundColor }))`;\n\t}\n\n\tif ( color ) {\n\t\tstyle.color = `var(--wpds-color-fg-${ target }-${ color }, var(--wpds-color-fg-content-${ color }))`;\n\t}\n\n\tif ( padding ) {\n\t\tObject.assign(\n\t\t\tstyle,\n\t\t\tgetDimensionVariantStyles( 'padding', target, padding )\n\t\t);\n\t}\n\n\tif ( borderRadius ) {\n\t\tstyle.borderRadius = `var(--wpds-border-radius-${ target }-${ borderRadius }, var(--wpds-border-radius-${ borderRadius }))`;\n\t}\n\n\tif ( borderWidth ) {\n\t\tstyle.borderWidth = `var(--wpds-border-width-${ target }-${ borderWidth }, var(--wpds-border-width-${ borderWidth }))`;\n\t\tstyle.borderStyle = 'solid';\n\t}\n\n\tif ( borderColor ) {\n\t\tstyle.borderColor = `var(--wpds-color-stroke-${ target }-${ borderColor }, var(--wpds-color-stroke-surface-${ borderColor }))`;\n\t}\n\n\tconst element = useRender( {\n\t\trender,\n\t\tref,\n\t\tprops: mergeProps< 'div' >( props, { style } ),\n\t} );\n\n\treturn element;\n} );\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsC;AACtC,qBAA2B;AAO1B;AADD,IAAM,iBAAiB,CAAE,UACxB,4CAAC,SAAM,GAAG,OAAQ;AAMnB,IAAM,aAAa,CAAE,QACpB,IAAI,OAAQ,CAAE,EAAE,YAAY,IAAI,IAAI,MAAO,CAAE;AAW9C,IAAM,kBAAkB,CACvB,UACA,QACA,UAEA,wBAAyB,QAAS,IAAK,MAAO,IAAK,KAAM,0BAA2B,QAAS,YAAa,KAAM;AAYjH,IAAM,4BAA4B,CACjC,UACA,QACA,UAEA,OAAO,UAAU,WACd,EAAE,CAAE,QAAS,GAAG,gBAAiB,UAAU,QAAQ,KAAM,EAAE,IAC3D,OAAO,KAAM,KAAM,EAAE;AAAA,EACrB,CAAE,QAAQ,SAAW;AAAA,IACpB,GAAG;AAAA,IACH,CAAE,WAAW,WAAY,GAAI,CAAE,GAAG;AAAA,MACjC;AAAA,MACA;AAAA,MACA,MAAO,GAAI;AAAA,IACZ;AAAA,EACD;AAAA,EACA,CAAC;AACD;AAMG,IAAM,UAAM,2BAAwC,SAASA,KACnE;AAAA,EACC,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,GAAG;AACJ,GACA,KACC;AACD,QAAM,QAA6B,CAAC;AAEpC,MAAK,iBAAkB;AACtB,UAAM,kBAAkB,uBAAwB,MAAO,IAAK,eAAgB,iCAAkC,eAAgB;AAAA,EAC/H;AAEA,MAAK,OAAQ;AACZ,UAAM,QAAQ,uBAAwB,MAAO,IAAK,KAAM,iCAAkC,KAAM;AAAA,EACjG;AAEA,MAAK,SAAU;AACd,WAAO;AAAA,MACN;AAAA,MACA,0BAA2B,WAAW,QAAQ,OAAQ;AAAA,IACvD;AAAA,EACD;AAEA,MAAK,cAAe;AACnB,UAAM,eAAe,4BAA6B,MAAO,IAAK,YAAa,8BAA+B,YAAa;AAAA,EACxH;AAEA,MAAK,aAAc;AAClB,UAAM,cAAc,2BAA4B,MAAO,IAAK,WAAY,6BAA8B,WAAY;AAClH,UAAM,cAAc;AAAA,EACrB;AAEA,MAAK,aAAc;AAClB,UAAM,cAAc,2BAA4B,MAAO,IAAK,WAAY,qCAAsC,WAAY;AAAA,EAC3H;AAEA,QAAM,cAAU,wBAAW;AAAA,IAC1B;AAAA,IACA;AAAA,IACA,WAAO,yBAAqB,OAAO,EAAE,MAAM,CAAE;AAAA,EAC9C,CAAE;AAEF,SAAO;AACR,CAAE;",
6
- "names": ["Box"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/box/index.ts"],
4
- "sourcesContent": ["export { Box } from './box';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoB;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/box/types.ts"],
4
- "sourcesContent": ["import {\n\ttype PaddingSize,\n\ttype BorderRadiusSize,\n\ttype BorderWidthSize,\n\ttype Target,\n\ttype SurfaceBackgroundColor,\n\ttype ContentForegroundColor,\n\ttype SurfaceStrokeColor,\n} from '@wordpress/theme';\nimport { type ComponentProps } from '../utils/types';\n\ntype DimensionVariant< T > = {\n\tblock?: T;\n\tblockStart?: T;\n\tblockEnd?: T;\n\tinline?: T;\n\tinlineStart?: T;\n\tinlineEnd?: T;\n};\n\nexport interface BoxProps extends ComponentProps< 'div' > {\n\t/**\n\t * The target rendering element design token grouping to use for the box.\n\t */\n\ttarget?: Target;\n\n\t/**\n\t * The surface background design token for box background color.\n\t */\n\tbackgroundColor?: SurfaceBackgroundColor;\n\n\t/**\n\t * The surface foreground design token for box text color.\n\t */\n\tcolor?: ContentForegroundColor;\n\n\t/**\n\t * The surface spacing design token or base unit multiplier for box padding.\n\t */\n\tpadding?: PaddingSize | DimensionVariant< PaddingSize >;\n\n\t/**\n\t * The surface border radius design token.\n\t */\n\tborderRadius?: BorderRadiusSize;\n\n\t/**\n\t * The surface border width design token.\n\t */\n\tborderWidth?: BorderWidthSize;\n\n\t/**\n\t * The surface border stroke color design token.\n\t */\n\tborderColor?: SurfaceStrokeColor;\n\n\t/**\n\t * The content to be rendered inside the component.\n\t */\n\tchildren?: React.ReactNode;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
6
- "names": []
7
- }
@@ -1,63 +0,0 @@
1
- // packages/ui/src/box/box.tsx
2
- import { useRender, mergeProps } from "@base-ui/react";
3
- import { forwardRef } from "@wordpress/element";
4
- import { jsx } from "react/jsx-runtime";
5
- var DEFAULT_RENDER = (props) => /* @__PURE__ */ jsx("div", { ...props });
6
- var capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
7
- var getSpacingValue = (property, target, value) => `var(--wpds-dimension-${property}-${target}-${value}, var(--wpds-dimension-${property}-surface-${value}))`;
8
- var getDimensionVariantStyles = (property, target, value) => typeof value !== "object" ? { [property]: getSpacingValue(property, target, value) } : Object.keys(value).reduce(
9
- (result, key) => ({
10
- ...result,
11
- [property + capitalize(key)]: getSpacingValue(
12
- property,
13
- target,
14
- value[key]
15
- )
16
- }),
17
- {}
18
- );
19
- var Box = forwardRef(function Box2({
20
- target = "surface",
21
- backgroundColor,
22
- color,
23
- padding,
24
- borderRadius,
25
- borderWidth,
26
- borderColor,
27
- render = DEFAULT_RENDER,
28
- ...props
29
- }, ref) {
30
- const style = {};
31
- if (backgroundColor) {
32
- style.backgroundColor = `var(--wpds-color-bg-${target}-${backgroundColor}, var(--wpds-color-bg-surface-${backgroundColor}))`;
33
- }
34
- if (color) {
35
- style.color = `var(--wpds-color-fg-${target}-${color}, var(--wpds-color-fg-content-${color}))`;
36
- }
37
- if (padding) {
38
- Object.assign(
39
- style,
40
- getDimensionVariantStyles("padding", target, padding)
41
- );
42
- }
43
- if (borderRadius) {
44
- style.borderRadius = `var(--wpds-border-radius-${target}-${borderRadius}, var(--wpds-border-radius-${borderRadius}))`;
45
- }
46
- if (borderWidth) {
47
- style.borderWidth = `var(--wpds-border-width-${target}-${borderWidth}, var(--wpds-border-width-${borderWidth}))`;
48
- style.borderStyle = "solid";
49
- }
50
- if (borderColor) {
51
- style.borderColor = `var(--wpds-color-stroke-${target}-${borderColor}, var(--wpds-color-stroke-surface-${borderColor}))`;
52
- }
53
- const element = useRender({
54
- render,
55
- ref,
56
- props: mergeProps(props, { style })
57
- });
58
- return element;
59
- });
60
- export {
61
- Box
62
- };
63
- //# sourceMappingURL=box.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/box/box.tsx"],
4
- "sourcesContent": ["import { useRender, mergeProps } from '@base-ui/react';\nimport { forwardRef } from '@wordpress/element';\nimport { type BoxProps } from './types';\n\n/**\n * Default render function that renders a div element with the given props.\n */\nconst DEFAULT_RENDER = ( props: React.ComponentPropsWithoutRef< 'div' > ) => (\n\t<div { ...props } />\n);\n\n/**\n * Capitalizes the first character of a string.\n */\nconst capitalize = ( str: string ): string =>\n\tstr.charAt( 0 ).toUpperCase() + str.slice( 1 );\n\n/**\n * Converts a size token name to a CSS design token property reference (with\n * fallback).\n *\n * @param property The CSS property name.\n * @param target The design system token target.\n * @param value The size token name.\n * @return A CSS value string with variable references.\n */\nconst getSpacingValue = (\n\tproperty: string,\n\ttarget: string,\n\tvalue: string\n): string =>\n\t`var(--wpds-dimension-${ property }-${ target }-${ value }, var(--wpds-dimension-${ property }-surface-${ value }))`;\n\n/**\n * Generates CSS styles for properties with optionally directional values,\n * normalizing single values and objects with directional keys for logical\n * properties.\n *\n * @param property The CSS property name from BoxProps.\n * @param target The design system token target.\n * @param value The property value (single or object with directional keys).\n * @return A CSSProperties object with the computed styles.\n */\nconst getDimensionVariantStyles = < T extends keyof BoxProps >(\n\tproperty: T,\n\ttarget: string,\n\tvalue: NonNullable< BoxProps[ T ] >\n): React.CSSProperties =>\n\ttypeof value !== 'object'\n\t\t? { [ property ]: getSpacingValue( property, target, value ) }\n\t\t: Object.keys( value ).reduce(\n\t\t\t\t( result, key ) => ( {\n\t\t\t\t\t...result,\n\t\t\t\t\t[ property + capitalize( key ) ]: getSpacingValue(\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\ttarget,\n\t\t\t\t\t\tvalue[ key ]\n\t\t\t\t\t),\n\t\t\t\t} ),\n\t\t\t\t{} as Record< string, string >\n\t\t );\n\n/**\n * A low-level visual primitive that provides an interface for applying design\n * token-based customization for background, text, padding, and more.\n */\nexport const Box = forwardRef< HTMLDivElement, BoxProps >( function Box(\n\t{\n\t\ttarget = 'surface',\n\t\tbackgroundColor,\n\t\tcolor,\n\t\tpadding,\n\t\tborderRadius,\n\t\tborderWidth,\n\t\tborderColor,\n\t\trender = DEFAULT_RENDER,\n\t\t...props\n\t},\n\tref\n) {\n\tconst style: React.CSSProperties = {};\n\n\tif ( backgroundColor ) {\n\t\tstyle.backgroundColor = `var(--wpds-color-bg-${ target }-${ backgroundColor }, var(--wpds-color-bg-surface-${ backgroundColor }))`;\n\t}\n\n\tif ( color ) {\n\t\tstyle.color = `var(--wpds-color-fg-${ target }-${ color }, var(--wpds-color-fg-content-${ color }))`;\n\t}\n\n\tif ( padding ) {\n\t\tObject.assign(\n\t\t\tstyle,\n\t\t\tgetDimensionVariantStyles( 'padding', target, padding )\n\t\t);\n\t}\n\n\tif ( borderRadius ) {\n\t\tstyle.borderRadius = `var(--wpds-border-radius-${ target }-${ borderRadius }, var(--wpds-border-radius-${ borderRadius }))`;\n\t}\n\n\tif ( borderWidth ) {\n\t\tstyle.borderWidth = `var(--wpds-border-width-${ target }-${ borderWidth }, var(--wpds-border-width-${ borderWidth }))`;\n\t\tstyle.borderStyle = 'solid';\n\t}\n\n\tif ( borderColor ) {\n\t\tstyle.borderColor = `var(--wpds-color-stroke-${ target }-${ borderColor }, var(--wpds-color-stroke-surface-${ borderColor }))`;\n\t}\n\n\tconst element = useRender( {\n\t\trender,\n\t\tref,\n\t\tprops: mergeProps< 'div' >( props, { style } ),\n\t} );\n\n\treturn element;\n} );\n"],
5
- "mappings": ";AAAA,SAAS,WAAW,kBAAkB;AACtC,SAAS,kBAAkB;AAO1B;AADD,IAAM,iBAAiB,CAAE,UACxB,oBAAC,SAAM,GAAG,OAAQ;AAMnB,IAAM,aAAa,CAAE,QACpB,IAAI,OAAQ,CAAE,EAAE,YAAY,IAAI,IAAI,MAAO,CAAE;AAW9C,IAAM,kBAAkB,CACvB,UACA,QACA,UAEA,wBAAyB,QAAS,IAAK,MAAO,IAAK,KAAM,0BAA2B,QAAS,YAAa,KAAM;AAYjH,IAAM,4BAA4B,CACjC,UACA,QACA,UAEA,OAAO,UAAU,WACd,EAAE,CAAE,QAAS,GAAG,gBAAiB,UAAU,QAAQ,KAAM,EAAE,IAC3D,OAAO,KAAM,KAAM,EAAE;AAAA,EACrB,CAAE,QAAQ,SAAW;AAAA,IACpB,GAAG;AAAA,IACH,CAAE,WAAW,WAAY,GAAI,CAAE,GAAG;AAAA,MACjC;AAAA,MACA;AAAA,MACA,MAAO,GAAI;AAAA,IACZ;AAAA,EACD;AAAA,EACA,CAAC;AACD;AAMG,IAAM,MAAM,WAAwC,SAASA,KACnE;AAAA,EACC,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,GAAG;AACJ,GACA,KACC;AACD,QAAM,QAA6B,CAAC;AAEpC,MAAK,iBAAkB;AACtB,UAAM,kBAAkB,uBAAwB,MAAO,IAAK,eAAgB,iCAAkC,eAAgB;AAAA,EAC/H;AAEA,MAAK,OAAQ;AACZ,UAAM,QAAQ,uBAAwB,MAAO,IAAK,KAAM,iCAAkC,KAAM;AAAA,EACjG;AAEA,MAAK,SAAU;AACd,WAAO;AAAA,MACN;AAAA,MACA,0BAA2B,WAAW,QAAQ,OAAQ;AAAA,IACvD;AAAA,EACD;AAEA,MAAK,cAAe;AACnB,UAAM,eAAe,4BAA6B,MAAO,IAAK,YAAa,8BAA+B,YAAa;AAAA,EACxH;AAEA,MAAK,aAAc;AAClB,UAAM,cAAc,2BAA4B,MAAO,IAAK,WAAY,6BAA8B,WAAY;AAClH,UAAM,cAAc;AAAA,EACrB;AAEA,MAAK,aAAc;AAClB,UAAM,cAAc,2BAA4B,MAAO,IAAK,WAAY,qCAAsC,WAAY;AAAA,EAC3H;AAEA,QAAM,UAAU,UAAW;AAAA,IAC1B;AAAA,IACA;AAAA,IACA,OAAO,WAAqB,OAAO,EAAE,MAAM,CAAE;AAAA,EAC9C,CAAE;AAEF,SAAO;AACR,CAAE;",
6
- "names": ["Box"]
7
- }
@@ -1,6 +0,0 @@
1
- // packages/ui/src/box/index.ts
2
- import { Box } from "./box.mjs";
3
- export {
4
- Box
5
- };
6
- //# sourceMappingURL=index.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/box/index.ts"],
4
- "sourcesContent": ["export { Box } from './box';\n"],
5
- "mappings": ";AAAA,SAAS,WAAW;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- import { type BoxProps } from './types';
2
- /**
3
- * A low-level visual primitive that provides an interface for applying design
4
- * token-based customization for background, text, padding, and more.
5
- */
6
- export declare const Box: import("react").ForwardRefExoticComponent<BoxProps & import("react").RefAttributes<HTMLDivElement>>;
7
- //# sourceMappingURL=box.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../src/box/box.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AA4DxC;;;GAGG;AACH,eAAO,MAAM,GAAG,qGAmDb,CAAC"}
@@ -1,2 +0,0 @@
1
- export { Box } from './box';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/box/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC"}
@@ -1,8 +0,0 @@
1
- import { type Meta, type StoryObj } from '@storybook/react-vite';
2
- import { Box } from '../box';
3
- declare const meta: Meta<typeof Box>;
4
- export default meta;
5
- type Story = StoryObj<typeof Box>;
6
- export declare const Default: Story;
7
- export declare const DirectionalPadding: Story;
8
- //# sourceMappingURL=index.story.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/box/stories/index.story.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,GAAG,CAG3B,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAE,OAAO,GAAG,CAAE,CAAC;AAEpC,eAAO,MAAM,OAAO,EAAE,KAgBrB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,KAUhC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=box.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"box.test.d.ts","sourceRoot":"","sources":["../../../src/box/test/box.test.tsx"],"names":[],"mappings":""}
@@ -1,46 +0,0 @@
1
- import { type PaddingSize, type BorderRadiusSize, type BorderWidthSize, type Target, type SurfaceBackgroundColor, type ContentForegroundColor, type SurfaceStrokeColor } from '@wordpress/theme';
2
- import { type ComponentProps } from '../utils/types';
3
- type DimensionVariant<T> = {
4
- block?: T;
5
- blockStart?: T;
6
- blockEnd?: T;
7
- inline?: T;
8
- inlineStart?: T;
9
- inlineEnd?: T;
10
- };
11
- export interface BoxProps extends ComponentProps<'div'> {
12
- /**
13
- * The target rendering element design token grouping to use for the box.
14
- */
15
- target?: Target;
16
- /**
17
- * The surface background design token for box background color.
18
- */
19
- backgroundColor?: SurfaceBackgroundColor;
20
- /**
21
- * The surface foreground design token for box text color.
22
- */
23
- color?: ContentForegroundColor;
24
- /**
25
- * The surface spacing design token or base unit multiplier for box padding.
26
- */
27
- padding?: PaddingSize | DimensionVariant<PaddingSize>;
28
- /**
29
- * The surface border radius design token.
30
- */
31
- borderRadius?: BorderRadiusSize;
32
- /**
33
- * The surface border width design token.
34
- */
35
- borderWidth?: BorderWidthSize;
36
- /**
37
- * The surface border stroke color design token.
38
- */
39
- borderColor?: SurfaceStrokeColor;
40
- /**
41
- * The content to be rendered inside the component.
42
- */
43
- children?: React.ReactNode;
44
- }
45
- export {};
46
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/box/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,KAAK,gBAAgB,CAAE,CAAC,IAAK;IAC5B,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,UAAU,CAAC,EAAE,CAAC,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,CAAC;IACb,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,WAAW,CAAC,EAAE,CAAC,CAAC;IAChB,SAAS,CAAC,EAAE,CAAC,CAAC;CACd,CAAC;AAEF,MAAM,WAAW,QAAS,SAAQ,cAAc,CAAE,KAAK,CAAE;IACxD;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,eAAe,CAAC,EAAE,sBAAsB,CAAC;IAEzC;;OAEG;IACH,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAE/B;;OAEG;IACH,OAAO,CAAC,EAAE,WAAW,GAAG,gBAAgB,CAAE,WAAW,CAAE,CAAC;IAExD;;OAEG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAEhC;;OAEG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC;IAE9B;;OAEG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;IAEjC;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B"}
package/src/box/box.tsx DELETED
@@ -1,118 +0,0 @@
1
- import { useRender, mergeProps } from '@base-ui/react';
2
- import { forwardRef } from '@wordpress/element';
3
- import { type BoxProps } from './types';
4
-
5
- /**
6
- * Default render function that renders a div element with the given props.
7
- */
8
- const DEFAULT_RENDER = ( props: React.ComponentPropsWithoutRef< 'div' > ) => (
9
- <div { ...props } />
10
- );
11
-
12
- /**
13
- * Capitalizes the first character of a string.
14
- */
15
- const capitalize = ( str: string ): string =>
16
- str.charAt( 0 ).toUpperCase() + str.slice( 1 );
17
-
18
- /**
19
- * Converts a size token name to a CSS design token property reference (with
20
- * fallback).
21
- *
22
- * @param property The CSS property name.
23
- * @param target The design system token target.
24
- * @param value The size token name.
25
- * @return A CSS value string with variable references.
26
- */
27
- const getSpacingValue = (
28
- property: string,
29
- target: string,
30
- value: string
31
- ): string =>
32
- `var(--wpds-dimension-${ property }-${ target }-${ value }, var(--wpds-dimension-${ property }-surface-${ value }))`;
33
-
34
- /**
35
- * Generates CSS styles for properties with optionally directional values,
36
- * normalizing single values and objects with directional keys for logical
37
- * properties.
38
- *
39
- * @param property The CSS property name from BoxProps.
40
- * @param target The design system token target.
41
- * @param value The property value (single or object with directional keys).
42
- * @return A CSSProperties object with the computed styles.
43
- */
44
- const getDimensionVariantStyles = < T extends keyof BoxProps >(
45
- property: T,
46
- target: string,
47
- value: NonNullable< BoxProps[ T ] >
48
- ): React.CSSProperties =>
49
- typeof value !== 'object'
50
- ? { [ property ]: getSpacingValue( property, target, value ) }
51
- : Object.keys( value ).reduce(
52
- ( result, key ) => ( {
53
- ...result,
54
- [ property + capitalize( key ) ]: getSpacingValue(
55
- property,
56
- target,
57
- value[ key ]
58
- ),
59
- } ),
60
- {} as Record< string, string >
61
- );
62
-
63
- /**
64
- * A low-level visual primitive that provides an interface for applying design
65
- * token-based customization for background, text, padding, and more.
66
- */
67
- export const Box = forwardRef< HTMLDivElement, BoxProps >( function Box(
68
- {
69
- target = 'surface',
70
- backgroundColor,
71
- color,
72
- padding,
73
- borderRadius,
74
- borderWidth,
75
- borderColor,
76
- render = DEFAULT_RENDER,
77
- ...props
78
- },
79
- ref
80
- ) {
81
- const style: React.CSSProperties = {};
82
-
83
- if ( backgroundColor ) {
84
- style.backgroundColor = `var(--wpds-color-bg-${ target }-${ backgroundColor }, var(--wpds-color-bg-surface-${ backgroundColor }))`;
85
- }
86
-
87
- if ( color ) {
88
- style.color = `var(--wpds-color-fg-${ target }-${ color }, var(--wpds-color-fg-content-${ color }))`;
89
- }
90
-
91
- if ( padding ) {
92
- Object.assign(
93
- style,
94
- getDimensionVariantStyles( 'padding', target, padding )
95
- );
96
- }
97
-
98
- if ( borderRadius ) {
99
- style.borderRadius = `var(--wpds-border-radius-${ target }-${ borderRadius }, var(--wpds-border-radius-${ borderRadius }))`;
100
- }
101
-
102
- if ( borderWidth ) {
103
- style.borderWidth = `var(--wpds-border-width-${ target }-${ borderWidth }, var(--wpds-border-width-${ borderWidth }))`;
104
- style.borderStyle = 'solid';
105
- }
106
-
107
- if ( borderColor ) {
108
- style.borderColor = `var(--wpds-color-stroke-${ target }-${ borderColor }, var(--wpds-color-stroke-surface-${ borderColor }))`;
109
- }
110
-
111
- const element = useRender( {
112
- render,
113
- ref,
114
- props: mergeProps< 'div' >( props, { style } ),
115
- } );
116
-
117
- return element;
118
- } );
package/src/box/index.ts DELETED
@@ -1 +0,0 @@
1
- export { Box } from './box';
@@ -1,41 +0,0 @@
1
- import { type Meta, type StoryObj } from '@storybook/react-vite';
2
- import { type PaddingSize } from '@wordpress/theme';
3
- import { Box } from '../box';
4
-
5
- const meta: Meta< typeof Box > = {
6
- title: 'Design System/Components/Box',
7
- component: Box,
8
- };
9
- export default meta;
10
-
11
- type Story = StoryObj< typeof Box >;
12
-
13
- export const Default: Story = {
14
- args: {
15
- children: 'Box',
16
- backgroundColor: 'info',
17
- color: 'info',
18
- padding: 'sm',
19
- borderColor: 'brand',
20
- borderRadius: 'md',
21
- borderWidth: 'sm',
22
- },
23
- argTypes: {
24
- padding: {
25
- control: 'select',
26
- options: [ '2xs', 'xs', 'sm', 'md', 'lg' ] satisfies PaddingSize[],
27
- },
28
- },
29
- };
30
-
31
- export const DirectionalPadding: Story = {
32
- ...Default,
33
- args: {
34
- ...Default.args,
35
- padding: {
36
- blockStart: 'sm',
37
- inline: 'md',
38
- blockEnd: 'lg',
39
- },
40
- },
41
- };
@@ -1,29 +0,0 @@
1
- import { render, screen } from '@testing-library/react';
2
- import { createRef } from '@wordpress/element';
3
- import { Box } from '../box';
4
-
5
- describe( 'Box', () => {
6
- it( 'forwards ref', () => {
7
- const ref = createRef< HTMLDivElement >();
8
-
9
- render( <Box ref={ ref }>Content</Box> );
10
-
11
- expect( ref.current ).toBeInstanceOf( HTMLDivElement );
12
- } );
13
-
14
- it( 'merges props', () => {
15
- render(
16
- <Box backgroundColor="brand" style={ { width: '10px' } }>
17
- Content
18
- </Box>
19
- );
20
-
21
- const box = screen.getByText( 'Content' );
22
-
23
- expect( box ).toHaveStyle( {
24
- 'background-color':
25
- 'var(--wpds-color-bg-surface-brand, var(--wpds-color-bg-surface-brand))',
26
- width: '10px',
27
- } );
28
- } );
29
- } );
package/src/box/types.ts DELETED
@@ -1,61 +0,0 @@
1
- import {
2
- type PaddingSize,
3
- type BorderRadiusSize,
4
- type BorderWidthSize,
5
- type Target,
6
- type SurfaceBackgroundColor,
7
- type ContentForegroundColor,
8
- type SurfaceStrokeColor,
9
- } from '@wordpress/theme';
10
- import { type ComponentProps } from '../utils/types';
11
-
12
- type DimensionVariant< T > = {
13
- block?: T;
14
- blockStart?: T;
15
- blockEnd?: T;
16
- inline?: T;
17
- inlineStart?: T;
18
- inlineEnd?: T;
19
- };
20
-
21
- export interface BoxProps extends ComponentProps< 'div' > {
22
- /**
23
- * The target rendering element design token grouping to use for the box.
24
- */
25
- target?: Target;
26
-
27
- /**
28
- * The surface background design token for box background color.
29
- */
30
- backgroundColor?: SurfaceBackgroundColor;
31
-
32
- /**
33
- * The surface foreground design token for box text color.
34
- */
35
- color?: ContentForegroundColor;
36
-
37
- /**
38
- * The surface spacing design token or base unit multiplier for box padding.
39
- */
40
- padding?: PaddingSize | DimensionVariant< PaddingSize >;
41
-
42
- /**
43
- * The surface border radius design token.
44
- */
45
- borderRadius?: BorderRadiusSize;
46
-
47
- /**
48
- * The surface border width design token.
49
- */
50
- borderWidth?: BorderWidthSize;
51
-
52
- /**
53
- * The surface border stroke color design token.
54
- */
55
- borderColor?: SurfaceStrokeColor;
56
-
57
- /**
58
- * The content to be rendered inside the component.
59
- */
60
- children?: React.ReactNode;
61
- }
File without changes
File without changes