@upstart.gg/sdk
Version:
You can test the CLI without recompiling by running:
41 lines (39 loc) • 872 B
JavaScript
import { Type } from "@sinclair/typebox";
//#region src/shared/bricks/props/css-length.ts
const cssUnits = [
"px",
"%",
"em",
"rem",
"vh",
"vw",
"dvh",
"dvw",
"rlh",
"lh",
"cqh",
"cqw"
];
function cssLength(options = {}) {
return Type.String({
title: "Length",
description: `A CSS length value. Must be a number with a unit (e.g. "10px", "50%"). The unit can be one of the following: ${cssUnits?.join(", ")}.`,
default: options.default,
"ui:field": "css-length",
"ui:css-units": cssUnits,
examples: [
"100px",
"50%",
"2em",
"1.5rem"
],
...options
});
}
function isCssLength(value) {
if (typeof value !== "string") return false;
return (/* @__PURE__ */ new RegExp(`^-?\\d+(?:\\.\\d+)?\\s*(${cssUnits.join("|")})$`)).test(value);
}
//#endregion
export { cssLength, cssUnits, isCssLength };
//# sourceMappingURL=css-length.js.map