@wordpress/ui 0.3.0 → 0.3.1-next.6deb34194.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/CONTRIBUTING.md +25 -0
- package/README.md +1 -1
- package/build/box/box.js +87 -0
- package/build/box/box.js.map +7 -0
- package/build/box/index.js +31 -0
- package/build/box/index.js.map +7 -0
- package/build/box/types.js +19 -0
- package/build/box/types.js.map +7 -0
- package/build/index.js +25 -0
- package/build/index.js.map +7 -0
- package/build/lock-unlock.js +37 -0
- package/build/lock-unlock.js.map +7 -0
- package/build/stack/index.js +31 -0
- package/build/stack/index.js.map +7 -0
- package/build/stack/stack.js +94 -0
- package/build/stack/stack.js.map +7 -0
- package/build/stack/types.js +19 -0
- package/build/stack/types.js.map +7 -0
- package/build/types/css-modules.d.js +2 -0
- package/build/types/css-modules.d.js.map +7 -0
- package/build/types/react.d.js +5 -0
- package/build/types/react.d.js.map +7 -0
- package/build/utils/element.js +45 -0
- package/build/utils/element.js.map +7 -0
- package/build/utils/types.js +19 -0
- package/build/utils/types.js.map +7 -0
- package/build-module/box/box.js +62 -0
- package/build-module/box/box.js.map +7 -0
- package/build-module/box/index.js +6 -0
- package/build-module/box/index.js.map +7 -0
- package/build-module/box/types.js +1 -0
- package/build-module/box/types.js.map +7 -0
- package/build-module/index.js +3 -0
- package/build-module/index.js.map +7 -0
- package/build-module/lock-unlock.js +11 -0
- package/build-module/lock-unlock.js.map +7 -0
- package/build-module/stack/index.js +6 -0
- package/build-module/stack/index.js.map +7 -0
- package/build-module/stack/stack.js +58 -0
- package/build-module/stack/stack.js.map +7 -0
- package/build-module/stack/types.js +1 -0
- package/build-module/stack/types.js.map +7 -0
- package/build-module/types/css-modules.d.js +1 -0
- package/build-module/types/css-modules.d.js.map +7 -0
- package/build-module/types/react.d.js +3 -0
- package/build-module/types/react.d.js.map +7 -0
- package/build-module/utils/element.js +20 -0
- package/build-module/utils/element.js.map +7 -0
- package/build-module/utils/types.js +1 -0
- package/build-module/utils/types.js.map +7 -0
- package/build-types/box/box.d.ts.map +1 -1
- package/build-types/box/stories/index.story.d.ts.map +1 -1
- package/build-types/box/test/box.test.d.ts +2 -0
- package/build-types/box/test/box.test.d.ts.map +1 -0
- package/build-types/box/types.d.ts +13 -0
- package/build-types/box/types.d.ts.map +1 -1
- package/build-types/stack/index.d.ts +5 -0
- package/build-types/stack/index.d.ts.map +1 -0
- package/build-types/stack/stack.d.ts +16 -0
- package/build-types/stack/stack.d.ts.map +1 -0
- package/build-types/stack/stories/index.story.d.ts +18 -0
- package/build-types/stack/stories/index.story.d.ts.map +1 -0
- package/build-types/stack/test/stack.test.d.ts +2 -0
- package/build-types/stack/test/stack.test.d.ts.map +1 -0
- package/build-types/stack/types.d.ts +39 -0
- package/build-types/stack/types.d.ts.map +1 -0
- package/build-types/utils/element.d.ts +12 -4
- package/build-types/utils/element.d.ts.map +1 -1
- package/package.json +9 -5
- package/src/box/box.tsx +22 -2
- package/src/box/stories/index.story.tsx +4 -1
- package/src/box/test/box.test.tsx +40 -0
- package/src/box/types.ts +30 -0
- package/src/stack/index.ts +4 -0
- package/src/stack/stack.tsx +76 -0
- package/src/stack/stories/index.story.tsx +132 -0
- package/src/stack/style.module.css +7 -0
- package/src/stack/test/stack.test.tsx +44 -0
- package/src/stack/types.ts +48 -0
- package/src/types/css-modules.d.ts +4 -0
- package/src/types/react.d.ts +7 -0
- package/src/utils/element.ts +25 -12
- package/tsconfig.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/CONTRIBUTING.md
CHANGED
|
@@ -25,3 +25,28 @@ src/
|
|
|
25
25
|
|
|
26
26
|
- The folder name should match the primary component name
|
|
27
27
|
- The `index.ts` file should contain only the public API exports for the component(s)
|
|
28
|
+
|
|
29
|
+
## CSS Architecture
|
|
30
|
+
|
|
31
|
+
### CSS Layers
|
|
32
|
+
|
|
33
|
+
We use [CSS cascade layers](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Cascade_layers) to ensure an expected order of precedence in style resolution. All component stylesheets must follow this layering approach to maintain consistency and prevent specificity conflicts.
|
|
34
|
+
|
|
35
|
+
Every component stylesheet must include the layer definition at the top and wrap all styles within the appropriate layer:
|
|
36
|
+
|
|
37
|
+
```css
|
|
38
|
+
@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;
|
|
39
|
+
|
|
40
|
+
@layer wp-ui-components {
|
|
41
|
+
.stack {
|
|
42
|
+
display: flex;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
#### CSS Layer Hierarchy
|
|
48
|
+
|
|
49
|
+
- **`wp-ui-utilities`** - Shared utility styles (box-sizing, focus rings, resets) that apply before component styles
|
|
50
|
+
- **`wp-ui-components`** - Default styles for design system components (`.stack`, etc.)
|
|
51
|
+
- **`wp-ui-compositions`** - Internal compositions that extend base components
|
|
52
|
+
- **`wp-ui-overrides`** - Last-resort styles to override default rules
|
package/README.md
CHANGED
package/build/box/box.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
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_element = require("@wordpress/element");
|
|
27
|
+
var import_element2 = require("../utils/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) => typeof value === "number" ? `calc(var(--wpds-dimension-base) * ${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 = { ...props.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-surface-${borderRadius}))`;
|
|
69
|
+
}
|
|
70
|
+
if (borderWidth) {
|
|
71
|
+
style.borderWidth = `var(--wpds-border-width-${target}-${borderWidth}, var(--wpds-border-width-surface-${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
|
+
return (0, import_element2.renderElement)({
|
|
78
|
+
render,
|
|
79
|
+
ref,
|
|
80
|
+
props: { ...props, style }
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
Box
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=box.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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/index.ts
|
|
21
|
+
var box_exports = {};
|
|
22
|
+
__export(box_exports, {
|
|
23
|
+
Box: () => import_box.Box
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(box_exports);
|
|
26
|
+
var import_box = require("./box");
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
Box
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// packages/ui/src/box/types.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
|
19
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// packages/ui/src/index.ts
|
|
18
|
+
var index_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(index_exports);
|
|
20
|
+
__reExport(index_exports, require("./box"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("./box")
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
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/lock-unlock.ts
|
|
21
|
+
var lock_unlock_exports = {};
|
|
22
|
+
__export(lock_unlock_exports, {
|
|
23
|
+
lock: () => lock,
|
|
24
|
+
unlock: () => unlock
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(lock_unlock_exports);
|
|
27
|
+
var import_private_apis = require("@wordpress/private-apis");
|
|
28
|
+
var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
|
|
29
|
+
"I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
|
|
30
|
+
"@wordpress/dataviews"
|
|
31
|
+
);
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
lock,
|
|
35
|
+
unlock
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=lock-unlock.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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/stack/index.ts
|
|
21
|
+
var stack_exports = {};
|
|
22
|
+
__export(stack_exports, {
|
|
23
|
+
Stack: () => import_stack.Stack
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(stack_exports);
|
|
26
|
+
var import_stack = require("./stack");
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
Stack
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/ui/src/stack/stack.tsx
|
|
31
|
+
var stack_exports = {};
|
|
32
|
+
__export(stack_exports, {
|
|
33
|
+
Stack: () => Stack,
|
|
34
|
+
getNormalizedGap: () => getNormalizedGap
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(stack_exports);
|
|
37
|
+
var import_clsx = __toESM(require("clsx"));
|
|
38
|
+
var import_element = require("@wordpress/element");
|
|
39
|
+
var import_element2 = require("../utils/element");
|
|
40
|
+
|
|
41
|
+
// packages/ui/src/stack/style.module.css
|
|
42
|
+
var css = `@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;
|
|
43
|
+
|
|
44
|
+
@layer wp-ui-components {
|
|
45
|
+
.style-module__stack__Gc4EG {
|
|
46
|
+
display: flex;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
document.head.appendChild(document.createElement("style")).appendChild(document.createTextNode(css));
|
|
51
|
+
var style_default = {
|
|
52
|
+
"stack": "style-module__stack__Gc4EG"
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// packages/ui/src/stack/stack.tsx
|
|
56
|
+
var TOKEN_NAMES = /* @__PURE__ */ new Set([
|
|
57
|
+
"2xs",
|
|
58
|
+
"xs",
|
|
59
|
+
"sm",
|
|
60
|
+
"md",
|
|
61
|
+
"lg",
|
|
62
|
+
"xl"
|
|
63
|
+
]);
|
|
64
|
+
function getNormalizedGap(gap) {
|
|
65
|
+
if (typeof gap === "number") {
|
|
66
|
+
return `calc( ${gap} * var( --wpds-dimension-base ) )`;
|
|
67
|
+
}
|
|
68
|
+
if (TOKEN_NAMES.has(gap)) {
|
|
69
|
+
return `var(--wpds-dimension-gap-${gap})`;
|
|
70
|
+
}
|
|
71
|
+
return String(gap);
|
|
72
|
+
}
|
|
73
|
+
var Stack = (0, import_element.forwardRef)(function Stack2({ direction, gap = 0, align, justify, wrap, render, ...props }, ref) {
|
|
74
|
+
const className = (0, import_clsx.default)(props.className, style_default.stack);
|
|
75
|
+
const style = {
|
|
76
|
+
gap: getNormalizedGap(gap),
|
|
77
|
+
alignItems: align,
|
|
78
|
+
justifyContent: justify,
|
|
79
|
+
flexDirection: direction,
|
|
80
|
+
flexWrap: wrap,
|
|
81
|
+
...props.style
|
|
82
|
+
};
|
|
83
|
+
return (0, import_element2.renderElement)({
|
|
84
|
+
render,
|
|
85
|
+
ref,
|
|
86
|
+
props: { ...props, style, className }
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
90
|
+
0 && (module.exports = {
|
|
91
|
+
Stack,
|
|
92
|
+
getNormalizedGap
|
|
93
|
+
});
|
|
94
|
+
//# sourceMappingURL=stack.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// packages/ui/src/stack/types.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
|
19
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/types/react.d.ts"],
|
|
4
|
+
"sourcesContent": ["import 'react';\n\ndeclare module 'react' {\n\tinterface CSSProperties {\n\t\t[ key: `--${ string }` ]: string | number | undefined;\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;AAAA,mBAAO;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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/utils/element.ts
|
|
21
|
+
var element_exports = {};
|
|
22
|
+
__export(element_exports, {
|
|
23
|
+
renderElement: () => renderElement
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(element_exports);
|
|
26
|
+
var import_element = require("@wordpress/element");
|
|
27
|
+
var renderElement = ({
|
|
28
|
+
render,
|
|
29
|
+
defaultTagName = "div",
|
|
30
|
+
props,
|
|
31
|
+
ref
|
|
32
|
+
}) => {
|
|
33
|
+
const propsWithRef = ref ? { ...props, ref } : props;
|
|
34
|
+
if (render === void 0) {
|
|
35
|
+
return (0, import_element.createElement)(defaultTagName, propsWithRef);
|
|
36
|
+
} else if (typeof render === "function") {
|
|
37
|
+
return render(propsWithRef);
|
|
38
|
+
}
|
|
39
|
+
return (0, import_element.cloneElement)(render, propsWithRef);
|
|
40
|
+
};
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
renderElement
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=element.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/element.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { cloneElement, createElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { ComponentProps } from './types';\n\ntype RenderProp< E extends React.ElementType > = NonNullable<\n\tComponentProps< E >[ 'render' ]\n>;\n\n/**\n * Renders an element from a render prop (a component or an element), with\n * merged props and ref.\n *\n * @param options Render options.\n * @param options.render The render prop (component or element).\n * @param options.defaultTagName The default tag name to use if no render prop\n * is provided.\n * @param options.props Props to pass to or merge with the element.\n * @param options.ref Optional ref to attach to the element.\n * @return The rendered element.\n */\nexport const renderElement = < E extends React.ElementType >( {\n\trender,\n\tdefaultTagName = 'div',\n\tprops,\n\tref,\n}: {\n\trender?: RenderProp< E >;\n\tdefaultTagName?: keyof JSX.IntrinsicElements;\n\tprops: Omit< ComponentProps< E >, 'render' >;\n\tref?: React.Ref<\n\t\tE extends keyof HTMLElementTagNameMap\n\t\t\t? HTMLElementTagNameMap[ E ]\n\t\t\t: Element\n\t>;\n} ): React.ReactElement => {\n\tconst propsWithRef = ref ? { ...props, ref } : props;\n\n\tif ( render === undefined ) {\n\t\treturn createElement( defaultTagName, propsWithRef );\n\t} else if ( typeof render === 'function' ) {\n\t\treturn render( propsWithRef );\n\t}\n\n\treturn cloneElement( render, propsWithRef );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA4C;AAuBrC,IAAM,gBAAgB,CAAiC;AAAA,EAC7D;AAAA,EACA,iBAAiB;AAAA,EACjB;AAAA,EACA;AACD,MAS2B;AAC1B,QAAM,eAAe,MAAM,EAAE,GAAG,OAAO,IAAI,IAAI;AAE/C,MAAK,WAAW,QAAY;AAC3B,eAAO,8BAAe,gBAAgB,YAAa;AAAA,EACpD,WAAY,OAAO,WAAW,YAAa;AAC1C,WAAO,OAAQ,YAAa;AAAA,EAC7B;AAEA,aAAO,6BAAc,QAAQ,YAAa;AAC3C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// packages/ui/src/utils/types.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
|
19
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/types.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport {\n\ttype ElementType,\n\ttype ComponentPropsWithoutRef,\n\ttype HTMLAttributes,\n\ttype Ref,\n} from 'react';\n\ntype HTMLAttributesWithRef< T extends ElementType = any > =\n\tHTMLAttributes< T > & { ref?: Ref< T > | undefined };\n\ntype ComponentRenderFn< Props > = (\n\tprops: Props\n) => React.ReactElement< unknown >;\n\nexport type ComponentProps< E extends ElementType > = Omit<\n\tComponentPropsWithoutRef< E >,\n\t'className' | 'children' | 'render'\n> & {\n\t/**\n\t * CSS class name to apply to the component.\n\t */\n\tclassName?: string;\n\n\t/**\n\t * Replaces the component's default HTML element using a given React\n\t * element, or a function that returns a React element.\n\t */\n\trender?:\n\t\t| ComponentRenderFn< HTMLAttributesWithRef >\n\t\t| React.ReactElement< Record< string, unknown > >;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|