@wordpress/ui 0.4.0 → 1.0.1-next.8fd3f8831.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 (91) 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} +3 -3
  18. package/build/stack/{types.js → types.cjs} +1 -1
  19. package/build/stack/types.cjs.map +7 -0
  20. package/build/types/css-modules.d.cjs +2 -0
  21. package/build/types/css-modules.d.cjs.map +7 -0
  22. package/build/types/{react.d.js → react.d.cjs} +1 -1
  23. package/build/utils/{element.js → element.cjs} +1 -1
  24. package/build/utils/{types.js → types.cjs} +1 -1
  25. package/build-module/badge/badge.js +70 -0
  26. package/build-module/badge/badge.js.map +7 -0
  27. package/build-module/badge/index.js +6 -0
  28. package/build-module/badge/index.js.map +7 -0
  29. package/build-module/badge/types.js +1 -0
  30. package/build-module/box/box.js +2 -2
  31. package/build-module/box/box.js.map +2 -2
  32. package/build-module/box/index.js +1 -1
  33. package/build-module/index.js +3 -1
  34. package/build-module/index.js.map +2 -2
  35. package/build-module/stack/index.js +1 -1
  36. package/build-module/stack/index.js.map +2 -2
  37. package/build-module/stack/stack.js +1 -1
  38. package/build-types/badge/badge.d.ts +7 -0
  39. package/build-types/badge/badge.d.ts.map +1 -0
  40. package/build-types/badge/index.d.ts +2 -0
  41. package/build-types/badge/index.d.ts.map +1 -0
  42. package/build-types/badge/stories/index.story.d.ts +22 -0
  43. package/build-types/badge/stories/index.story.d.ts.map +1 -0
  44. package/build-types/badge/types.d.ts +17 -0
  45. package/build-types/badge/types.d.ts.map +1 -0
  46. package/build-types/box/box.d.ts.map +1 -1
  47. package/build-types/box/stories/index.story.d.ts +0 -9
  48. package/build-types/box/stories/index.story.d.ts.map +1 -1
  49. package/build-types/box/types.d.ts +8 -15
  50. package/build-types/box/types.d.ts.map +1 -1
  51. package/build-types/index.d.ts +2 -0
  52. package/build-types/index.d.ts.map +1 -1
  53. package/build-types/stack/index.d.ts +0 -3
  54. package/build-types/stack/index.d.ts.map +1 -1
  55. package/build-types/stack/types.d.ts +2 -5
  56. package/build-types/stack/types.d.ts.map +1 -1
  57. package/build-types/test/index.test.d.ts +2 -0
  58. package/build-types/test/index.test.d.ts.map +1 -0
  59. package/package.json +14 -7
  60. package/src/badge/badge.tsx +98 -0
  61. package/src/badge/index.ts +1 -0
  62. package/src/badge/stories/choosing-intent.mdx +112 -0
  63. package/src/badge/stories/index.story.tsx +134 -0
  64. package/src/badge/types.ts +25 -0
  65. package/src/box/box.tsx +5 -7
  66. package/src/box/stories/index.story.tsx +2 -12
  67. package/src/box/types.ts +16 -59
  68. package/src/index.ts +2 -0
  69. package/src/stack/index.ts +0 -3
  70. package/src/stack/types.ts +2 -6
  71. package/src/test/index.test.ts +22 -0
  72. package/build/box/box.js.map +0 -7
  73. package/build/box/types.js.map +0 -7
  74. package/build/index.js.map +0 -7
  75. package/build/lock-unlock.js.map +0 -7
  76. package/build/stack/index.js.map +0 -7
  77. package/build/stack/types.js.map +0 -7
  78. package/build/types/css-modules.d.js +0 -2
  79. package/build-module/lock-unlock.js +0 -11
  80. package/build-module/lock-unlock.js.map +0 -7
  81. package/build-types/lock-unlock.d.ts +0 -2
  82. package/build-types/lock-unlock.d.ts.map +0 -1
  83. package/src/lock-unlock.ts +0 -10
  84. package/tsconfig.json +0 -13
  85. package/tsconfig.tsbuildinfo +0 -1
  86. /package/build/box/{index.js.map → index.cjs.map} +0 -0
  87. /package/build/stack/{stack.js.map → stack.cjs.map} +0 -0
  88. /package/build/types/{react.d.js.map → react.d.cjs.map} +0 -0
  89. /package/build/utils/{element.js.map → element.cjs.map} +0 -0
  90. /package/build/utils/{types.js.map → types.cjs.map} +0 -0
  91. /package/{build/types/css-modules.d.js.map → build-module/badge/types.js.map} +0 -0
@@ -0,0 +1,22 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { Meta, StoryObj } from '@storybook/react';
5
+ import '@wordpress/theme/design-tokens.css';
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { Badge } from '../index';
10
+ declare const meta: Meta<typeof Badge>;
11
+ export default meta;
12
+ type Story = StoryObj<typeof Badge>;
13
+ export declare const Default: Story;
14
+ export declare const High: Story;
15
+ export declare const Medium: Story;
16
+ export declare const Low: Story;
17
+ export declare const Stable: Story;
18
+ export declare const Informational: Story;
19
+ export declare const Draft: Story;
20
+ export declare const None: Story;
21
+ export declare const AllIntents: Story;
22
+ //# sourceMappingURL=index.story.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/badge/stories/index.story.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAMvD,OAAO,oCAAoC,CAAC;AAE5C;;GAEG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,KAAK,CAI7B,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAE,OAAO,KAAK,CAAE,CAAC;AAEtC,eAAO,MAAM,OAAO,EAAE,KAIrB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAMlB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAMpB,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,KAMjB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAMpB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAM3B,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAMnB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAMlB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KA8CxB,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { type ComponentProps } from '../utils/types';
5
+ export interface BadgeProps extends ComponentProps<'span'> {
6
+ /**
7
+ * The text to display in the badge.
8
+ */
9
+ children: string;
10
+ /**
11
+ * The semantic intent of the badge, communicating its meaning through color.
12
+ *
13
+ * @default "none"
14
+ */
15
+ intent?: 'high' | 'medium' | 'low' | 'stable' | 'informational' | 'draft' | 'none';
16
+ }
17
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/badge/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAE,MAAM,CAAE;IAC3D;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,MAAM,CAAC,EACJ,MAAM,GACN,QAAQ,GACR,KAAK,GACL,QAAQ,GACR,eAAe,GACf,OAAO,GACP,MAAM,CAAC;CACV"}
@@ -1 +1 @@
1
- {"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../src/box/box.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAoExC;;;GAGG;AACH,eAAO,MAAM,GAAG,qGAiDb,CAAC"}
1
+ {"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../src/box/box.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAkExC;;;GAGG;AACH,eAAO,MAAM,GAAG,qGAiDb,CAAC"}
@@ -1,14 +1,5 @@
1
- /**
2
- * External dependencies
3
- */
4
1
  import { type Meta, type StoryObj } from '@storybook/react';
5
- /**
6
- * WordPress dependencies
7
- */
8
2
  import '@wordpress/theme/design-tokens.css';
9
- /**
10
- * Internal dependencies
11
- */
12
3
  import { Box } from '../box';
13
4
  declare const meta: Meta<typeof Box>;
14
5
  export default meta;
@@ -1 +1 @@
1
- {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/box/stories/index.story.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5D;;GAEG;AACH,OAAO,oCAAoC,CAAC;AAE5C;;GAEG;AACH,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,GAAG,CAI3B,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
+ {"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,kBAAkB,CAAC;AAE5D,OAAO,oCAAoC,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,GAAG,CAI3B,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,12 +1,5 @@
1
- /**
2
- * Internal dependencies
3
- */
1
+ import { type PaddingSize, type BorderRadiusSize, type BorderWidthSize, type Target, type SurfaceBackgroundColor, type ContentForegroundColor, type SurfaceStrokeColor } from '@wordpress/theme';
4
2
  import { type ComponentProps } from '../utils/types';
5
- type SizeToken = '2xs' | 'xs' | 'sm' | 'md' | 'lg';
6
- type Size = number | SizeToken;
7
- type BackgroundColor = 'neutral' | 'neutral-strong' | 'neutral-weak' | 'brand' | 'success' | 'success-weak' | 'info' | 'info-weak' | 'warning' | 'warning-weak' | 'caution' | 'caution-weak' | 'error' | 'error-weak';
8
- type ForegroundColor = 'neutral' | 'neutral-weak' | 'success' | 'success-weak' | 'info' | 'info-weak' | 'warning' | 'warning-weak' | 'caution' | 'caution-weak' | 'error' | 'error-weak';
9
- type StrokeColor = 'brand' | 'brand-strong' | 'error' | 'error-strong' | 'info' | 'info-strong' | 'neutral' | 'neutral-strong' | 'neutral-weak' | 'success' | 'success-strong' | 'warning' | 'warning-strong';
10
3
  type DimensionVariant<T> = {
11
4
  block?: T;
12
5
  blockStart?: T;
@@ -19,31 +12,31 @@ export interface BoxProps extends ComponentProps<'div'> {
19
12
  /**
20
13
  * The target rendering element design token grouping to use for the box.
21
14
  */
22
- target?: string;
15
+ target?: Target;
23
16
  /**
24
17
  * The surface background design token for box background color.
25
18
  */
26
- backgroundColor?: BackgroundColor;
19
+ backgroundColor?: SurfaceBackgroundColor;
27
20
  /**
28
21
  * The surface foreground design token for box text color.
29
22
  */
30
- color?: ForegroundColor;
23
+ color?: ContentForegroundColor;
31
24
  /**
32
25
  * The surface spacing design token or base unit multiplier for box padding.
33
26
  */
34
- padding?: Size | DimensionVariant<Size>;
27
+ padding?: PaddingSize | DimensionVariant<PaddingSize>;
35
28
  /**
36
29
  * The surface border radius design token.
37
30
  */
38
- borderRadius?: Exclude<SizeToken, '2xs'>;
31
+ borderRadius?: BorderRadiusSize;
39
32
  /**
40
33
  * The surface border width design token.
41
34
  */
42
- borderWidth?: Exclude<SizeToken, '2xs'>;
35
+ borderWidth?: BorderWidthSize;
43
36
  /**
44
37
  * The surface border stroke color design token.
45
38
  */
46
- borderColor?: StrokeColor;
39
+ borderColor?: SurfaceStrokeColor;
47
40
  /**
48
41
  * The content to be rendered inside the component.
49
42
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/box/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,KAAK,SAAS,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnD,KAAK,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC;AAE/B,KAAK,eAAe,GACjB,SAAS,GACT,gBAAgB,GAChB,cAAc,GACd,OAAO,GACP,SAAS,GACT,cAAc,GACd,MAAM,GACN,WAAW,GACX,SAAS,GACT,cAAc,GACd,SAAS,GACT,cAAc,GACd,OAAO,GACP,YAAY,CAAC;AAEhB,KAAK,eAAe,GACjB,SAAS,GACT,cAAc,GACd,SAAS,GACT,cAAc,GACd,MAAM,GACN,WAAW,GACX,SAAS,GACT,cAAc,GACd,SAAS,GACT,cAAc,GACd,OAAO,GACP,YAAY,CAAC;AAEhB,KAAK,WAAW,GACb,OAAO,GACP,cAAc,GACd,OAAO,GACP,cAAc,GACd,MAAM,GACN,aAAa,GACb,SAAS,GACT,gBAAgB,GAChB,cAAc,GACd,SAAS,GACT,gBAAgB,GAChB,SAAS,GACT,gBAAgB,CAAC;AAEpB,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,eAAe,CAAC;IAElC;;OAEG;IACH,KAAK,CAAC,EAAE,eAAe,CAAC;IAExB;;OAEG;IACH,OAAO,CAAC,EAAE,IAAI,GAAG,gBAAgB,CAAE,IAAI,CAAE,CAAC;IAE1C;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAE,SAAS,EAAE,KAAK,CAAE,CAAC;IAE3C;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAE,SAAS,EAAE,KAAK,CAAE,CAAC;IAE1C;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B"}
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"}
@@ -1,2 +1,4 @@
1
1
  export * from './box';
2
+ export * from './badge';
3
+ export * from './stack';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -1,5 +1,2 @@
1
- /**
2
- * Internal dependencies
3
- */
4
1
  export { Stack } from './stack';
5
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stack/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stack/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
@@ -1,8 +1,5 @@
1
- /**
2
- * Internal dependencies
3
- */
1
+ import { type GapSize } from '@wordpress/theme';
4
2
  import { type ComponentProps } from '../utils/types';
5
- export type SizeToken = '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
6
3
  export interface StackProps extends ComponentProps<'div'> {
7
4
  /**
8
5
  * The direction of the stack.
@@ -13,7 +10,7 @@ export interface StackProps extends ComponentProps<'div'> {
13
10
  *
14
11
  * @default undefined
15
12
  */
16
- gap?: SizeToken;
13
+ gap?: GapSize;
17
14
  /**
18
15
  * The alignment of the stack items along the cross axis.
19
16
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/stack/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEjE,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAE,KAAK,CAAE;IAC1D;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAClB,KAAK,CAAC,aAAa,CAAE,eAAe,CAAE,EACtC,aAAa,GAAG,gBAAgB,CAChC,CAAC;IAEF;;;;OAIG;IACH,GAAG,CAAC,EAAE,SAAS,CAAC;IAEhB;;;;OAIG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAE,YAAY,CAAE,CAAC;IAE5C;;;;OAIG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,aAAa,CAAE,gBAAgB,CAAE,CAAC;IAElD;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAE,KAAK,CAAC,aAAa,CAAE,UAAU,CAAE,EAAE,cAAc,CAAE,CAAC;IAEpE;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/stack/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAE,KAAK,CAAE;IAC1D;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAClB,KAAK,CAAC,aAAa,CAAE,eAAe,CAAE,EACtC,aAAa,GAAG,gBAAgB,CAChC,CAAC;IAEF;;;;OAIG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IAEd;;;;OAIG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAE,YAAY,CAAE,CAAC;IAE5C;;;;OAIG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,aAAa,CAAE,gBAAgB,CAAE,CAAC;IAElD;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAE,KAAK,CAAC,aAAa,CAAE,UAAU,CAAE,EAAE,cAAc,CAAE,CAAC;IAEpE;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/test/index.test.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/ui",
3
- "version": "0.4.0",
3
+ "version": "1.0.1-next.8fd3f8831.0",
4
4
  "description": "Themeable React UI components for the WordPress Design System.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -22,13 +22,21 @@
22
22
  "node": ">=20.10.0",
23
23
  "npm": ">=10.2.3"
24
24
  },
25
- "main": "build/index.js",
25
+ "files": [
26
+ "src",
27
+ "build",
28
+ "build-module",
29
+ "build-types",
30
+ "*.md"
31
+ ],
32
+ "type": "module",
33
+ "main": "build/index.cjs",
26
34
  "module": "build-module/index.js",
27
35
  "exports": {
28
36
  ".": {
29
37
  "types": "./build-types/index.d.ts",
30
38
  "import": "./build-module/index.js",
31
- "default": "./build/index.js"
39
+ "default": "./build/index.cjs"
32
40
  },
33
41
  "./package.json": "./package.json"
34
42
  },
@@ -36,12 +44,11 @@
36
44
  "types": "build-types",
37
45
  "sideEffects": false,
38
46
  "dependencies": {
39
- "@wordpress/element": "^6.37.0",
40
- "@wordpress/private-apis": "^1.37.0",
47
+ "@wordpress/element": "^6.36.1-next.8fd3f8831.0",
41
48
  "clsx": "^2.1.1"
42
49
  },
43
50
  "devDependencies": {
44
- "@wordpress/theme": "^0.4.0"
51
+ "@wordpress/theme": "^0.4.1-next.8fd3f8831.0"
45
52
  },
46
53
  "peerDependencies": {
47
54
  "react": "^18.0.0",
@@ -50,5 +57,5 @@
50
57
  "publishConfig": {
51
58
  "access": "public"
52
59
  },
53
- "gitHead": "2cf13ec6cf86153c9b3cf369bf5c59046f5cd950"
60
+ "gitHead": "e582b351bc4c4b8734bb087f63a3beec9875c3c7"
54
61
  }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { forwardRef } from '@wordpress/element';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { Box } from '../box';
10
+ import { type BoxProps } from '../box/types';
11
+ import { type BadgeProps } from './types';
12
+
13
+ /**
14
+ * Default render function that renders a span element with the given props.
15
+ *
16
+ * @param props The props to apply to the HTML element.
17
+ */
18
+ const DEFAULT_RENDER = ( props: React.ComponentPropsWithoutRef< 'span' > ) => (
19
+ <span { ...props } />
20
+ );
21
+
22
+ /**
23
+ * Maps intent values to Box backgroundColor and color props.
24
+ * Uses strong emphasis styles (as emphasis prop has been removed).
25
+ * @param intent
26
+ */
27
+ const getIntentStyles = (
28
+ intent: BadgeProps[ 'intent' ]
29
+ ): Partial< BoxProps > => {
30
+ switch ( intent ) {
31
+ case 'high':
32
+ return {
33
+ backgroundColor: 'error',
34
+ color: 'error',
35
+ };
36
+ case 'medium':
37
+ return {
38
+ backgroundColor: 'warning',
39
+ color: 'warning',
40
+ };
41
+ case 'low':
42
+ return {
43
+ backgroundColor: 'caution',
44
+ color: 'caution',
45
+ };
46
+ case 'stable':
47
+ return {
48
+ backgroundColor: 'success',
49
+ color: 'success',
50
+ };
51
+ case 'informational':
52
+ return {
53
+ backgroundColor: 'info',
54
+ color: 'info',
55
+ };
56
+ case 'draft':
57
+ return {
58
+ backgroundColor: 'neutral-weak',
59
+ color: 'neutral',
60
+ };
61
+ case 'none':
62
+ default:
63
+ return {
64
+ backgroundColor: 'neutral',
65
+ color: 'neutral-weak',
66
+ };
67
+ }
68
+ };
69
+
70
+ /**
71
+ * A badge component for displaying labels with semantic intent.
72
+ * Built on the Box primitive for consistent theming and accessibility.
73
+ */
74
+ export const Badge = forwardRef< HTMLDivElement, BadgeProps >( function Badge(
75
+ { children, intent = 'none', render = DEFAULT_RENDER, ...props },
76
+ ref
77
+ ) {
78
+ const intentStyles = getIntentStyles( intent );
79
+
80
+ return (
81
+ <Box
82
+ { ...intentStyles }
83
+ padding={ { inline: 'xs', block: '2xs' } }
84
+ borderRadius="lg"
85
+ render={ render }
86
+ style={ {
87
+ fontFamily: 'var(--wpds-font-family-body)',
88
+ fontSize: 'var(--wpds-font-size-small)',
89
+ fontWeight: '400',
90
+ lineHeight: 'var(--wpds-font-line-height-x-small)',
91
+ ...props.style,
92
+ } }
93
+ ref={ ref }
94
+ >
95
+ { children }
96
+ </Box>
97
+ );
98
+ } );
@@ -0,0 +1 @@
1
+ export { Badge } from './badge';
@@ -0,0 +1,112 @@
1
+ import { Meta } from '@storybook/blocks';
2
+ import { Badge } from '../index';
3
+
4
+ <Meta title="Design System/Components/Badge/Choosing intent" />
5
+
6
+ # Choosing intent
7
+
8
+ <div style={ { padding: '2rem', display: 'flex', justifyContent: 'center', gap: '0.5rem', flexWrap: 'wrap', border: '1px solid #e0e0e0', borderRadius: '0.5rem' } }>
9
+ <Badge intent="high">high</Badge>
10
+ <Badge intent="medium">medium</Badge>
11
+ <Badge intent="low">low</Badge>
12
+ <Badge intent="stable">stable</Badge>
13
+ <Badge intent="informational">informational</Badge>
14
+ <Badge intent="draft">draft</Badge>
15
+ <Badge intent="none">none</Badge>
16
+ </div>
17
+
18
+ It can be difficult to determine which badge intent to use because the component's properties are not tied to any specific product view. Those properties should be balanced against the requirements of the view in which the badge appears, all while keeping an eye on high-level consistency (global statuses that appear across multiple views).
19
+
20
+ Here is a decision tree to help identify which badge to use.
21
+
22
+ ## 1. Ask first: should this draw the eye?
23
+
24
+ If the user scans this screen, should their attention be drawn to this badge?
25
+
26
+ - If **no** → use `none` (or even just plain text; no badge), even if the state is positive or "stable".
27
+ - If **yes** → pick an intent based on how important the action or awareness is.
28
+
29
+ ## 2. High / Medium / Low = action priority
30
+
31
+ Use when there's something for the user to act on.
32
+
33
+ ### `high` – Critical / top priority
34
+
35
+ * Needs attention as soon as possible
36
+ * _E.g. "Payment declined", "Security issue"_
37
+
38
+ <Badge intent="high">Payment declined</Badge> <Badge intent="high">Security issue</Badge>
39
+
40
+ ### `medium` – Important / blocks progress
41
+
42
+ * Blocks a key task, should be handled soon
43
+ * _E.g. "Approval required", "Review needed"_
44
+
45
+ <Badge intent="medium">Approval required</Badge> <Badge intent="medium">Review needed</Badge>
46
+
47
+ ### `low` – Worth noticing / non‑urgent
48
+
49
+ * Good to be aware of; action may be optional or later
50
+ * _E.g. "Pending", "Queued", "Minor issues", "Optional setup"_
51
+
52
+ <Badge intent="low">Pending</Badge> <Badge intent="low">Queued</Badge>
53
+
54
+ ## 3. Informational / draft = special non-final states
55
+
56
+ ### `informational` – Notable, no action / fix needed
57
+
58
+ * Context only; no clear action
59
+ * _E.g. "Scheduled", "Beta", "Internal only"_
60
+
61
+ <Badge intent="informational">Scheduled</Badge> <Badge intent="informational">Beta</Badge>
62
+
63
+ ### `draft` – Not final / work in progress
64
+
65
+ * _E.g. "Draft", "Unpublished", "Work in progress"_
66
+
67
+ <Badge intent="draft">Draft</Badge> <Badge intent="draft">Unpublished</Badge>
68
+
69
+ ## 4. Stable / none = normal states
70
+
71
+ ### `stable` – Positive / "healthy" state
72
+
73
+ * Use when confirming success or "all good" is important in that view
74
+ * _E.g. "Healthy", "Active", "Live"_
75
+
76
+ <Badge intent="stable">Healthy</Badge> <Badge intent="stable">Active</Badge>
77
+
78
+ ### `none` – Default for normal / background states
79
+
80
+ * Especially in dense lists where too much color creates visual noise
81
+ * _E.g. "Inactive", "Expired"_
82
+
83
+ <Badge intent="none">Inactive</Badge> <Badge intent="none">Expired</Badge>
84
+
85
+ ## Examples
86
+
87
+ ### Comment status:
88
+
89
+ - "Approved" → `none`: <Badge intent="none">Approved</Badge>
90
+ - "Approval required" → `medium`: <Badge intent="medium">Approval required</Badge>
91
+
92
+ ### Page status:
93
+
94
+ - "Published" → `none`: <Badge intent="none">Published</Badge>
95
+ - "Pending" → `low`: <Badge intent="low">Pending</Badge>
96
+ - "Draft" → `draft`: <Badge intent="draft">Draft</Badge>
97
+ - "Scheduled" → `informational`: <Badge intent="informational">Scheduled</Badge>
98
+ - "Private" → `informational`: <Badge intent="informational">Private</Badge>
99
+
100
+ ### Plugin status:
101
+
102
+ - "Active" → `stable`: <Badge intent="stable">Active</Badge>
103
+ - "Inactive" → `none`: <Badge intent="none">Inactive</Badge>
104
+
105
+ ## 5. When in doubt…
106
+
107
+ Use the least attention‑grabbing intent that still:
108
+
109
+ - Makes it clear what needs attention,
110
+ - Marks what isn't final, or
111
+ - Confirms a key success state in that context.
112
+
@@ -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,