@wordpress/ui 0.3.1-next.6deb34194.0 → 1.0.1-next.738bb1424.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 (99) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/build/badge/badge.cjs +95 -0
  3. package/build/badge/badge.cjs.map +7 -0
  4. package/build/{lock-unlock.js → badge/index.cjs} +8 -14
  5. package/build/badge/index.cjs.map +7 -0
  6. package/build/badge/types.cjs +19 -0
  7. package/build/badge/types.cjs.map +7 -0
  8. package/build/box/{box.js → box.cjs} +3 -3
  9. package/build/box/box.cjs.map +7 -0
  10. package/build/box/{index.js → index.cjs} +2 -2
  11. package/build/box/{types.js → types.cjs} +1 -1
  12. package/build/box/types.cjs.map +7 -0
  13. package/build/{index.js → index.cjs} +7 -3
  14. package/build/index.cjs.map +7 -0
  15. package/build/stack/{index.js → index.cjs} +2 -2
  16. package/build/stack/index.cjs.map +7 -0
  17. package/build/stack/{stack.js → stack.cjs} +7 -26
  18. package/build/stack/stack.cjs.map +7 -0
  19. package/build/stack/{types.js → types.cjs} +1 -1
  20. package/build/stack/types.cjs.map +7 -0
  21. package/build/types/css-modules.d.cjs +2 -0
  22. package/build/types/css-modules.d.cjs.map +7 -0
  23. package/build/types/{react.d.js → react.d.cjs} +1 -1
  24. package/build/utils/{element.js → element.cjs} +1 -1
  25. package/build/utils/{types.js → types.cjs} +1 -1
  26. package/build-module/badge/badge.js +70 -0
  27. package/build-module/badge/badge.js.map +7 -0
  28. package/build-module/badge/index.js +6 -0
  29. package/build-module/badge/index.js.map +7 -0
  30. package/build-module/badge/types.js +1 -0
  31. package/build-module/box/box.js +2 -2
  32. package/build-module/box/box.js.map +2 -2
  33. package/build-module/box/index.js +1 -1
  34. package/build-module/index.js +3 -1
  35. package/build-module/index.js.map +2 -2
  36. package/build-module/stack/index.js +1 -1
  37. package/build-module/stack/index.js.map +2 -2
  38. package/build-module/stack/stack.js +4 -22
  39. package/build-module/stack/stack.js.map +2 -2
  40. package/build-types/badge/badge.d.ts +7 -0
  41. package/build-types/badge/badge.d.ts.map +1 -0
  42. package/build-types/badge/index.d.ts +2 -0
  43. package/build-types/badge/index.d.ts.map +1 -0
  44. package/build-types/badge/stories/index.story.d.ts +22 -0
  45. package/build-types/badge/stories/index.story.d.ts.map +1 -0
  46. package/build-types/badge/types.d.ts +17 -0
  47. package/build-types/badge/types.d.ts.map +1 -0
  48. package/build-types/box/box.d.ts.map +1 -1
  49. package/build-types/box/stories/index.story.d.ts +0 -9
  50. package/build-types/box/stories/index.story.d.ts.map +1 -1
  51. package/build-types/box/types.d.ts +8 -15
  52. package/build-types/box/types.d.ts.map +1 -1
  53. package/build-types/index.d.ts +2 -0
  54. package/build-types/index.d.ts.map +1 -1
  55. package/build-types/stack/index.d.ts +0 -3
  56. package/build-types/stack/index.d.ts.map +1 -1
  57. package/build-types/stack/stack.d.ts +1 -10
  58. package/build-types/stack/stack.d.ts.map +1 -1
  59. package/build-types/stack/stories/index.story.d.ts.map +1 -1
  60. package/build-types/stack/types.d.ts +4 -8
  61. package/build-types/stack/types.d.ts.map +1 -1
  62. package/build-types/test/index.test.d.ts +2 -0
  63. package/build-types/test/index.test.d.ts.map +1 -0
  64. package/package.json +14 -7
  65. package/src/badge/badge.tsx +98 -0
  66. package/src/badge/index.ts +1 -0
  67. package/src/badge/stories/choosing-intent.mdx +112 -0
  68. package/src/badge/stories/index.story.tsx +134 -0
  69. package/src/badge/types.ts +25 -0
  70. package/src/box/box.tsx +5 -7
  71. package/src/box/stories/index.story.tsx +2 -12
  72. package/src/box/types.ts +16 -59
  73. package/src/index.ts +2 -0
  74. package/src/stack/index.ts +0 -3
  75. package/src/stack/stack.tsx +3 -37
  76. package/src/stack/stories/index.story.tsx +1 -13
  77. package/src/stack/test/stack.test.tsx +1 -21
  78. package/src/stack/types.ts +4 -9
  79. package/src/test/index.test.ts +22 -0
  80. package/build/box/box.js.map +0 -7
  81. package/build/box/types.js.map +0 -7
  82. package/build/index.js.map +0 -7
  83. package/build/lock-unlock.js.map +0 -7
  84. package/build/stack/index.js.map +0 -7
  85. package/build/stack/stack.js.map +0 -7
  86. package/build/stack/types.js.map +0 -7
  87. package/build/types/css-modules.d.js +0 -2
  88. package/build-module/lock-unlock.js +0 -11
  89. package/build-module/lock-unlock.js.map +0 -7
  90. package/build-types/lock-unlock.d.ts +0 -2
  91. package/build-types/lock-unlock.d.ts.map +0 -1
  92. package/src/lock-unlock.ts +0 -10
  93. package/tsconfig.json +0 -13
  94. package/tsconfig.tsbuildinfo +0 -1
  95. /package/build/box/{index.js.map → index.cjs.map} +0 -0
  96. /package/build/types/{react.d.js.map → react.d.cjs.map} +0 -0
  97. /package/build/utils/{element.js.map → element.cjs.map} +0 -0
  98. /package/build/utils/{types.js.map → types.cjs.map} +0 -0
  99. /package/{build/types/css-modules.d.js.map → build-module/badge/types.js.map} +0 -0
@@ -0,0 +1,134 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { Meta, StoryObj } from '@storybook/react';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { Fragment } from '@wordpress/element';
10
+ import '@wordpress/theme/design-tokens.css';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import { Badge } from '../index';
16
+
17
+ const meta: Meta< typeof Badge > = {
18
+ title: 'Design System/Components/Badge',
19
+ component: Badge,
20
+ tags: [ 'status-experimental' ],
21
+ };
22
+ export default meta;
23
+
24
+ type Story = StoryObj< typeof Badge >;
25
+
26
+ export const Default: Story = {
27
+ args: {
28
+ children: 'Badge',
29
+ },
30
+ };
31
+
32
+ export const High: Story = {
33
+ ...Default,
34
+ args: {
35
+ ...Default.args,
36
+ intent: 'high',
37
+ },
38
+ };
39
+
40
+ export const Medium: Story = {
41
+ ...Default,
42
+ args: {
43
+ ...Default.args,
44
+ intent: 'medium',
45
+ },
46
+ };
47
+
48
+ export const Low: Story = {
49
+ ...Default,
50
+ args: {
51
+ ...Default.args,
52
+ intent: 'low',
53
+ },
54
+ };
55
+
56
+ export const Stable: Story = {
57
+ ...Default,
58
+ args: {
59
+ ...Default.args,
60
+ intent: 'stable',
61
+ },
62
+ };
63
+
64
+ export const Informational: Story = {
65
+ ...Default,
66
+ args: {
67
+ ...Default.args,
68
+ intent: 'informational',
69
+ },
70
+ };
71
+
72
+ export const Draft: Story = {
73
+ ...Default,
74
+ args: {
75
+ ...Default.args,
76
+ intent: 'draft',
77
+ },
78
+ };
79
+
80
+ export const None: Story = {
81
+ ...Default,
82
+ args: {
83
+ ...Default.args,
84
+ intent: 'none',
85
+ },
86
+ };
87
+
88
+ export const AllIntents: Story = {
89
+ ...Default,
90
+ render: ( args ) => (
91
+ <div
92
+ style={ {
93
+ display: 'grid',
94
+ gridTemplateColumns: 'max-content min-content',
95
+ gap: '1rem',
96
+ color: 'var(--wpds-color-fg-content-neutral)',
97
+ backgroundColor: 'var(--wpds-color-bg-surface-neutral-strong)',
98
+ } }
99
+ >
100
+ { (
101
+ [
102
+ 'high',
103
+ 'medium',
104
+ 'low',
105
+ 'stable',
106
+ 'informational',
107
+ 'draft',
108
+ 'none',
109
+ ] as const
110
+ ).map( ( intent ) => (
111
+ <Fragment key={ intent }>
112
+ <div
113
+ style={ {
114
+ paddingInlineEnd: '1rem',
115
+ display: 'flex',
116
+ alignItems: 'center',
117
+ } }
118
+ >
119
+ { intent }
120
+ </div>
121
+ <div
122
+ style={ {
123
+ padding: '0.5rem 1rem',
124
+ display: 'flex',
125
+ alignItems: 'center',
126
+ } }
127
+ >
128
+ <Badge { ...args } intent={ intent } />
129
+ </div>
130
+ </Fragment>
131
+ ) ) }
132
+ </div>
133
+ ),
134
+ };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { type ComponentProps } from '../utils/types';
5
+
6
+ export interface BadgeProps extends ComponentProps< 'span' > {
7
+ /**
8
+ * The text to display in the badge.
9
+ */
10
+ children: string;
11
+
12
+ /**
13
+ * The semantic intent of the badge, communicating its meaning through color.
14
+ *
15
+ * @default "none"
16
+ */
17
+ intent?:
18
+ | 'high'
19
+ | 'medium'
20
+ | 'low'
21
+ | 'stable'
22
+ | 'informational'
23
+ | 'draft'
24
+ | 'none';
25
+ }
package/src/box/box.tsx CHANGED
@@ -28,22 +28,20 @@ const capitalize = ( str: string ): string =>
28
28
  str.charAt( 0 ).toUpperCase() + str.slice( 1 );
29
29
 
30
30
  /**
31
- * Converts a size value to a CSS design token property reference (with
32
- * fallback) or a calculated value based on the base unit.
31
+ * Converts a size token name to a CSS design token property reference (with
32
+ * fallback).
33
33
  *
34
34
  * @param property The CSS property name.
35
35
  * @param target The design system token target.
36
- * @param value The size value, either a number (multiplier of base unit) or a string (token name).
36
+ * @param value The size token name.
37
37
  * @return A CSS value string with variable references.
38
38
  */
39
39
  const getSpacingValue = (
40
40
  property: string,
41
41
  target: string,
42
- value: number | string
42
+ value: string
43
43
  ): string =>
44
- typeof value === 'number'
45
- ? `calc(var(--wpds-dimension-base) * ${ value })`
46
- : `var(--wpds-dimension-${ property }-${ target }-${ value }, var(--wpds-dimension-${ property }-surface-${ value }))`;
44
+ `var(--wpds-dimension-${ property }-${ target }-${ value }, var(--wpds-dimension-${ property }-surface-${ value }))`;
47
45
 
48
46
  /**
49
47
  * Generates CSS styles for properties with optionally directional values,
@@ -1,16 +1,6 @@
1
- /**
2
- * External dependencies
3
- */
4
1
  import { type Meta, type StoryObj } from '@storybook/react';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
2
+ import { type PaddingSize } from '@wordpress/theme';
9
3
  import '@wordpress/theme/design-tokens.css';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
4
  import { Box } from '../box';
15
5
 
16
6
  const meta: Meta< typeof Box > = {
@@ -35,7 +25,7 @@ export const Default: Story = {
35
25
  argTypes: {
36
26
  padding: {
37
27
  control: 'select',
38
- options: [ '2xs', 'xs', 'sm', 'md', 'lg', 1, 2, 3, 4 ],
28
+ options: [ '2xs', 'xs', 'sm', 'md', 'lg' ] satisfies PaddingSize[],
39
29
  },
40
30
  },
41
31
  };
package/src/box/types.ts CHANGED
@@ -1,57 +1,14 @@
1
- /**
2
- * Internal dependencies
3
- */
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';
4
10
  import { type ComponentProps } from '../utils/types';
5
11
 
6
- type SizeToken = '2xs' | 'xs' | 'sm' | 'md' | 'lg';
7
-
8
- type Size = number | SizeToken;
9
-
10
- type BackgroundColor =
11
- | 'neutral'
12
- | 'neutral-strong'
13
- | 'neutral-weak'
14
- | 'brand'
15
- | 'success'
16
- | 'success-weak'
17
- | 'info'
18
- | 'info-weak'
19
- | 'warning'
20
- | 'warning-weak'
21
- | 'caution'
22
- | 'caution-weak'
23
- | 'error'
24
- | 'error-weak';
25
-
26
- type ForegroundColor =
27
- | 'neutral'
28
- | 'neutral-weak'
29
- | 'success'
30
- | 'success-weak'
31
- | 'info'
32
- | 'info-weak'
33
- | 'warning'
34
- | 'warning-weak'
35
- | 'caution'
36
- | 'caution-weak'
37
- | 'error'
38
- | 'error-weak';
39
-
40
- type StrokeColor =
41
- | 'brand'
42
- | 'brand-strong'
43
- | 'error'
44
- | 'error-strong'
45
- | 'info'
46
- | 'info-strong'
47
- | 'neutral'
48
- | 'neutral-strong'
49
- | 'neutral-weak'
50
- | 'success'
51
- | 'success-strong'
52
- | 'warning'
53
- | 'warning-strong';
54
-
55
12
  type DimensionVariant< T > = {
56
13
  block?: T;
57
14
  blockStart?: T;
@@ -65,37 +22,37 @@ export interface BoxProps extends ComponentProps< 'div' > {
65
22
  /**
66
23
  * The target rendering element design token grouping to use for the box.
67
24
  */
68
- target?: string;
25
+ target?: Target;
69
26
 
70
27
  /**
71
28
  * The surface background design token for box background color.
72
29
  */
73
- backgroundColor?: BackgroundColor;
30
+ backgroundColor?: SurfaceBackgroundColor;
74
31
 
75
32
  /**
76
33
  * The surface foreground design token for box text color.
77
34
  */
78
- color?: ForegroundColor;
35
+ color?: ContentForegroundColor;
79
36
 
80
37
  /**
81
38
  * The surface spacing design token or base unit multiplier for box padding.
82
39
  */
83
- padding?: Size | DimensionVariant< Size >;
40
+ padding?: PaddingSize | DimensionVariant< PaddingSize >;
84
41
 
85
42
  /**
86
43
  * The surface border radius design token.
87
44
  */
88
- borderRadius?: Exclude< SizeToken, '2xs' >;
45
+ borderRadius?: BorderRadiusSize;
89
46
 
90
47
  /**
91
48
  * The surface border width design token.
92
49
  */
93
- borderWidth?: Exclude< SizeToken, '2xs' >;
50
+ borderWidth?: BorderWidthSize;
94
51
 
95
52
  /**
96
53
  * The surface border stroke color design token.
97
54
  */
98
- borderColor?: StrokeColor;
55
+ borderColor?: SurfaceStrokeColor;
99
56
 
100
57
  /**
101
58
  * The content to be rendered inside the component.
package/src/index.ts CHANGED
@@ -1 +1,3 @@
1
1
  export * from './box';
2
+ export * from './badge';
3
+ export * from './stack';
@@ -1,4 +1 @@
1
- /**
2
- * Internal dependencies
3
- */
4
1
  export { Stack } from './stack';
@@ -12,55 +12,21 @@ import { forwardRef } from '@wordpress/element';
12
12
  * Internal dependencies
13
13
  */
14
14
  import { renderElement } from '../utils/element';
15
- import { type StackProps, type SizeToken } from './types';
15
+ import { type StackProps } from './types';
16
16
  import styles from './style.module.css';
17
17
 
18
- /**
19
- * Set of token names for gap spacing.
20
- */
21
- const TOKEN_NAMES = new Set< SizeToken >( [
22
- '2xs',
23
- 'xs',
24
- 'sm',
25
- 'md',
26
- 'lg',
27
- 'xl',
28
- ] );
29
-
30
- /**
31
- * Normalizes the gap value. When given a positive number, it will be converted
32
- * to a CSS calculation. When given a string, it will be returned as is.
33
- *
34
- * @param gap The gap value to normalize.
35
- *
36
- * @return The normalized gap value.
37
- */
38
- export function getNormalizedGap(
39
- gap: number | SizeToken | React.CSSProperties[ 'gap' ]
40
- ): string {
41
- if ( typeof gap === 'number' ) {
42
- return `calc( ${ gap } * var( --wpds-dimension-base ) )`;
43
- }
44
-
45
- if ( TOKEN_NAMES.has( gap as SizeToken ) ) {
46
- return `var(--wpds-dimension-gap-${ gap })`;
47
- }
48
-
49
- return String( gap );
50
- }
51
-
52
18
  /**
53
19
  * A flexible layout component using CSS Flexbox for consistent spacing and alignment.
54
20
  * Built on design tokens for predictable spacing values.
55
21
  */
56
22
  export const Stack = forwardRef< HTMLDivElement, StackProps >( function Stack(
57
- { direction, gap = 0, align, justify, wrap, render, ...props },
23
+ { direction, gap, align, justify, wrap, render, ...props },
58
24
  ref
59
25
  ) {
60
26
  const className = clsx( props.className, styles.stack );
61
27
 
62
28
  const style: React.CSSProperties = {
63
- gap: getNormalizedGap( gap ),
29
+ gap: gap && `var(--wpds-dimension-gap-${ gap })`,
64
30
  alignItems: align,
65
31
  justifyContent: justify,
66
32
  flexDirection: direction,
@@ -48,18 +48,6 @@ export const Default: Story = {
48
48
  ),
49
49
  },
50
50
  argTypes: {
51
- gap: {
52
- control: {
53
- type: 'select',
54
- },
55
- options: [ 0, 1, 2, 3, 4, '2xs', 'xs', 'sm', 'md', 'lg', 'xl' ],
56
- table: {
57
- type: {
58
- summary:
59
- 'number | "2xs" | "xs" | "sm" | "md" | "lg" | "xl"',
60
- },
61
- },
62
- },
63
51
  align: {
64
52
  options: [
65
53
  'center',
@@ -121,7 +109,7 @@ export const Nested: Story = {
121
109
  <DemoBox />
122
110
  </Stack>
123
111
  <DemoBox variant="lg" />
124
- <Stack gap={ 0 } direction="column">
112
+ <Stack direction="column">
125
113
  <DemoBox />
126
114
  <DemoBox />
127
115
  </Stack>
@@ -11,27 +11,7 @@ import { createRef } from '@wordpress/element';
11
11
  /**
12
12
  * Internal dependencies
13
13
  */
14
- import { Stack, getNormalizedGap } from '../stack';
15
-
16
- describe( 'getNormalizedGap', () => {
17
- it( 'should return the gap as a CSS calculation when the gap is a positive number', () => {
18
- const result = getNormalizedGap( 1 );
19
-
20
- expect( result ).toBe( 'calc( 1 * var( --wpds-dimension-base ) )' );
21
- } );
22
-
23
- it( 'should return the CSS variable reference to a token value', () => {
24
- const result = getNormalizedGap( 'md' );
25
-
26
- expect( result ).toBe( 'var(--wpds-dimension-gap-md)' );
27
- } );
28
-
29
- it( 'should return the gap as a literal value when the gap is a string', () => {
30
- const result = getNormalizedGap( '10px' );
31
-
32
- expect( result ).toBe( '10px' );
33
- } );
34
- } );
14
+ import { Stack } from '../stack';
35
15
 
36
16
  describe( 'Stack', () => {
37
17
  it( 'forwards ref', () => {
@@ -1,10 +1,6 @@
1
- /**
2
- * Internal dependencies
3
- */
1
+ import { type GapSize } from '@wordpress/theme';
4
2
  import { type ComponentProps } from '../utils/types';
5
3
 
6
- export type SizeToken = '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
7
-
8
4
  export interface StackProps extends ComponentProps< 'div' > {
9
5
  /**
10
6
  * The direction of the stack.
@@ -15,12 +11,11 @@ export interface StackProps extends ComponentProps< 'div' > {
15
11
  >;
16
12
 
17
13
  /**
18
- * The amount of space between each child element. As a number, it is a
19
- * multiple of the design system grid spacing.
14
+ * The amount of space between each child element using design system tokens.
20
15
  *
21
- * @default 'initial'
16
+ * @default undefined
22
17
  */
23
- gap?: number | SizeToken | React.CSSProperties[ 'gap' ];
18
+ gap?: GapSize;
24
19
 
25
20
  /**
26
21
  * The alignment of the stack items along the cross axis.
@@ -0,0 +1,22 @@
1
+ import { join, dirname, basename } from 'node:path';
2
+ import { readFile } from 'node:fs/promises';
3
+ import glob from 'fast-glob';
4
+
5
+ describe( 'index', () => {
6
+ it( 'should export something from each component', async () => {
7
+ // As described in the CONTRIBUTING.md file, each component should be
8
+ // exported from an index.ts in its implementation directory.
9
+ const components = await glob( '*/index.ts', {
10
+ cwd: join( __dirname, '..' ),
11
+ } );
12
+ const directories = components.map( ( c ) => basename( dirname( c ) ) );
13
+ const index = await readFile(
14
+ join( __dirname, '../index.ts' ),
15
+ 'utf-8'
16
+ );
17
+
18
+ for ( const directory of directories ) {
19
+ expect( index ).toContain( `'./${ directory }'` );
20
+ }
21
+ } );
22
+ } );
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/box/box.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { type BoxProps } from './types';\nimport { renderElement } from '../utils/element';\n\n/**\n * Default render function that renders a div element with the given props.\n *\n * @param props The props to apply to the HTML element.\n */\nconst DEFAULT_RENDER = ( props: React.ComponentPropsWithoutRef< 'div' > ) => (\n\t<div { ...props } />\n);\n\n/**\n * Capitalizes the first character of a string.\n *\n * @param str The string to capitalize.\n * @return The capitalized string.\n */\nconst capitalize = ( str: string ): string =>\n\tstr.charAt( 0 ).toUpperCase() + str.slice( 1 );\n\n/**\n * Converts a size value to a CSS design token property reference (with\n * fallback) or a calculated value based on the base unit.\n *\n * @param property The CSS property name.\n * @param target The design system token target.\n * @param value The size value, either a number (multiplier of base unit) or a string (token name).\n * @return A CSS value string with variable references.\n */\nconst getSpacingValue = (\n\tproperty: string,\n\ttarget: string,\n\tvalue: number | string\n): string =>\n\ttypeof value === 'number'\n\t\t? `calc(var(--wpds-dimension-base) * ${ value })`\n\t\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 = { ...props.style };\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-surface-${ borderRadius }))`;\n\t}\n\n\tif ( borderWidth ) {\n\t\tstyle.borderWidth = `var(--wpds-border-width-${ target }-${ borderWidth }, var(--wpds-border-width-surface-${ 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\treturn renderElement< 'div' >( {\n\t\trender,\n\t\tref,\n\t\tprops: { ...props, style },\n\t} );\n} );\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA2B;AAM3B,IAAAA,kBAA8B;AAQ7B;AADD,IAAM,iBAAiB,CAAE,UACxB,4CAAC,SAAM,GAAG,OAAQ;AASnB,IAAM,aAAa,CAAE,QACpB,IAAI,OAAQ,CAAE,EAAE,YAAY,IAAI,IAAI,MAAO,CAAE;AAW9C,IAAM,kBAAkB,CACvB,UACA,QACA,UAEA,OAAO,UAAU,WACd,qCAAsC,KAAM,MAC5C,wBAAyB,QAAS,IAAK,MAAO,IAAK,KAAM,0BAA2B,QAAS,YAAa,KAAM;AAYpH,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,SAASC,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,EAAE,GAAG,MAAM,MAAM;AAEpD,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,sCAAuC,YAAa;AAAA,EAChI;AAEA,MAAK,aAAc;AAClB,UAAM,cAAc,2BAA4B,MAAO,IAAK,WAAY,qCAAsC,WAAY;AAC1H,UAAM,cAAc;AAAA,EACrB;AAEA,MAAK,aAAc;AAClB,UAAM,cAAc,2BAA4B,MAAO,IAAK,WAAY,qCAAsC,WAAY;AAAA,EAC3H;AAEA,aAAO,+BAAwB;AAAA,IAC9B;AAAA,IACA;AAAA,IACA,OAAO,EAAE,GAAG,OAAO,MAAM;AAAA,EAC1B,CAAE;AACH,CAAE;",
6
- "names": ["import_element", "Box"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/box/types.ts"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { type ComponentProps } from '../utils/types';\n\ntype SizeToken = '2xs' | 'xs' | 'sm' | 'md' | 'lg';\n\ntype Size = number | SizeToken;\n\ntype BackgroundColor =\n\t| 'neutral'\n\t| 'neutral-strong'\n\t| 'neutral-weak'\n\t| 'brand'\n\t| 'success'\n\t| 'success-weak'\n\t| 'info'\n\t| 'info-weak'\n\t| 'warning'\n\t| 'warning-weak'\n\t| 'caution'\n\t| 'caution-weak'\n\t| 'error'\n\t| 'error-weak';\n\ntype ForegroundColor =\n\t| 'neutral'\n\t| 'neutral-weak'\n\t| 'success'\n\t| 'success-weak'\n\t| 'info'\n\t| 'info-weak'\n\t| 'warning'\n\t| 'warning-weak'\n\t| 'caution'\n\t| 'caution-weak'\n\t| 'error'\n\t| 'error-weak';\n\ntype StrokeColor =\n\t| 'brand'\n\t| 'brand-strong'\n\t| 'error'\n\t| 'error-strong'\n\t| 'info'\n\t| 'info-strong'\n\t| 'neutral'\n\t| 'neutral-strong'\n\t| 'neutral-weak'\n\t| 'success'\n\t| 'success-strong'\n\t| 'warning'\n\t| 'warning-strong';\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?: string;\n\n\t/**\n\t * The surface background design token for box background color.\n\t */\n\tbackgroundColor?: BackgroundColor;\n\n\t/**\n\t * The surface foreground design token for box text color.\n\t */\n\tcolor?: ForegroundColor;\n\n\t/**\n\t * The surface spacing design token or base unit multiplier for box padding.\n\t */\n\tpadding?: Size | DimensionVariant< Size >;\n\n\t/**\n\t * The surface border radius design token.\n\t */\n\tborderRadius?: Exclude< SizeToken, '2xs' >;\n\n\t/**\n\t * The surface border width design token.\n\t */\n\tborderWidth?: Exclude< SizeToken, '2xs' >;\n\n\t/**\n\t * The surface border stroke color design token.\n\t */\n\tborderColor?: StrokeColor;\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,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/index.ts"],
4
- "sourcesContent": ["export * from './box';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,kBAAd;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/lock-unlock.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/dataviews'\n\t);\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAiE;AAE1D,IAAM,EAAE,MAAM,OAAO,QAC3B;AAAA,EACC;AAAA,EACA;AACD;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/stack/index.ts"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nexport { Stack } from './stack';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAsB;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/stack/stack.tsx", "../../src/stack/style.module.css"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { renderElement } from '../utils/element';\nimport { type StackProps, type SizeToken } from './types';\nimport styles from './style.module.css';\n\n/**\n * Set of token names for gap spacing.\n */\nconst TOKEN_NAMES = new Set< SizeToken >( [\n\t'2xs',\n\t'xs',\n\t'sm',\n\t'md',\n\t'lg',\n\t'xl',\n] );\n\n/**\n * Normalizes the gap value. When given a positive number, it will be converted\n * to a CSS calculation. When given a string, it will be returned as is.\n *\n * @param gap The gap value to normalize.\n *\n * @return The normalized gap value.\n */\nexport function getNormalizedGap(\n\tgap: number | SizeToken | React.CSSProperties[ 'gap' ]\n): string {\n\tif ( typeof gap === 'number' ) {\n\t\treturn `calc( ${ gap } * var( --wpds-dimension-base ) )`;\n\t}\n\n\tif ( TOKEN_NAMES.has( gap as SizeToken ) ) {\n\t\treturn `var(--wpds-dimension-gap-${ gap })`;\n\t}\n\n\treturn String( gap );\n}\n\n/**\n * A flexible layout component using CSS Flexbox for consistent spacing and alignment.\n * Built on design tokens for predictable spacing values.\n */\nexport const Stack = forwardRef< HTMLDivElement, StackProps >( function Stack(\n\t{ direction, gap = 0, align, justify, wrap, render, ...props },\n\tref\n) {\n\tconst className = clsx( props.className, styles.stack );\n\n\tconst style: React.CSSProperties = {\n\t\tgap: getNormalizedGap( gap ),\n\t\talignItems: align,\n\t\tjustifyContent: justify,\n\t\tflexDirection: direction,\n\t\tflexWrap: wrap,\n\t\t...props.style,\n\t};\n\n\treturn renderElement< 'div' >( {\n\t\trender,\n\t\tref,\n\t\tprops: { ...props, style, className },\n\t} );\n} );\n", "const css = `@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;\n\n@layer wp-ui-components {\n\t.style-module__stack__Gc4EG {\n\t\tdisplay: flex;\n\t}\n}\n`;\ndocument.head\n .appendChild(document.createElement(\"style\"))\n .appendChild(document.createTextNode(css));\nexport {css};\nexport default {\n \"stack\": \"style-module__stack__Gc4EG\"\n};"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,qBAA2B;AAK3B,IAAAA,kBAA8B;;;ACb9B,IAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQZ,SAAS,KACJ,YAAY,SAAS,cAAc,OAAO,CAAC,EAC3C,YAAY,SAAS,eAAe,GAAG,CAAC;AAE7C,IAAO,gBAAQ;AAAA,EACb,SAAS;AACX;;;ADMA,IAAM,cAAc,oBAAI,IAAkB;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAUK,SAAS,iBACf,KACS;AACT,MAAK,OAAO,QAAQ,UAAW;AAC9B,WAAO,SAAU,GAAI;AAAA,EACtB;AAEA,MAAK,YAAY,IAAK,GAAiB,GAAI;AAC1C,WAAO,4BAA6B,GAAI;AAAA,EACzC;AAEA,SAAO,OAAQ,GAAI;AACpB;AAMO,IAAM,YAAQ,2BAA0C,SAASC,OACvE,EAAE,WAAW,MAAM,GAAG,OAAO,SAAS,MAAM,QAAQ,GAAG,MAAM,GAC7D,KACC;AACD,QAAM,gBAAY,YAAAC,SAAM,MAAM,WAAW,cAAO,KAAM;AAEtD,QAAM,QAA6B;AAAA,IAClC,KAAK,iBAAkB,GAAI;AAAA,IAC3B,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,UAAU;AAAA,IACV,GAAG,MAAM;AAAA,EACV;AAEA,aAAO,+BAAwB;AAAA,IAC9B;AAAA,IACA;AAAA,IACA,OAAO,EAAE,GAAG,OAAO,OAAO,UAAU;AAAA,EACrC,CAAE;AACH,CAAE;",
6
- "names": ["import_element", "Stack", "clsx"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/stack/types.ts"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { type ComponentProps } from '../utils/types';\n\nexport type SizeToken = '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\nexport interface StackProps extends ComponentProps< 'div' > {\n\t/**\n\t * The direction of the stack.\n\t */\n\tdirection?: Exclude<\n\t\tReact.CSSProperties[ 'flexDirection' ],\n\t\t'row-reverse' | 'column-reverse'\n\t>;\n\n\t/**\n\t * The amount of space between each child element. As a number, it is a\n\t * multiple of the design system grid spacing.\n\t *\n\t * @default 'initial'\n\t */\n\tgap?: number | SizeToken | React.CSSProperties[ 'gap' ];\n\n\t/**\n\t * The alignment of the stack items along the cross axis.\n\t *\n\t * @default 'initial'\n\t */\n\talign?: React.CSSProperties[ 'alignItems' ];\n\n\t/**\n\t * The alignment of the stack items along the main axis.\n\t *\n\t * @default 'initial'\n\t */\n\tjustify?: React.CSSProperties[ 'justifyContent' ];\n\n\t/**\n\t * Whether the stack items should wrap to the next line.\n\t */\n\twrap?: Exclude< React.CSSProperties[ 'flexWrap' ], 'wrap-reverse' >;\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,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=css-modules.d.js.map
@@ -1,11 +0,0 @@
1
- // packages/ui/src/lock-unlock.ts
2
- import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from "@wordpress/private-apis";
3
- var { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules(
4
- "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
5
- "@wordpress/dataviews"
6
- );
7
- export {
8
- lock,
9
- unlock
10
- };
11
- //# sourceMappingURL=lock-unlock.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/lock-unlock.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/dataviews'\n\t);\n"],
5
- "mappings": ";AAGA,SAAS,wDAAwD;AAE1D,IAAM,EAAE,MAAM,OAAO,IAC3B;AAAA,EACC;AAAA,EACA;AACD;",
6
- "names": []
7
- }
@@ -1,2 +0,0 @@
1
- export declare const lock: (object: unknown, privateData: unknown) => void, unlock: <T = any>(object: unknown) => T;
2
- //# sourceMappingURL=lock-unlock.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lock-unlock.d.ts","sourceRoot":"","sources":["../src/lock-unlock.ts"],"names":[],"mappings":"AAKA,eAAO,MAAQ,IAAI,mDAAE,MAAM,iCAIzB,CAAC"}
@@ -1,10 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';
5
-
6
- export const { lock, unlock } =
7
- __dangerousOptInToUnstableAPIsOnlyForCoreModules(
8
- 'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',
9
- '@wordpress/dataviews'
10
- );
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/tsconfig.json",
3
- "extends": "../../tsconfig.base.json",
4
- "compilerOptions": {
5
- "types": [ "node", "jest", "@testing-library/jest-dom" ]
6
- },
7
- "references": [
8
- { "path": "../element" },
9
- { "path": "../private-apis" },
10
- { "path": "../theme" }
11
- ],
12
- "exclude": []
13
- }