@copilotkit/shared 2.0.0-rc.37 → 2.0.0-rc.39
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/dist/generative-ui/clone-value.cjs +364 -0
- package/dist/generative-ui/clone-value.cjs.map +1 -0
- package/dist/generative-ui/clone-value.d.cts +51 -0
- package/dist/generative-ui/clone-value.d.cts.map +1 -0
- package/dist/generative-ui/clone-value.d.mts +51 -0
- package/dist/generative-ui/clone-value.d.mts.map +1 -0
- package/dist/generative-ui/clone-value.mjs +363 -0
- package/dist/generative-ui/clone-value.mjs.map +1 -0
- package/dist/generative-ui/index.cjs +39 -0
- package/dist/generative-ui/index.d.cts +8 -2
- package/dist/generative-ui/index.d.mts +8 -2
- package/dist/generative-ui/index.mjs +8 -2
- package/dist/generative-ui/is-record.d.cts +3 -1
- package/dist/generative-ui/is-record.d.cts.map +1 -1
- package/dist/generative-ui/is-record.d.mts +3 -1
- package/dist/generative-ui/is-record.d.mts.map +1 -1
- package/dist/generative-ui/schema-render.cjs +2 -1
- package/dist/generative-ui/schema-render.cjs.map +1 -1
- package/dist/generative-ui/schema-render.d.cts.map +1 -1
- package/dist/generative-ui/schema-render.d.mts.map +1 -1
- package/dist/generative-ui/schema-render.mjs +2 -1
- package/dist/generative-ui/schema-render.mjs.map +1 -1
- package/dist/generative-ui/standard/chart-config.cjs +347 -0
- package/dist/generative-ui/standard/chart-config.cjs.map +1 -0
- package/dist/generative-ui/standard/chart-config.d.cts +97 -0
- package/dist/generative-ui/standard/chart-config.d.cts.map +1 -0
- package/dist/generative-ui/standard/chart-config.d.mts +97 -0
- package/dist/generative-ui/standard/chart-config.d.mts.map +1 -0
- package/dist/generative-ui/standard/chart-config.mjs +342 -0
- package/dist/generative-ui/standard/chart-config.mjs.map +1 -0
- package/dist/generative-ui/standard/composites.d.cts +2 -2
- package/dist/generative-ui/standard/composites.d.mts +2 -2
- package/dist/generative-ui/standard/declarations.d.cts +68 -68
- package/dist/generative-ui/standard/declarations.d.mts +68 -68
- package/dist/generative-ui/standard/index.d.mts +5 -1
- package/dist/generative-ui/standard/inputs.d.cts +22 -22
- package/dist/generative-ui/standard/inputs.d.mts +22 -22
- package/dist/generative-ui/standard/layout.d.cts +90 -90
- package/dist/generative-ui/standard/layout.d.mts +90 -90
- package/dist/generative-ui/standard/map-helpers.cjs +104 -0
- package/dist/generative-ui/standard/map-helpers.cjs.map +1 -0
- package/dist/generative-ui/standard/map-helpers.d.cts +88 -0
- package/dist/generative-ui/standard/map-helpers.d.cts.map +1 -0
- package/dist/generative-ui/standard/map-helpers.d.mts +88 -0
- package/dist/generative-ui/standard/map-helpers.d.mts.map +1 -0
- package/dist/generative-ui/standard/map-helpers.mjs +95 -0
- package/dist/generative-ui/standard/map-helpers.mjs.map +1 -0
- package/dist/generative-ui/standard/media.d.cts +6 -6
- package/dist/generative-ui/standard/media.d.mts +6 -6
- package/dist/generative-ui/standard/style-helpers.cjs +151 -0
- package/dist/generative-ui/standard/style-helpers.cjs.map +1 -0
- package/dist/generative-ui/standard/style-helpers.d.cts +56 -0
- package/dist/generative-ui/standard/style-helpers.d.cts.map +1 -0
- package/dist/generative-ui/standard/style-helpers.d.mts +56 -0
- package/dist/generative-ui/standard/style-helpers.d.mts.map +1 -0
- package/dist/generative-ui/standard/style-helpers.mjs +142 -0
- package/dist/generative-ui/standard/style-helpers.mjs.map +1 -0
- package/dist/generative-ui/standard/text.d.cts +14 -14
- package/dist/generative-ui/standard/text.d.mts +14 -14
- package/dist/generative-ui/standard/url.cjs +54 -0
- package/dist/generative-ui/standard/url.cjs.map +1 -0
- package/dist/generative-ui/standard/url.d.cts +32 -0
- package/dist/generative-ui/standard/url.d.cts.map +1 -0
- package/dist/generative-ui/standard/url.d.mts +32 -0
- package/dist/generative-ui/standard/url.d.mts.map +1 -0
- package/dist/generative-ui/standard/url.mjs +50 -0
- package/dist/generative-ui/standard/url.mjs.map +1 -0
- package/dist/generative-ui/thrown.cjs +69 -0
- package/dist/generative-ui/thrown.cjs.map +1 -0
- package/dist/generative-ui/thrown.d.cts +21 -0
- package/dist/generative-ui/thrown.d.cts.map +1 -0
- package/dist/generative-ui/thrown.d.mts +21 -0
- package/dist/generative-ui/thrown.d.mts.map +1 -0
- package/dist/generative-ui/thrown.mjs +67 -0
- package/dist/generative-ui/thrown.mjs.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +368 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/package.json +1 -1
- package/src/__tests__/schema-render.test.ts +78 -0
- package/src/generative-ui/__tests__/clone-value-differential.test.ts +480 -0
- package/src/generative-ui/__tests__/clone-value.test.ts +226 -0
- package/src/generative-ui/clone-value.ts +511 -0
- package/src/generative-ui/index.ts +6 -2
- package/src/generative-ui/schema-render.ts +2 -1
- package/src/generative-ui/standard/__tests__/standard-helpers.test.ts +407 -0
- package/src/generative-ui/standard/chart-config.ts +434 -0
- package/src/generative-ui/standard/index.ts +36 -0
- package/src/generative-ui/standard/map-helpers.ts +155 -0
- package/src/generative-ui/standard/style-helpers.ts +170 -0
- package/src/generative-ui/standard/url.ts +51 -0
- package/src/generative-ui/thrown.ts +90 -0
- package/src/index.ts +5 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
const require_tokens = require('./tokens.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/generative-ui/standard/style-helpers.ts
|
|
4
|
+
/**
|
|
5
|
+
* Equal when the JSON is equal. Use it as the equality check of a computed
|
|
6
|
+
* value over agent data, so a new object with the same content does not
|
|
7
|
+
* trigger a redraw.
|
|
8
|
+
*/
|
|
9
|
+
const jsonEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
10
|
+
/** Hides an element on screen. Screen readers still read it. */
|
|
11
|
+
const VISUALLY_HIDDEN = {
|
|
12
|
+
position: "absolute",
|
|
13
|
+
width: "1px",
|
|
14
|
+
height: "1px",
|
|
15
|
+
padding: 0,
|
|
16
|
+
margin: "-1px",
|
|
17
|
+
overflow: "hidden",
|
|
18
|
+
clipPath: "inset(50%)",
|
|
19
|
+
whiteSpace: "nowrap",
|
|
20
|
+
border: 0
|
|
21
|
+
};
|
|
22
|
+
/** The outline of a focused control, for a `:focus-visible` rule. */
|
|
23
|
+
const FOCUS_RING = "2px solid var(--a2ui-color-focus, #0285ff)";
|
|
24
|
+
/**
|
|
25
|
+
* Cuts the text after `lines` lines, with an ellipsis.
|
|
26
|
+
*
|
|
27
|
+
* @param lines - The number of lines to show.
|
|
28
|
+
*/
|
|
29
|
+
function lineClamp(lines) {
|
|
30
|
+
return {
|
|
31
|
+
display: "-webkit-box",
|
|
32
|
+
WebkitLineClamp: lines,
|
|
33
|
+
WebkitBoxOrient: "vertical",
|
|
34
|
+
overflow: "hidden"
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** The `align-items` value of each `align` prop value. */
|
|
38
|
+
const ALIGN_CSS = {
|
|
39
|
+
start: "flex-start",
|
|
40
|
+
end: "flex-end",
|
|
41
|
+
center: "center",
|
|
42
|
+
baseline: "baseline",
|
|
43
|
+
stretch: "stretch"
|
|
44
|
+
};
|
|
45
|
+
/** The `justify-content` value of each `justify` prop value. */
|
|
46
|
+
const JUSTIFY_CSS = {
|
|
47
|
+
start: "flex-start",
|
|
48
|
+
end: "flex-end",
|
|
49
|
+
center: "center",
|
|
50
|
+
spaceBetween: "space-between",
|
|
51
|
+
spaceAround: "space-around",
|
|
52
|
+
spaceEvenly: "space-evenly",
|
|
53
|
+
stretch: "stretch"
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* A CSS length: pixels when `value` is a number, the raw CSS when it is a
|
|
57
|
+
* string, and `undefined` when it is not set.
|
|
58
|
+
*
|
|
59
|
+
* @example px(12) // "12px"
|
|
60
|
+
*/
|
|
61
|
+
function px(value) {
|
|
62
|
+
if (value === void 0) return void 0;
|
|
63
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The CSS of a `radius` prop: one radius for all corners, or one radius for
|
|
67
|
+
* each corner.
|
|
68
|
+
*
|
|
69
|
+
* @param value - A radius token, a raw CSS value, or an object of corners.
|
|
70
|
+
*/
|
|
71
|
+
function radiusStyle(value) {
|
|
72
|
+
if (typeof value === "string" || typeof value === "number") return { borderRadius: require_tokens.radius(value) };
|
|
73
|
+
if (value === void 0) return {};
|
|
74
|
+
return {
|
|
75
|
+
borderTopLeftRadius: require_tokens.radius(value.topLeft),
|
|
76
|
+
borderTopRightRadius: require_tokens.radius(value.topRight),
|
|
77
|
+
borderBottomLeftRadius: require_tokens.radius(value.bottomLeft),
|
|
78
|
+
borderBottomRightRadius: require_tokens.radius(value.bottomRight)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A copy of `style` without the undefined entries, so a later spread never
|
|
83
|
+
* erases a value. An undefined longhand next to a shorthand is a removal:
|
|
84
|
+
* clearing `row-gap` resets the `gap` shorthand in real browsers.
|
|
85
|
+
*/
|
|
86
|
+
function defined(style) {
|
|
87
|
+
const result = {};
|
|
88
|
+
for (const [key, value] of Object.entries(style)) if (value !== void 0) result[key] = value;
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The `gap` of the layout props, with `rowGap` and `columnGap` winning over
|
|
93
|
+
* it. A renderer can apply a style object in sorted key order (Angular does),
|
|
94
|
+
* so `columnGap` would come before the `gap` shorthand and lose to it. A
|
|
95
|
+
* longhand therefore sets both longhands and no shorthand.
|
|
96
|
+
*/
|
|
97
|
+
function gapStyle(props) {
|
|
98
|
+
const gap = require_tokens.spacing(props.gap) ?? (props.disableAutoSpacing ? 0 : void 0);
|
|
99
|
+
const rowGap = require_tokens.spacing(props.rowGap);
|
|
100
|
+
const columnGap = require_tokens.spacing(props.columnGap);
|
|
101
|
+
if (rowGap === void 0 && columnGap === void 0) return { gap };
|
|
102
|
+
return {
|
|
103
|
+
rowGap: rowGap ?? gap,
|
|
104
|
+
columnGap: columnGap ?? gap
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The flex container CSS of the shared layout props (`align`, `gap`,
|
|
109
|
+
* `padding`, `radius`, sizes and the rest). An unset prop gives no CSS.
|
|
110
|
+
*
|
|
111
|
+
* @param props - The layout props of a container component.
|
|
112
|
+
*/
|
|
113
|
+
function layoutStyle(props) {
|
|
114
|
+
const overflow = props.scrollable ? "auto" : props.clip ? "hidden" : void 0;
|
|
115
|
+
return defined({
|
|
116
|
+
display: props.inline ? "inline-flex" : "flex",
|
|
117
|
+
alignItems: props.align ? ALIGN_CSS[props.align] : void 0,
|
|
118
|
+
justifyContent: props.justify ? JUSTIFY_CSS[props.justify] : void 0,
|
|
119
|
+
flexWrap: props.wrap,
|
|
120
|
+
...gapStyle(props),
|
|
121
|
+
padding: props.flush ? 0 : require_tokens.spacing(props.padding),
|
|
122
|
+
background: require_tokens.backgroundColor(props.background),
|
|
123
|
+
border: props.border ? `1px solid ${require_tokens.borderColor(props.borderColor ?? "default")}` : void 0,
|
|
124
|
+
...radiusStyle(props.radius),
|
|
125
|
+
width: require_tokens.spacing(props.width),
|
|
126
|
+
height: require_tokens.spacing(props.height),
|
|
127
|
+
minWidth: require_tokens.spacing(props.minWidth ?? props.minSize) ?? 0,
|
|
128
|
+
maxWidth: require_tokens.spacing(props.maxWidth ?? props.maxSize) ?? "100%",
|
|
129
|
+
minHeight: require_tokens.spacing(props.minHeight ?? props.minSize),
|
|
130
|
+
maxHeight: require_tokens.spacing(props.maxHeight ?? props.maxSize),
|
|
131
|
+
flex: props.flex,
|
|
132
|
+
flexGrow: props.weight,
|
|
133
|
+
aspectRatio: props.aspectRatio,
|
|
134
|
+
overflow,
|
|
135
|
+
boxShadow: props.shadow ? require_tokens.SHADOW_SM : void 0,
|
|
136
|
+
boxSizing: "border-box"
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
exports.ALIGN_CSS = ALIGN_CSS;
|
|
142
|
+
exports.FOCUS_RING = FOCUS_RING;
|
|
143
|
+
exports.JUSTIFY_CSS = JUSTIFY_CSS;
|
|
144
|
+
exports.VISUALLY_HIDDEN = VISUALLY_HIDDEN;
|
|
145
|
+
exports.defined = defined;
|
|
146
|
+
exports.jsonEqual = jsonEqual;
|
|
147
|
+
exports.layoutStyle = layoutStyle;
|
|
148
|
+
exports.lineClamp = lineClamp;
|
|
149
|
+
exports.px = px;
|
|
150
|
+
exports.radiusStyle = radiusStyle;
|
|
151
|
+
//# sourceMappingURL=style-helpers.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-helpers.cjs","names":["radius","spacing","backgroundColor","borderColor","SHADOW_SM"],"sources":["../../../src/generative-ui/standard/style-helpers.ts"],"sourcesContent":["// Framework-free style helpers of the standard components. Each framework\n// binds the returned style objects to its own elements.\nimport {\n SHADOW_SM,\n backgroundColor,\n borderColor,\n radius,\n spacing,\n} from \"./tokens\";\nimport type { ALIGN, JUSTIFY } from \"./tokens\";\nimport type { LayoutProps } from \"./layout\";\n\n/** An inline style object, with camelCase CSS properties as keys. */\nexport type StyleMap = Record<string, string | number | undefined>;\n\n/**\n * Equal when the JSON is equal. Use it as the equality check of a computed\n * value over agent data, so a new object with the same content does not\n * trigger a redraw.\n */\nexport const jsonEqual = (a: unknown, b: unknown) =>\n JSON.stringify(a) === JSON.stringify(b);\n\n/** Hides an element on screen. Screen readers still read it. */\nexport const VISUALLY_HIDDEN: StyleMap = {\n position: \"absolute\",\n width: \"1px\",\n height: \"1px\",\n padding: 0,\n margin: \"-1px\",\n overflow: \"hidden\",\n clipPath: \"inset(50%)\",\n whiteSpace: \"nowrap\",\n border: 0,\n};\n\n/** The outline of a focused control, for a `:focus-visible` rule. */\nexport const FOCUS_RING = \"2px solid var(--a2ui-color-focus, #0285ff)\";\n\n/**\n * Cuts the text after `lines` lines, with an ellipsis.\n *\n * @param lines - The number of lines to show.\n */\nexport function lineClamp(lines: number): StyleMap {\n return {\n display: \"-webkit-box\",\n WebkitLineClamp: lines,\n WebkitBoxOrient: \"vertical\",\n overflow: \"hidden\",\n };\n}\n\n/** The `align-items` value of each `align` prop value. */\nexport const ALIGN_CSS: Record<(typeof ALIGN)[number], string> = {\n start: \"flex-start\",\n end: \"flex-end\",\n center: \"center\",\n baseline: \"baseline\",\n stretch: \"stretch\",\n};\n\n/** The `justify-content` value of each `justify` prop value. */\nexport const JUSTIFY_CSS: Record<(typeof JUSTIFY)[number], string> = {\n start: \"flex-start\",\n end: \"flex-end\",\n center: \"center\",\n spaceBetween: \"space-between\",\n spaceAround: \"space-around\",\n spaceEvenly: \"space-evenly\",\n stretch: \"stretch\",\n};\n\n/**\n * A CSS length: pixels when `value` is a number, the raw CSS when it is a\n * string, and `undefined` when it is not set.\n *\n * @example px(12) // \"12px\"\n */\nexport function px(value: number | string | undefined) {\n if (value === undefined) return undefined;\n return typeof value === \"number\" ? `${value}px` : value;\n}\n\n/**\n * The CSS of a `radius` prop: one radius for all corners, or one radius for\n * each corner.\n *\n * @param value - A radius token, a raw CSS value, or an object of corners.\n */\nexport function radiusStyle(value: LayoutProps[\"radius\"]): StyleMap {\n if (typeof value === \"string\" || typeof value === \"number\") {\n return { borderRadius: radius(value) };\n }\n if (value === undefined) return {};\n return {\n borderTopLeftRadius: radius(value.topLeft),\n borderTopRightRadius: radius(value.topRight),\n borderBottomLeftRadius: radius(value.bottomLeft),\n borderBottomRightRadius: radius(value.bottomRight),\n };\n}\n\n/**\n * A copy of `style` without the undefined entries, so a later spread never\n * erases a value. An undefined longhand next to a shorthand is a removal:\n * clearing `row-gap` resets the `gap` shorthand in real browsers.\n */\nexport function defined(style: StyleMap): StyleMap {\n const result: StyleMap = {};\n for (const [key, value] of Object.entries(style)) {\n if (value !== undefined) result[key] = value;\n }\n return result;\n}\n\n/**\n * The `gap` of the layout props, with `rowGap` and `columnGap` winning over\n * it. A renderer can apply a style object in sorted key order (Angular does),\n * so `columnGap` would come before the `gap` shorthand and lose to it. A\n * longhand therefore sets both longhands and no shorthand.\n */\nfunction gapStyle(props: LayoutProps): StyleMap {\n const gap = spacing(props.gap) ?? (props.disableAutoSpacing ? 0 : undefined);\n const rowGap = spacing(props.rowGap);\n const columnGap = spacing(props.columnGap);\n if (rowGap === undefined && columnGap === undefined) return { gap };\n return { rowGap: rowGap ?? gap, columnGap: columnGap ?? gap };\n}\n\n/**\n * The flex container CSS of the shared layout props (`align`, `gap`,\n * `padding`, `radius`, sizes and the rest). An unset prop gives no CSS.\n *\n * @param props - The layout props of a container component.\n */\nexport function layoutStyle(props: LayoutProps): StyleMap {\n const overflow = props.scrollable\n ? \"auto\"\n : props.clip\n ? \"hidden\"\n : undefined;\n return defined({\n display: props.inline ? \"inline-flex\" : \"flex\",\n alignItems: props.align ? ALIGN_CSS[props.align] : undefined,\n justifyContent: props.justify ? JUSTIFY_CSS[props.justify] : undefined,\n flexWrap: props.wrap,\n ...gapStyle(props),\n padding: props.flush ? 0 : spacing(props.padding),\n background: backgroundColor(props.background),\n border: props.border\n ? `1px solid ${borderColor(props.borderColor ?? \"default\")}`\n : undefined,\n ...radiusStyle(props.radius),\n width: spacing(props.width),\n height: spacing(props.height),\n // A container can shrink below its content and never gets wider than\n // its parent.\n minWidth: spacing(props.minWidth ?? props.minSize) ?? 0,\n maxWidth: spacing(props.maxWidth ?? props.maxSize) ?? \"100%\",\n minHeight: spacing(props.minHeight ?? props.minSize),\n maxHeight: spacing(props.maxHeight ?? props.maxSize),\n flex: props.flex,\n flexGrow: props.weight,\n aspectRatio: props.aspectRatio,\n overflow,\n boxShadow: props.shadow ? SHADOW_SM : undefined,\n boxSizing: \"border-box\",\n });\n}\n"],"mappings":";;;;;;;;AAoBA,MAAa,aAAa,GAAY,MACpC,KAAK,UAAU,EAAE,KAAK,KAAK,UAAU,EAAE;;AAGzC,MAAa,kBAA4B;CACvC,UAAU;CACV,OAAO;CACP,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,UAAU;CACV,UAAU;CACV,YAAY;CACZ,QAAQ;CACT;;AAGD,MAAa,aAAa;;;;;;AAO1B,SAAgB,UAAU,OAAyB;AACjD,QAAO;EACL,SAAS;EACT,iBAAiB;EACjB,iBAAiB;EACjB,UAAU;EACX;;;AAIH,MAAa,YAAoD;CAC/D,OAAO;CACP,KAAK;CACL,QAAQ;CACR,UAAU;CACV,SAAS;CACV;;AAGD,MAAa,cAAwD;CACnE,OAAO;CACP,KAAK;CACL,QAAQ;CACR,cAAc;CACd,aAAa;CACb,aAAa;CACb,SAAS;CACV;;;;;;;AAQD,SAAgB,GAAG,OAAoC;AACrD,KAAI,UAAU,OAAW,QAAO;AAChC,QAAO,OAAO,UAAU,WAAW,GAAG,MAAM,MAAM;;;;;;;;AASpD,SAAgB,YAAY,OAAwC;AAClE,KAAI,OAAO,UAAU,YAAY,OAAO,UAAU,SAChD,QAAO,EAAE,cAAcA,sBAAO,MAAM,EAAE;AAExC,KAAI,UAAU,OAAW,QAAO,EAAE;AAClC,QAAO;EACL,qBAAqBA,sBAAO,MAAM,QAAQ;EAC1C,sBAAsBA,sBAAO,MAAM,SAAS;EAC5C,wBAAwBA,sBAAO,MAAM,WAAW;EAChD,yBAAyBA,sBAAO,MAAM,YAAY;EACnD;;;;;;;AAQH,SAAgB,QAAQ,OAA2B;CACjD,MAAM,SAAmB,EAAE;AAC3B,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,CAC9C,KAAI,UAAU,OAAW,QAAO,OAAO;AAEzC,QAAO;;;;;;;;AAST,SAAS,SAAS,OAA8B;CAC9C,MAAM,MAAMC,uBAAQ,MAAM,IAAI,KAAK,MAAM,qBAAqB,IAAI;CAClE,MAAM,SAASA,uBAAQ,MAAM,OAAO;CACpC,MAAM,YAAYA,uBAAQ,MAAM,UAAU;AAC1C,KAAI,WAAW,UAAa,cAAc,OAAW,QAAO,EAAE,KAAK;AACnE,QAAO;EAAE,QAAQ,UAAU;EAAK,WAAW,aAAa;EAAK;;;;;;;;AAS/D,SAAgB,YAAY,OAA8B;CACxD,MAAM,WAAW,MAAM,aACnB,SACA,MAAM,OACJ,WACA;AACN,QAAO,QAAQ;EACb,SAAS,MAAM,SAAS,gBAAgB;EACxC,YAAY,MAAM,QAAQ,UAAU,MAAM,SAAS;EACnD,gBAAgB,MAAM,UAAU,YAAY,MAAM,WAAW;EAC7D,UAAU,MAAM;EAChB,GAAG,SAAS,MAAM;EAClB,SAAS,MAAM,QAAQ,IAAIA,uBAAQ,MAAM,QAAQ;EACjD,YAAYC,+BAAgB,MAAM,WAAW;EAC7C,QAAQ,MAAM,SACV,aAAaC,2BAAY,MAAM,eAAe,UAAU,KACxD;EACJ,GAAG,YAAY,MAAM,OAAO;EAC5B,OAAOF,uBAAQ,MAAM,MAAM;EAC3B,QAAQA,uBAAQ,MAAM,OAAO;EAG7B,UAAUA,uBAAQ,MAAM,YAAY,MAAM,QAAQ,IAAI;EACtD,UAAUA,uBAAQ,MAAM,YAAY,MAAM,QAAQ,IAAI;EACtD,WAAWA,uBAAQ,MAAM,aAAa,MAAM,QAAQ;EACpD,WAAWA,uBAAQ,MAAM,aAAa,MAAM,QAAQ;EACpD,MAAM,MAAM;EACZ,UAAU,MAAM;EAChB,aAAa,MAAM;EACnB;EACA,WAAW,MAAM,SAASG,2BAAY;EACtC,WAAW;EACZ,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ALIGN, JUSTIFY } from "./tokens.cjs";
|
|
2
|
+
import { LayoutProps } from "./layout.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/generative-ui/standard/style-helpers.d.ts
|
|
5
|
+
/** An inline style object, with camelCase CSS properties as keys. */
|
|
6
|
+
type StyleMap = Record<string, string | number | undefined>;
|
|
7
|
+
/**
|
|
8
|
+
* Equal when the JSON is equal. Use it as the equality check of a computed
|
|
9
|
+
* value over agent data, so a new object with the same content does not
|
|
10
|
+
* trigger a redraw.
|
|
11
|
+
*/
|
|
12
|
+
declare const jsonEqual: (a: unknown, b: unknown) => boolean;
|
|
13
|
+
/** Hides an element on screen. Screen readers still read it. */
|
|
14
|
+
declare const VISUALLY_HIDDEN: StyleMap;
|
|
15
|
+
/** The outline of a focused control, for a `:focus-visible` rule. */
|
|
16
|
+
declare const FOCUS_RING = "2px solid var(--a2ui-color-focus, #0285ff)";
|
|
17
|
+
/**
|
|
18
|
+
* Cuts the text after `lines` lines, with an ellipsis.
|
|
19
|
+
*
|
|
20
|
+
* @param lines - The number of lines to show.
|
|
21
|
+
*/
|
|
22
|
+
declare function lineClamp(lines: number): StyleMap;
|
|
23
|
+
/** The `align-items` value of each `align` prop value. */
|
|
24
|
+
declare const ALIGN_CSS: Record<(typeof ALIGN)[number], string>;
|
|
25
|
+
/** The `justify-content` value of each `justify` prop value. */
|
|
26
|
+
declare const JUSTIFY_CSS: Record<(typeof JUSTIFY)[number], string>;
|
|
27
|
+
/**
|
|
28
|
+
* A CSS length: pixels when `value` is a number, the raw CSS when it is a
|
|
29
|
+
* string, and `undefined` when it is not set.
|
|
30
|
+
*
|
|
31
|
+
* @example px(12) // "12px"
|
|
32
|
+
*/
|
|
33
|
+
declare function px(value: number | string | undefined): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* The CSS of a `radius` prop: one radius for all corners, or one radius for
|
|
36
|
+
* each corner.
|
|
37
|
+
*
|
|
38
|
+
* @param value - A radius token, a raw CSS value, or an object of corners.
|
|
39
|
+
*/
|
|
40
|
+
declare function radiusStyle(value: LayoutProps["radius"]): StyleMap;
|
|
41
|
+
/**
|
|
42
|
+
* A copy of `style` without the undefined entries, so a later spread never
|
|
43
|
+
* erases a value. An undefined longhand next to a shorthand is a removal:
|
|
44
|
+
* clearing `row-gap` resets the `gap` shorthand in real browsers.
|
|
45
|
+
*/
|
|
46
|
+
declare function defined(style: StyleMap): StyleMap;
|
|
47
|
+
/**
|
|
48
|
+
* The flex container CSS of the shared layout props (`align`, `gap`,
|
|
49
|
+
* `padding`, `radius`, sizes and the rest). An unset prop gives no CSS.
|
|
50
|
+
*
|
|
51
|
+
* @param props - The layout props of a container component.
|
|
52
|
+
*/
|
|
53
|
+
declare function layoutStyle(props: LayoutProps): StyleMap;
|
|
54
|
+
//#endregion
|
|
55
|
+
export { ALIGN_CSS, FOCUS_RING, JUSTIFY_CSS, StyleMap, VISUALLY_HIDDEN, defined, jsonEqual, layoutStyle, lineClamp, px, radiusStyle };
|
|
56
|
+
//# sourceMappingURL=style-helpers.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-helpers.d.cts","names":[],"sources":["../../../src/generative-ui/standard/style-helpers.ts"],"mappings":";;;;;KAaY,QAAA,GAAW,MAAA;AAAvB;;;;;AAAA,cAOa,SAAA,GAAa,CAAA,WAAY,CAAA;;cAIzB,eAAA,EAAiB,QAAA;;cAajB,UAAA;AAbb;;;;;AAAA,iBAoBgB,SAAA,CAAU,KAAA,WAAgB,QAAA;;cAU7B,SAAA,EAAW,MAAA,SAAe,KAAA;;cAS1B,WAAA,EAAa,MAAA,SAAe,OAAA;AAnBzC;;;;;AAUA;AAVA,iBAmCgB,EAAA,CAAG,KAAA;;;;AAhBnB;;;iBA2BgB,WAAA,CAAY,KAAA,EAAO,WAAA,aAAwB,QAAA;;AAX3D;;;;iBA6BgB,OAAA,CAAQ,KAAA,EAAO,QAAA,GAAW,QAAA;AAlB1C;;;;;;AAAA,iBA8CgB,WAAA,CAAY,KAAA,EAAO,WAAA,GAAc,QAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ALIGN, JUSTIFY } from "./tokens.mjs";
|
|
2
|
+
import { LayoutProps } from "./layout.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/generative-ui/standard/style-helpers.d.ts
|
|
5
|
+
/** An inline style object, with camelCase CSS properties as keys. */
|
|
6
|
+
type StyleMap = Record<string, string | number | undefined>;
|
|
7
|
+
/**
|
|
8
|
+
* Equal when the JSON is equal. Use it as the equality check of a computed
|
|
9
|
+
* value over agent data, so a new object with the same content does not
|
|
10
|
+
* trigger a redraw.
|
|
11
|
+
*/
|
|
12
|
+
declare const jsonEqual: (a: unknown, b: unknown) => boolean;
|
|
13
|
+
/** Hides an element on screen. Screen readers still read it. */
|
|
14
|
+
declare const VISUALLY_HIDDEN: StyleMap;
|
|
15
|
+
/** The outline of a focused control, for a `:focus-visible` rule. */
|
|
16
|
+
declare const FOCUS_RING = "2px solid var(--a2ui-color-focus, #0285ff)";
|
|
17
|
+
/**
|
|
18
|
+
* Cuts the text after `lines` lines, with an ellipsis.
|
|
19
|
+
*
|
|
20
|
+
* @param lines - The number of lines to show.
|
|
21
|
+
*/
|
|
22
|
+
declare function lineClamp(lines: number): StyleMap;
|
|
23
|
+
/** The `align-items` value of each `align` prop value. */
|
|
24
|
+
declare const ALIGN_CSS: Record<(typeof ALIGN)[number], string>;
|
|
25
|
+
/** The `justify-content` value of each `justify` prop value. */
|
|
26
|
+
declare const JUSTIFY_CSS: Record<(typeof JUSTIFY)[number], string>;
|
|
27
|
+
/**
|
|
28
|
+
* A CSS length: pixels when `value` is a number, the raw CSS when it is a
|
|
29
|
+
* string, and `undefined` when it is not set.
|
|
30
|
+
*
|
|
31
|
+
* @example px(12) // "12px"
|
|
32
|
+
*/
|
|
33
|
+
declare function px(value: number | string | undefined): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* The CSS of a `radius` prop: one radius for all corners, or one radius for
|
|
36
|
+
* each corner.
|
|
37
|
+
*
|
|
38
|
+
* @param value - A radius token, a raw CSS value, or an object of corners.
|
|
39
|
+
*/
|
|
40
|
+
declare function radiusStyle(value: LayoutProps["radius"]): StyleMap;
|
|
41
|
+
/**
|
|
42
|
+
* A copy of `style` without the undefined entries, so a later spread never
|
|
43
|
+
* erases a value. An undefined longhand next to a shorthand is a removal:
|
|
44
|
+
* clearing `row-gap` resets the `gap` shorthand in real browsers.
|
|
45
|
+
*/
|
|
46
|
+
declare function defined(style: StyleMap): StyleMap;
|
|
47
|
+
/**
|
|
48
|
+
* The flex container CSS of the shared layout props (`align`, `gap`,
|
|
49
|
+
* `padding`, `radius`, sizes and the rest). An unset prop gives no CSS.
|
|
50
|
+
*
|
|
51
|
+
* @param props - The layout props of a container component.
|
|
52
|
+
*/
|
|
53
|
+
declare function layoutStyle(props: LayoutProps): StyleMap;
|
|
54
|
+
//#endregion
|
|
55
|
+
export { ALIGN_CSS, FOCUS_RING, JUSTIFY_CSS, StyleMap, VISUALLY_HIDDEN, defined, jsonEqual, layoutStyle, lineClamp, px, radiusStyle };
|
|
56
|
+
//# sourceMappingURL=style-helpers.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-helpers.d.mts","names":[],"sources":["../../../src/generative-ui/standard/style-helpers.ts"],"mappings":";;;;;KAaY,QAAA,GAAW,MAAA;AAAvB;;;;;AAAA,cAOa,SAAA,GAAa,CAAA,WAAY,CAAA;;cAIzB,eAAA,EAAiB,QAAA;;cAajB,UAAA;AAbb;;;;;AAAA,iBAoBgB,SAAA,CAAU,KAAA,WAAgB,QAAA;;cAU7B,SAAA,EAAW,MAAA,SAAe,KAAA;;cAS1B,WAAA,EAAa,MAAA,SAAe,OAAA;AAnBzC;;;;;AAUA;AAVA,iBAmCgB,EAAA,CAAG,KAAA;;;;AAhBnB;;;iBA2BgB,WAAA,CAAY,KAAA,EAAO,WAAA,aAAwB,QAAA;;AAX3D;;;;iBA6BgB,OAAA,CAAQ,KAAA,EAAO,QAAA,GAAW,QAAA;AAlB1C;;;;;;AAAA,iBA8CgB,WAAA,CAAY,KAAA,EAAO,WAAA,GAAc,QAAA"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { SHADOW_SM, backgroundColor, borderColor, radius, spacing } from "./tokens.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/generative-ui/standard/style-helpers.ts
|
|
4
|
+
/**
|
|
5
|
+
* Equal when the JSON is equal. Use it as the equality check of a computed
|
|
6
|
+
* value over agent data, so a new object with the same content does not
|
|
7
|
+
* trigger a redraw.
|
|
8
|
+
*/
|
|
9
|
+
const jsonEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
10
|
+
/** Hides an element on screen. Screen readers still read it. */
|
|
11
|
+
const VISUALLY_HIDDEN = {
|
|
12
|
+
position: "absolute",
|
|
13
|
+
width: "1px",
|
|
14
|
+
height: "1px",
|
|
15
|
+
padding: 0,
|
|
16
|
+
margin: "-1px",
|
|
17
|
+
overflow: "hidden",
|
|
18
|
+
clipPath: "inset(50%)",
|
|
19
|
+
whiteSpace: "nowrap",
|
|
20
|
+
border: 0
|
|
21
|
+
};
|
|
22
|
+
/** The outline of a focused control, for a `:focus-visible` rule. */
|
|
23
|
+
const FOCUS_RING = "2px solid var(--a2ui-color-focus, #0285ff)";
|
|
24
|
+
/**
|
|
25
|
+
* Cuts the text after `lines` lines, with an ellipsis.
|
|
26
|
+
*
|
|
27
|
+
* @param lines - The number of lines to show.
|
|
28
|
+
*/
|
|
29
|
+
function lineClamp(lines) {
|
|
30
|
+
return {
|
|
31
|
+
display: "-webkit-box",
|
|
32
|
+
WebkitLineClamp: lines,
|
|
33
|
+
WebkitBoxOrient: "vertical",
|
|
34
|
+
overflow: "hidden"
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** The `align-items` value of each `align` prop value. */
|
|
38
|
+
const ALIGN_CSS = {
|
|
39
|
+
start: "flex-start",
|
|
40
|
+
end: "flex-end",
|
|
41
|
+
center: "center",
|
|
42
|
+
baseline: "baseline",
|
|
43
|
+
stretch: "stretch"
|
|
44
|
+
};
|
|
45
|
+
/** The `justify-content` value of each `justify` prop value. */
|
|
46
|
+
const JUSTIFY_CSS = {
|
|
47
|
+
start: "flex-start",
|
|
48
|
+
end: "flex-end",
|
|
49
|
+
center: "center",
|
|
50
|
+
spaceBetween: "space-between",
|
|
51
|
+
spaceAround: "space-around",
|
|
52
|
+
spaceEvenly: "space-evenly",
|
|
53
|
+
stretch: "stretch"
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* A CSS length: pixels when `value` is a number, the raw CSS when it is a
|
|
57
|
+
* string, and `undefined` when it is not set.
|
|
58
|
+
*
|
|
59
|
+
* @example px(12) // "12px"
|
|
60
|
+
*/
|
|
61
|
+
function px(value) {
|
|
62
|
+
if (value === void 0) return void 0;
|
|
63
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The CSS of a `radius` prop: one radius for all corners, or one radius for
|
|
67
|
+
* each corner.
|
|
68
|
+
*
|
|
69
|
+
* @param value - A radius token, a raw CSS value, or an object of corners.
|
|
70
|
+
*/
|
|
71
|
+
function radiusStyle(value) {
|
|
72
|
+
if (typeof value === "string" || typeof value === "number") return { borderRadius: radius(value) };
|
|
73
|
+
if (value === void 0) return {};
|
|
74
|
+
return {
|
|
75
|
+
borderTopLeftRadius: radius(value.topLeft),
|
|
76
|
+
borderTopRightRadius: radius(value.topRight),
|
|
77
|
+
borderBottomLeftRadius: radius(value.bottomLeft),
|
|
78
|
+
borderBottomRightRadius: radius(value.bottomRight)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A copy of `style` without the undefined entries, so a later spread never
|
|
83
|
+
* erases a value. An undefined longhand next to a shorthand is a removal:
|
|
84
|
+
* clearing `row-gap` resets the `gap` shorthand in real browsers.
|
|
85
|
+
*/
|
|
86
|
+
function defined(style) {
|
|
87
|
+
const result = {};
|
|
88
|
+
for (const [key, value] of Object.entries(style)) if (value !== void 0) result[key] = value;
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The `gap` of the layout props, with `rowGap` and `columnGap` winning over
|
|
93
|
+
* it. A renderer can apply a style object in sorted key order (Angular does),
|
|
94
|
+
* so `columnGap` would come before the `gap` shorthand and lose to it. A
|
|
95
|
+
* longhand therefore sets both longhands and no shorthand.
|
|
96
|
+
*/
|
|
97
|
+
function gapStyle(props) {
|
|
98
|
+
const gap = spacing(props.gap) ?? (props.disableAutoSpacing ? 0 : void 0);
|
|
99
|
+
const rowGap = spacing(props.rowGap);
|
|
100
|
+
const columnGap = spacing(props.columnGap);
|
|
101
|
+
if (rowGap === void 0 && columnGap === void 0) return { gap };
|
|
102
|
+
return {
|
|
103
|
+
rowGap: rowGap ?? gap,
|
|
104
|
+
columnGap: columnGap ?? gap
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The flex container CSS of the shared layout props (`align`, `gap`,
|
|
109
|
+
* `padding`, `radius`, sizes and the rest). An unset prop gives no CSS.
|
|
110
|
+
*
|
|
111
|
+
* @param props - The layout props of a container component.
|
|
112
|
+
*/
|
|
113
|
+
function layoutStyle(props) {
|
|
114
|
+
const overflow = props.scrollable ? "auto" : props.clip ? "hidden" : void 0;
|
|
115
|
+
return defined({
|
|
116
|
+
display: props.inline ? "inline-flex" : "flex",
|
|
117
|
+
alignItems: props.align ? ALIGN_CSS[props.align] : void 0,
|
|
118
|
+
justifyContent: props.justify ? JUSTIFY_CSS[props.justify] : void 0,
|
|
119
|
+
flexWrap: props.wrap,
|
|
120
|
+
...gapStyle(props),
|
|
121
|
+
padding: props.flush ? 0 : spacing(props.padding),
|
|
122
|
+
background: backgroundColor(props.background),
|
|
123
|
+
border: props.border ? `1px solid ${borderColor(props.borderColor ?? "default")}` : void 0,
|
|
124
|
+
...radiusStyle(props.radius),
|
|
125
|
+
width: spacing(props.width),
|
|
126
|
+
height: spacing(props.height),
|
|
127
|
+
minWidth: spacing(props.minWidth ?? props.minSize) ?? 0,
|
|
128
|
+
maxWidth: spacing(props.maxWidth ?? props.maxSize) ?? "100%",
|
|
129
|
+
minHeight: spacing(props.minHeight ?? props.minSize),
|
|
130
|
+
maxHeight: spacing(props.maxHeight ?? props.maxSize),
|
|
131
|
+
flex: props.flex,
|
|
132
|
+
flexGrow: props.weight,
|
|
133
|
+
aspectRatio: props.aspectRatio,
|
|
134
|
+
overflow,
|
|
135
|
+
boxShadow: props.shadow ? SHADOW_SM : void 0,
|
|
136
|
+
boxSizing: "border-box"
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
export { ALIGN_CSS, FOCUS_RING, JUSTIFY_CSS, VISUALLY_HIDDEN, defined, jsonEqual, layoutStyle, lineClamp, px, radiusStyle };
|
|
142
|
+
//# sourceMappingURL=style-helpers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-helpers.mjs","names":[],"sources":["../../../src/generative-ui/standard/style-helpers.ts"],"sourcesContent":["// Framework-free style helpers of the standard components. Each framework\n// binds the returned style objects to its own elements.\nimport {\n SHADOW_SM,\n backgroundColor,\n borderColor,\n radius,\n spacing,\n} from \"./tokens\";\nimport type { ALIGN, JUSTIFY } from \"./tokens\";\nimport type { LayoutProps } from \"./layout\";\n\n/** An inline style object, with camelCase CSS properties as keys. */\nexport type StyleMap = Record<string, string | number | undefined>;\n\n/**\n * Equal when the JSON is equal. Use it as the equality check of a computed\n * value over agent data, so a new object with the same content does not\n * trigger a redraw.\n */\nexport const jsonEqual = (a: unknown, b: unknown) =>\n JSON.stringify(a) === JSON.stringify(b);\n\n/** Hides an element on screen. Screen readers still read it. */\nexport const VISUALLY_HIDDEN: StyleMap = {\n position: \"absolute\",\n width: \"1px\",\n height: \"1px\",\n padding: 0,\n margin: \"-1px\",\n overflow: \"hidden\",\n clipPath: \"inset(50%)\",\n whiteSpace: \"nowrap\",\n border: 0,\n};\n\n/** The outline of a focused control, for a `:focus-visible` rule. */\nexport const FOCUS_RING = \"2px solid var(--a2ui-color-focus, #0285ff)\";\n\n/**\n * Cuts the text after `lines` lines, with an ellipsis.\n *\n * @param lines - The number of lines to show.\n */\nexport function lineClamp(lines: number): StyleMap {\n return {\n display: \"-webkit-box\",\n WebkitLineClamp: lines,\n WebkitBoxOrient: \"vertical\",\n overflow: \"hidden\",\n };\n}\n\n/** The `align-items` value of each `align` prop value. */\nexport const ALIGN_CSS: Record<(typeof ALIGN)[number], string> = {\n start: \"flex-start\",\n end: \"flex-end\",\n center: \"center\",\n baseline: \"baseline\",\n stretch: \"stretch\",\n};\n\n/** The `justify-content` value of each `justify` prop value. */\nexport const JUSTIFY_CSS: Record<(typeof JUSTIFY)[number], string> = {\n start: \"flex-start\",\n end: \"flex-end\",\n center: \"center\",\n spaceBetween: \"space-between\",\n spaceAround: \"space-around\",\n spaceEvenly: \"space-evenly\",\n stretch: \"stretch\",\n};\n\n/**\n * A CSS length: pixels when `value` is a number, the raw CSS when it is a\n * string, and `undefined` when it is not set.\n *\n * @example px(12) // \"12px\"\n */\nexport function px(value: number | string | undefined) {\n if (value === undefined) return undefined;\n return typeof value === \"number\" ? `${value}px` : value;\n}\n\n/**\n * The CSS of a `radius` prop: one radius for all corners, or one radius for\n * each corner.\n *\n * @param value - A radius token, a raw CSS value, or an object of corners.\n */\nexport function radiusStyle(value: LayoutProps[\"radius\"]): StyleMap {\n if (typeof value === \"string\" || typeof value === \"number\") {\n return { borderRadius: radius(value) };\n }\n if (value === undefined) return {};\n return {\n borderTopLeftRadius: radius(value.topLeft),\n borderTopRightRadius: radius(value.topRight),\n borderBottomLeftRadius: radius(value.bottomLeft),\n borderBottomRightRadius: radius(value.bottomRight),\n };\n}\n\n/**\n * A copy of `style` without the undefined entries, so a later spread never\n * erases a value. An undefined longhand next to a shorthand is a removal:\n * clearing `row-gap` resets the `gap` shorthand in real browsers.\n */\nexport function defined(style: StyleMap): StyleMap {\n const result: StyleMap = {};\n for (const [key, value] of Object.entries(style)) {\n if (value !== undefined) result[key] = value;\n }\n return result;\n}\n\n/**\n * The `gap` of the layout props, with `rowGap` and `columnGap` winning over\n * it. A renderer can apply a style object in sorted key order (Angular does),\n * so `columnGap` would come before the `gap` shorthand and lose to it. A\n * longhand therefore sets both longhands and no shorthand.\n */\nfunction gapStyle(props: LayoutProps): StyleMap {\n const gap = spacing(props.gap) ?? (props.disableAutoSpacing ? 0 : undefined);\n const rowGap = spacing(props.rowGap);\n const columnGap = spacing(props.columnGap);\n if (rowGap === undefined && columnGap === undefined) return { gap };\n return { rowGap: rowGap ?? gap, columnGap: columnGap ?? gap };\n}\n\n/**\n * The flex container CSS of the shared layout props (`align`, `gap`,\n * `padding`, `radius`, sizes and the rest). An unset prop gives no CSS.\n *\n * @param props - The layout props of a container component.\n */\nexport function layoutStyle(props: LayoutProps): StyleMap {\n const overflow = props.scrollable\n ? \"auto\"\n : props.clip\n ? \"hidden\"\n : undefined;\n return defined({\n display: props.inline ? \"inline-flex\" : \"flex\",\n alignItems: props.align ? ALIGN_CSS[props.align] : undefined,\n justifyContent: props.justify ? JUSTIFY_CSS[props.justify] : undefined,\n flexWrap: props.wrap,\n ...gapStyle(props),\n padding: props.flush ? 0 : spacing(props.padding),\n background: backgroundColor(props.background),\n border: props.border\n ? `1px solid ${borderColor(props.borderColor ?? \"default\")}`\n : undefined,\n ...radiusStyle(props.radius),\n width: spacing(props.width),\n height: spacing(props.height),\n // A container can shrink below its content and never gets wider than\n // its parent.\n minWidth: spacing(props.minWidth ?? props.minSize) ?? 0,\n maxWidth: spacing(props.maxWidth ?? props.maxSize) ?? \"100%\",\n minHeight: spacing(props.minHeight ?? props.minSize),\n maxHeight: spacing(props.maxHeight ?? props.maxSize),\n flex: props.flex,\n flexGrow: props.weight,\n aspectRatio: props.aspectRatio,\n overflow,\n boxShadow: props.shadow ? SHADOW_SM : undefined,\n boxSizing: \"border-box\",\n });\n}\n"],"mappings":";;;;;;;;AAoBA,MAAa,aAAa,GAAY,MACpC,KAAK,UAAU,EAAE,KAAK,KAAK,UAAU,EAAE;;AAGzC,MAAa,kBAA4B;CACvC,UAAU;CACV,OAAO;CACP,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,UAAU;CACV,UAAU;CACV,YAAY;CACZ,QAAQ;CACT;;AAGD,MAAa,aAAa;;;;;;AAO1B,SAAgB,UAAU,OAAyB;AACjD,QAAO;EACL,SAAS;EACT,iBAAiB;EACjB,iBAAiB;EACjB,UAAU;EACX;;;AAIH,MAAa,YAAoD;CAC/D,OAAO;CACP,KAAK;CACL,QAAQ;CACR,UAAU;CACV,SAAS;CACV;;AAGD,MAAa,cAAwD;CACnE,OAAO;CACP,KAAK;CACL,QAAQ;CACR,cAAc;CACd,aAAa;CACb,aAAa;CACb,SAAS;CACV;;;;;;;AAQD,SAAgB,GAAG,OAAoC;AACrD,KAAI,UAAU,OAAW,QAAO;AAChC,QAAO,OAAO,UAAU,WAAW,GAAG,MAAM,MAAM;;;;;;;;AASpD,SAAgB,YAAY,OAAwC;AAClE,KAAI,OAAO,UAAU,YAAY,OAAO,UAAU,SAChD,QAAO,EAAE,cAAc,OAAO,MAAM,EAAE;AAExC,KAAI,UAAU,OAAW,QAAO,EAAE;AAClC,QAAO;EACL,qBAAqB,OAAO,MAAM,QAAQ;EAC1C,sBAAsB,OAAO,MAAM,SAAS;EAC5C,wBAAwB,OAAO,MAAM,WAAW;EAChD,yBAAyB,OAAO,MAAM,YAAY;EACnD;;;;;;;AAQH,SAAgB,QAAQ,OAA2B;CACjD,MAAM,SAAmB,EAAE;AAC3B,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,CAC9C,KAAI,UAAU,OAAW,QAAO,OAAO;AAEzC,QAAO;;;;;;;;AAST,SAAS,SAAS,OAA8B;CAC9C,MAAM,MAAM,QAAQ,MAAM,IAAI,KAAK,MAAM,qBAAqB,IAAI;CAClE,MAAM,SAAS,QAAQ,MAAM,OAAO;CACpC,MAAM,YAAY,QAAQ,MAAM,UAAU;AAC1C,KAAI,WAAW,UAAa,cAAc,OAAW,QAAO,EAAE,KAAK;AACnE,QAAO;EAAE,QAAQ,UAAU;EAAK,WAAW,aAAa;EAAK;;;;;;;;AAS/D,SAAgB,YAAY,OAA8B;CACxD,MAAM,WAAW,MAAM,aACnB,SACA,MAAM,OACJ,WACA;AACN,QAAO,QAAQ;EACb,SAAS,MAAM,SAAS,gBAAgB;EACxC,YAAY,MAAM,QAAQ,UAAU,MAAM,SAAS;EACnD,gBAAgB,MAAM,UAAU,YAAY,MAAM,WAAW;EAC7D,UAAU,MAAM;EAChB,GAAG,SAAS,MAAM;EAClB,SAAS,MAAM,QAAQ,IAAI,QAAQ,MAAM,QAAQ;EACjD,YAAY,gBAAgB,MAAM,WAAW;EAC7C,QAAQ,MAAM,SACV,aAAa,YAAY,MAAM,eAAe,UAAU,KACxD;EACJ,GAAG,YAAY,MAAM,OAAO;EAC5B,OAAO,QAAQ,MAAM,MAAM;EAC3B,QAAQ,QAAQ,MAAM,OAAO;EAG7B,UAAU,QAAQ,MAAM,YAAY,MAAM,QAAQ,IAAI;EACtD,UAAU,QAAQ,MAAM,YAAY,MAAM,QAAQ,IAAI;EACtD,WAAW,QAAQ,MAAM,aAAa,MAAM,QAAQ;EACpD,WAAW,QAAQ,MAAM,aAAa,MAAM,QAAQ;EACpD,MAAM,MAAM;EACZ,UAAU,MAAM;EAChB,aAAa,MAAM;EACnB;EACA,WAAW,MAAM,SAAS,YAAY;EACtC,WAAW;EACZ,CAAC"}
|
|
@@ -55,12 +55,12 @@ declare const textSchema: z.ZodObject<{
|
|
|
55
55
|
weight: z.ZodOptional<z.ZodNumber>;
|
|
56
56
|
text: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
57
57
|
size: z.ZodOptional<z.ZodEnum<{
|
|
58
|
-
"2xs": "2xs";
|
|
59
|
-
xs: "xs";
|
|
60
58
|
sm: "sm";
|
|
61
59
|
md: "md";
|
|
62
60
|
lg: "lg";
|
|
63
61
|
"3xs": "3xs";
|
|
62
|
+
"2xs": "2xs";
|
|
63
|
+
xs: "xs";
|
|
64
64
|
}>>;
|
|
65
65
|
fontSize: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
66
66
|
lineHeight: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
@@ -121,12 +121,12 @@ declare const labelSchema: z.ZodObject<{
|
|
|
121
121
|
htmlFor: z.ZodOptional<z.ZodString>;
|
|
122
122
|
color: z.ZodOptional<z.ZodString>;
|
|
123
123
|
size: z.ZodOptional<z.ZodEnum<{
|
|
124
|
-
"2xs": "2xs";
|
|
125
|
-
xs: "xs";
|
|
126
124
|
sm: "sm";
|
|
127
125
|
md: "md";
|
|
128
126
|
lg: "lg";
|
|
129
127
|
"3xs": "3xs";
|
|
128
|
+
"2xs": "2xs";
|
|
129
|
+
xs: "xs";
|
|
130
130
|
}>>;
|
|
131
131
|
fontWeight: z.ZodOptional<z.ZodEnum<{
|
|
132
132
|
normal: "normal";
|
|
@@ -161,12 +161,12 @@ declare const BADGE_SIZES: readonly ["sm", "md", "lg"];
|
|
|
161
161
|
declare const badgeSchema: z.ZodObject<{
|
|
162
162
|
label: z.ZodString;
|
|
163
163
|
color: z.ZodOptional<z.ZodEnum<{
|
|
164
|
+
secondary: "secondary";
|
|
164
165
|
success: "success";
|
|
165
166
|
info: "info";
|
|
166
167
|
warning: "warning";
|
|
167
168
|
danger: "danger";
|
|
168
169
|
discovery: "discovery";
|
|
169
|
-
secondary: "secondary";
|
|
170
170
|
}>>;
|
|
171
171
|
size: z.ZodOptional<z.ZodEnum<{
|
|
172
172
|
sm: "sm";
|
|
@@ -203,12 +203,12 @@ declare const mathSchema: z.ZodObject<{
|
|
|
203
203
|
declare const shimmerSchema: z.ZodObject<{
|
|
204
204
|
text: z.ZodString;
|
|
205
205
|
size: z.ZodOptional<z.ZodEnum<{
|
|
206
|
-
"2xs": "2xs";
|
|
207
|
-
xs: "xs";
|
|
208
206
|
sm: "sm";
|
|
209
207
|
md: "md";
|
|
210
208
|
lg: "lg";
|
|
211
209
|
"3xs": "3xs";
|
|
210
|
+
"2xs": "2xs";
|
|
211
|
+
xs: "xs";
|
|
212
212
|
}>>;
|
|
213
213
|
lineThrough: z.ZodOptional<z.ZodBoolean>;
|
|
214
214
|
color: z.ZodOptional<z.ZodString>;
|
|
@@ -283,12 +283,12 @@ declare const textDeclarations: {
|
|
|
283
283
|
weight: z.ZodOptional<z.ZodNumber>;
|
|
284
284
|
text: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
285
285
|
size: z.ZodOptional<z.ZodEnum<{
|
|
286
|
-
"2xs": "2xs";
|
|
287
|
-
xs: "xs";
|
|
288
286
|
sm: "sm";
|
|
289
287
|
md: "md";
|
|
290
288
|
lg: "lg";
|
|
291
289
|
"3xs": "3xs";
|
|
290
|
+
"2xs": "2xs";
|
|
291
|
+
xs: "xs";
|
|
292
292
|
}>>;
|
|
293
293
|
fontSize: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
294
294
|
lineHeight: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
@@ -357,12 +357,12 @@ declare const textDeclarations: {
|
|
|
357
357
|
htmlFor: z.ZodOptional<z.ZodString>;
|
|
358
358
|
color: z.ZodOptional<z.ZodString>;
|
|
359
359
|
size: z.ZodOptional<z.ZodEnum<{
|
|
360
|
-
"2xs": "2xs";
|
|
361
|
-
xs: "xs";
|
|
362
360
|
sm: "sm";
|
|
363
361
|
md: "md";
|
|
364
362
|
lg: "lg";
|
|
365
363
|
"3xs": "3xs";
|
|
364
|
+
"2xs": "2xs";
|
|
365
|
+
xs: "xs";
|
|
366
366
|
}>>;
|
|
367
367
|
fontWeight: z.ZodOptional<z.ZodEnum<{
|
|
368
368
|
normal: "normal";
|
|
@@ -414,12 +414,12 @@ declare const textDeclarations: {
|
|
|
414
414
|
props: z.ZodObject<{
|
|
415
415
|
label: z.ZodString;
|
|
416
416
|
color: z.ZodOptional<z.ZodEnum<{
|
|
417
|
+
secondary: "secondary";
|
|
417
418
|
success: "success";
|
|
418
419
|
info: "info";
|
|
419
420
|
warning: "warning";
|
|
420
421
|
danger: "danger";
|
|
421
422
|
discovery: "discovery";
|
|
422
|
-
secondary: "secondary";
|
|
423
423
|
}>>;
|
|
424
424
|
size: z.ZodOptional<z.ZodEnum<{
|
|
425
425
|
sm: "sm";
|
|
@@ -474,12 +474,12 @@ declare const textDeclarations: {
|
|
|
474
474
|
props: z.ZodObject<{
|
|
475
475
|
text: z.ZodString;
|
|
476
476
|
size: z.ZodOptional<z.ZodEnum<{
|
|
477
|
-
"2xs": "2xs";
|
|
478
|
-
xs: "xs";
|
|
479
477
|
sm: "sm";
|
|
480
478
|
md: "md";
|
|
481
479
|
lg: "lg";
|
|
482
480
|
"3xs": "3xs";
|
|
481
|
+
"2xs": "2xs";
|
|
482
|
+
xs: "xs";
|
|
483
483
|
}>>;
|
|
484
484
|
lineThrough: z.ZodOptional<z.ZodBoolean>;
|
|
485
485
|
color: z.ZodOptional<z.ZodString>;
|