@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.
- package/AGENTS.md +9 -0
- package/CHANGELOG.md +32 -1
- package/CLAUDE.md +1 -0
- package/README.md +13 -12
- package/build/badge/badge.cjs +37 -62
- package/build/badge/badge.cjs.map +4 -4
- package/build/button/button.cjs +3 -3
- package/build/button/button.cjs.map +2 -2
- package/build/dialog/action.cjs +46 -0
- package/build/dialog/action.cjs.map +7 -0
- package/build/dialog/close-icon.cjs +57 -0
- package/build/dialog/close-icon.cjs.map +7 -0
- package/build/dialog/context.cjs +76 -0
- package/build/dialog/context.cjs.map +7 -0
- package/build/dialog/footer.cjs +64 -0
- package/build/dialog/footer.cjs.map +7 -0
- package/build/dialog/header.cjs +64 -0
- package/build/dialog/header.cjs.map +7 -0
- package/build/dialog/index.cjs +52 -0
- package/build/dialog/index.cjs.map +7 -0
- package/build/dialog/popup.cjs +77 -0
- package/build/dialog/popup.cjs.map +7 -0
- package/build/dialog/root.cjs +35 -0
- package/build/dialog/root.cjs.map +7 -0
- package/build/dialog/title.cjs +76 -0
- package/build/dialog/title.cjs.map +7 -0
- package/build/dialog/trigger.cjs +38 -0
- package/build/dialog/trigger.cjs.map +7 -0
- package/build/dialog/types.cjs +19 -0
- package/build/dialog/types.cjs.map +7 -0
- package/build/form/primitives/field/root.cjs +1 -1
- package/build/form/primitives/field/root.cjs.map +1 -1
- package/build/form/primitives/fieldset/root.cjs +3 -3
- package/build/form/primitives/fieldset/root.cjs.map +2 -2
- package/build/form/primitives/index.cjs +5 -2
- package/build/form/primitives/index.cjs.map +2 -2
- package/build/form/primitives/input-layout/input-layout.cjs +3 -3
- package/build/form/primitives/input-layout/input-layout.cjs.map +2 -2
- package/build/form/primitives/input-layout/slot.cjs +3 -3
- package/build/form/primitives/input-layout/slot.cjs.map +2 -2
- package/build/form/primitives/select/item.cjs +3 -3
- package/build/form/primitives/select/item.cjs.map +2 -2
- package/build/form/primitives/select/popup.cjs +3 -3
- package/build/form/primitives/select/popup.cjs.map +2 -2
- package/build/form/primitives/select/trigger.cjs +3 -3
- package/build/form/primitives/select/trigger.cjs.map +2 -2
- package/build/{box → form/primitives/textarea}/index.cjs +7 -7
- package/build/form/primitives/textarea/index.cjs.map +7 -0
- package/build/form/primitives/textarea/textarea.cjs +90 -0
- package/build/form/primitives/textarea/textarea.cjs.map +7 -0
- package/build/form/primitives/textarea/types.cjs +19 -0
- package/build/form/primitives/textarea/types.cjs.map +7 -0
- package/build/icon-button/icon-button.cjs +104 -0
- package/build/icon-button/icon-button.cjs.map +7 -0
- package/build/icon-button/index.cjs +31 -0
- package/build/icon-button/index.cjs.map +7 -0
- package/build/icon-button/types.cjs +19 -0
- package/build/icon-button/types.cjs.map +7 -0
- package/build/index.cjs +8 -2
- package/build/index.cjs.map +2 -2
- package/build/tabs/index.cjs +40 -0
- package/build/tabs/index.cjs.map +7 -0
- package/build/tabs/list.cjs +145 -0
- package/build/tabs/list.cjs.map +7 -0
- package/build/tabs/panel.cjs +67 -0
- package/build/tabs/panel.cjs.map +7 -0
- package/build/tabs/root.cjs +38 -0
- package/build/tabs/root.cjs.map +7 -0
- package/build/tabs/tab.cjs +71 -0
- package/build/tabs/tab.cjs.map +7 -0
- package/build/{box → tabs}/types.cjs +1 -1
- package/build/tabs/types.cjs.map +7 -0
- package/build/tooltip/popup.cjs +3 -3
- package/build/tooltip/popup.cjs.map +2 -2
- package/build-module/badge/badge.mjs +27 -62
- package/build-module/badge/badge.mjs.map +3 -3
- package/build-module/button/button.mjs +3 -3
- package/build-module/button/button.mjs.map +2 -2
- package/build-module/dialog/action.mjs +21 -0
- package/build-module/dialog/action.mjs.map +7 -0
- package/build-module/dialog/close-icon.mjs +32 -0
- package/build-module/dialog/close-icon.mjs.map +7 -0
- package/build-module/dialog/context.mjs +57 -0
- package/build-module/dialog/context.mjs.map +7 -0
- package/build-module/dialog/footer.mjs +29 -0
- package/build-module/dialog/footer.mjs.map +7 -0
- package/build-module/dialog/header.mjs +29 -0
- package/build-module/dialog/header.mjs.map +7 -0
- package/build-module/dialog/index.mjs +20 -0
- package/build-module/dialog/index.mjs.map +7 -0
- package/build-module/dialog/popup.mjs +44 -0
- package/build-module/dialog/popup.mjs.map +7 -0
- package/build-module/dialog/root.mjs +10 -0
- package/build-module/dialog/root.mjs.map +7 -0
- package/build-module/dialog/title.mjs +41 -0
- package/build-module/dialog/title.mjs.map +7 -0
- package/build-module/dialog/trigger.mjs +13 -0
- package/build-module/dialog/trigger.mjs.map +7 -0
- package/build-module/form/primitives/field/root.mjs +1 -1
- package/build-module/form/primitives/field/root.mjs.map +1 -1
- package/build-module/form/primitives/fieldset/root.mjs +3 -3
- package/build-module/form/primitives/fieldset/root.mjs.map +2 -2
- package/build-module/form/primitives/index.mjs +3 -1
- package/build-module/form/primitives/index.mjs.map +2 -2
- package/build-module/form/primitives/input-layout/input-layout.mjs +3 -3
- package/build-module/form/primitives/input-layout/input-layout.mjs.map +2 -2
- package/build-module/form/primitives/input-layout/slot.mjs +3 -3
- package/build-module/form/primitives/input-layout/slot.mjs.map +2 -2
- package/build-module/form/primitives/select/item.mjs +3 -3
- package/build-module/form/primitives/select/item.mjs.map +2 -2
- package/build-module/form/primitives/select/popup.mjs +3 -3
- package/build-module/form/primitives/select/popup.mjs.map +2 -2
- package/build-module/form/primitives/select/trigger.mjs +3 -3
- package/build-module/form/primitives/select/trigger.mjs.map +2 -2
- package/build-module/form/primitives/textarea/index.mjs +6 -0
- package/build-module/form/primitives/textarea/index.mjs.map +7 -0
- package/build-module/form/primitives/textarea/textarea.mjs +55 -0
- package/build-module/form/primitives/textarea/textarea.mjs.map +7 -0
- package/build-module/form/primitives/textarea/types.mjs +1 -0
- package/build-module/form/primitives/textarea/types.mjs.map +7 -0
- package/build-module/icon-button/icon-button.mjs +69 -0
- package/build-module/icon-button/icon-button.mjs.map +7 -0
- package/build-module/icon-button/index.mjs +6 -0
- package/build-module/icon-button/index.mjs.map +7 -0
- package/build-module/icon-button/types.mjs +1 -0
- package/build-module/icon-button/types.mjs.map +7 -0
- package/build-module/index.mjs +5 -1
- package/build-module/index.mjs.map +2 -2
- package/build-module/tabs/index.mjs +12 -0
- package/build-module/tabs/index.mjs.map +7 -0
- package/build-module/tabs/list.mjs +110 -0
- package/build-module/tabs/list.mjs.map +7 -0
- package/build-module/tabs/panel.mjs +32 -0
- package/build-module/tabs/panel.mjs.map +7 -0
- package/build-module/tabs/root.mjs +13 -0
- package/build-module/tabs/root.mjs.map +7 -0
- package/build-module/tabs/tab.mjs +36 -0
- package/build-module/tabs/tab.mjs.map +7 -0
- package/build-module/tabs/types.mjs +1 -0
- package/build-module/tabs/types.mjs.map +7 -0
- package/build-module/tooltip/popup.mjs +3 -3
- package/build-module/tooltip/popup.mjs.map +2 -2
- package/build-types/badge/badge.d.ts +1 -2
- package/build-types/badge/badge.d.ts.map +1 -1
- package/build-types/button/stories/index.story.d.ts +1 -2
- package/build-types/button/stories/index.story.d.ts.map +1 -1
- package/build-types/dialog/action.d.ts +8 -0
- package/build-types/dialog/action.d.ts.map +1 -0
- package/build-types/dialog/close-icon.d.ts +8 -0
- package/build-types/dialog/close-icon.d.ts.map +1 -0
- package/build-types/dialog/context.d.ts +25 -0
- package/build-types/dialog/context.d.ts.map +1 -0
- package/build-types/dialog/footer.d.ts +8 -0
- package/build-types/dialog/footer.d.ts.map +1 -0
- package/build-types/dialog/header.d.ts +8 -0
- package/build-types/dialog/header.d.ts.map +1 -0
- package/build-types/dialog/index.d.ts +10 -0
- package/build-types/dialog/index.d.ts.map +1 -0
- package/build-types/dialog/popup.d.ts +8 -0
- package/build-types/dialog/popup.d.ts.map +1 -0
- package/build-types/dialog/root.d.ts +10 -0
- package/build-types/dialog/root.d.ts.map +1 -0
- package/build-types/dialog/stories/index.story.d.ts +18 -0
- package/build-types/dialog/stories/index.story.d.ts.map +1 -0
- package/build-types/dialog/test/index.test.d.ts +2 -0
- package/build-types/dialog/test/index.test.d.ts.map +1 -0
- package/build-types/dialog/title.d.ts +12 -0
- package/build-types/dialog/title.d.ts.map +1 -0
- package/build-types/dialog/trigger.d.ts +7 -0
- package/build-types/dialog/trigger.d.ts.map +1 -0
- package/build-types/dialog/types.d.ts +77 -0
- package/build-types/dialog/types.d.ts.map +1 -0
- package/build-types/form/primitives/field/stories/index.story.d.ts +0 -1
- package/build-types/form/primitives/field/stories/index.story.d.ts.map +1 -1
- package/build-types/form/primitives/index.d.ts +1 -0
- package/build-types/form/primitives/index.d.ts.map +1 -1
- package/build-types/form/primitives/input/input.d.ts +1 -1
- package/build-types/form/primitives/select/stories/index.story.d.ts +0 -1
- package/build-types/form/primitives/select/stories/index.story.d.ts.map +1 -1
- package/build-types/form/primitives/textarea/index.d.ts +2 -0
- package/build-types/form/primitives/textarea/index.d.ts.map +1 -0
- package/build-types/form/primitives/textarea/stories/index.story.d.ts +13 -0
- package/build-types/form/primitives/textarea/stories/index.story.d.ts.map +1 -0
- package/build-types/form/primitives/textarea/test/index.test.d.ts +2 -0
- package/build-types/form/primitives/textarea/test/index.test.d.ts.map +1 -0
- package/build-types/form/primitives/textarea/textarea.d.ts +4 -0
- package/build-types/form/primitives/textarea/textarea.d.ts.map +1 -0
- package/build-types/form/primitives/textarea/types.d.ts +11 -0
- package/build-types/form/primitives/textarea/types.d.ts.map +1 -0
- package/build-types/icon-button/icon-button.d.ts +13 -0
- package/build-types/icon-button/icon-button.d.ts.map +1 -0
- package/build-types/icon-button/index.d.ts +2 -0
- package/build-types/icon-button/index.d.ts.map +1 -0
- package/build-types/icon-button/stories/index.story.d.ts +19 -0
- package/build-types/icon-button/stories/index.story.d.ts.map +1 -0
- package/build-types/icon-button/test/index.test.d.ts +2 -0
- package/build-types/icon-button/test/index.test.d.ts.map +1 -0
- package/build-types/icon-button/types.d.ts +36 -0
- package/build-types/icon-button/types.d.ts.map +1 -0
- package/build-types/index.d.ts +3 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/stack/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/index.d.ts +6 -0
- package/build-types/tabs/index.d.ts.map +1 -0
- package/build-types/tabs/list.d.ts +16 -0
- package/build-types/tabs/list.d.ts.map +1 -0
- package/build-types/tabs/panel.d.ts +15 -0
- package/build-types/tabs/panel.d.ts.map +1 -0
- package/build-types/tabs/root.d.ts +15 -0
- package/build-types/tabs/root.d.ts.map +1 -0
- package/build-types/tabs/stories/index.story.d.ts +13 -0
- package/build-types/tabs/stories/index.story.d.ts.map +1 -0
- package/build-types/tabs/tab.d.ts +15 -0
- package/build-types/tabs/tab.d.ts.map +1 -0
- package/build-types/tabs/test/index.test.d.ts +2 -0
- package/build-types/tabs/test/index.test.d.ts.map +1 -0
- package/build-types/tabs/types.d.ts +33 -0
- package/build-types/tabs/types.d.ts.map +1 -0
- package/package.json +12 -10
- package/src/badge/badge.tsx +19 -78
- package/src/badge/stories/choosing-intent.story.tsx +1 -1
- package/src/badge/style.module.css +48 -0
- package/src/button/stories/index.story.tsx +3 -16
- package/src/button/style.module.css +23 -12
- package/src/dialog/action.tsx +22 -0
- package/src/dialog/close-icon.tsx +32 -0
- package/src/dialog/context.tsx +113 -0
- package/src/dialog/footer.tsx +26 -0
- package/src/dialog/header.tsx +26 -0
- package/src/dialog/index.ts +10 -0
- package/src/dialog/popup.tsx +46 -0
- package/src/dialog/root.tsx +14 -0
- package/src/dialog/stories/index.story.tsx +177 -0
- package/src/dialog/style.module.css +114 -0
- package/src/dialog/test/index.test.tsx +309 -0
- package/src/dialog/title.tsx +39 -0
- package/src/dialog/trigger.tsx +14 -0
- package/src/dialog/types.ts +93 -0
- package/src/form/primitives/field/root.tsx +1 -1
- package/src/form/primitives/field/stories/index.story.tsx +0 -1
- package/src/form/primitives/fieldset/style.module.css +1 -1
- package/src/form/primitives/index.ts +1 -0
- package/src/form/primitives/input-layout/style.module.css +5 -8
- package/src/form/primitives/select/stories/index.story.tsx +0 -1
- package/src/form/primitives/select/test/index.test.tsx +0 -2
- package/src/form/primitives/textarea/index.ts +1 -0
- package/src/form/primitives/textarea/stories/index.story.tsx +40 -0
- package/src/form/primitives/textarea/style.module.css +22 -0
- package/src/form/primitives/textarea/test/index.test.tsx +143 -0
- package/src/form/primitives/textarea/textarea.tsx +51 -0
- package/src/form/primitives/textarea/types.ts +18 -0
- package/src/icon-button/icon-button.tsx +65 -0
- package/src/icon-button/index.ts +1 -0
- package/src/icon-button/stories/index.story.tsx +128 -0
- package/src/icon-button/style.module.css +16 -0
- package/src/icon-button/test/index.test.tsx +86 -0
- package/src/icon-button/types.ts +38 -0
- package/src/index.ts +3 -1
- package/src/stack/stories/index.story.tsx +4 -5
- package/src/tabs/index.ts +6 -0
- package/src/tabs/list.tsx +130 -0
- package/src/tabs/panel.tsx +23 -0
- package/src/tabs/root.tsx +15 -0
- package/src/tabs/stories/best-practices.mdx +85 -0
- package/src/tabs/stories/index.story.tsx +363 -0
- package/src/tabs/style.module.css +269 -0
- package/src/tabs/tab.tsx +29 -0
- package/src/tabs/test/index.test.tsx +2260 -0
- package/src/tabs/types.ts +36 -0
- package/src/tooltip/style.module.css +3 -3
- package/src/utils/css/item-popup.module.css +2 -2
- package/src/utils/css/select-trigger.module.css +1 -1
- package/build/box/box.cjs +0 -88
- package/build/box/box.cjs.map +0 -7
- package/build/box/index.cjs.map +0 -7
- package/build/box/types.cjs.map +0 -7
- package/build-module/box/box.mjs +0 -63
- package/build-module/box/box.mjs.map +0 -7
- package/build-module/box/index.mjs +0 -6
- package/build-module/box/index.mjs.map +0 -7
- package/build-types/box/box.d.ts +0 -7
- package/build-types/box/box.d.ts.map +0 -1
- package/build-types/box/index.d.ts +0 -2
- package/build-types/box/index.d.ts.map +0 -1
- package/build-types/box/stories/index.story.d.ts +0 -8
- package/build-types/box/stories/index.story.d.ts.map +0 -1
- package/build-types/box/test/box.test.d.ts +0 -2
- package/build-types/box/test/box.test.d.ts.map +0 -1
- package/build-types/box/types.d.ts +0 -46
- package/build-types/box/types.d.ts.map +0 -1
- package/src/box/box.tsx +0 -118
- package/src/box/index.ts +0 -1
- package/src/box/stories/index.story.tsx +0 -41
- package/src/box/test/box.test.tsx +0 -29
- package/src/box/types.ts +0 -61
- /package/build-module/{box → dialog}/types.mjs +0 -0
- /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-
|
|
12
|
-
var(--wpds-dimension-padding-
|
|
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-
|
|
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-
|
|
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-
|
|
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;
|
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
|
package/build/box/box.cjs.map
DELETED
|
@@ -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
|
-
}
|
package/build/box/index.cjs.map
DELETED
package/build/box/types.cjs.map
DELETED
|
@@ -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
|
-
}
|
package/build-module/box/box.mjs
DELETED
|
@@ -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
|
-
}
|
package/build-types/box/box.d.ts
DELETED
|
@@ -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 +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 +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
|