@ariaui/radius 0.1.1

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.
@@ -0,0 +1,454 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __export = (target, all) => {
24
+ for (var name in all)
25
+ __defProp(target, name, { get: all[name], enumerable: true });
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
+
37
+ // tokens.ts
38
+ var tokens_exports = {};
39
+ __export(tokens_exports, {
40
+ BREAKPOINTS: () => BREAKPOINTS,
41
+ clampScale: () => clampScale,
42
+ createLinearScale: () => createLinearScale,
43
+ createScale: () => createScale,
44
+ innerCorners: () => innerCorners,
45
+ innerRadius: () => innerRadius,
46
+ mobileRadius: () => mobileRadius,
47
+ nestingPair: () => nestingPair,
48
+ parseCorners: () => parseCorners,
49
+ parseRadius: () => parseRadius,
50
+ requiredGap: () => requiredGap,
51
+ resolveBaseRadius: () => resolveBaseRadius,
52
+ resolveInnerRadius: () => resolveInnerRadius,
53
+ resolveRadius: () => resolveRadius,
54
+ resolveRadiusScale: () => resolveRadiusScale,
55
+ resolveThemeAliases: () => resolveThemeAliases,
56
+ responsiveRadius: () => responsiveRadius,
57
+ roundCorners: () => roundCorners,
58
+ scaleBy: () => scaleBy,
59
+ setBottom: () => setBottom,
60
+ setCorner: () => setCorner,
61
+ setLeft: () => setLeft,
62
+ setRight: () => setRight,
63
+ setTop: () => setTop,
64
+ sortedBreakpoints: () => sortedBreakpoints,
65
+ sortedLevels: () => sortedLevels,
66
+ stepRadius: () => stepRadius,
67
+ toCSS: () => toCSS,
68
+ toCSSDeclaration: () => toCSSDeclaration,
69
+ toCSSProperties: () => toCSSProperties,
70
+ toCSSShorthand: () => toCSSShorthand,
71
+ toCSSVar: () => toCSSVar,
72
+ toPx: () => toPx2,
73
+ toRem: () => toRem,
74
+ toTailwindClass: () => toTailwindClass,
75
+ toTailwindCorners: () => toTailwindCorners,
76
+ uniformCorners: () => uniformCorners
77
+ });
78
+ module.exports = __toCommonJS(tokens_exports);
79
+
80
+ // src/parse.ts
81
+ function parseRadius(input) {
82
+ if (typeof input === "number") {
83
+ return { value: input, unit: "px", original: `${input}px` };
84
+ }
85
+ const trimmed = input.trim();
86
+ if (trimmed.endsWith("rem")) {
87
+ const value2 = parseFloat(trimmed);
88
+ if (Number.isNaN(value2)) throw new Error(`Invalid radius value: "${input}"`);
89
+ return { value: value2, unit: "rem", original: trimmed };
90
+ }
91
+ if (trimmed.endsWith("%")) {
92
+ const value2 = parseFloat(trimmed);
93
+ if (Number.isNaN(value2)) throw new Error(`Invalid radius value: "${input}"`);
94
+ return { value: value2, unit: "%", original: trimmed };
95
+ }
96
+ const value = parseFloat(trimmed);
97
+ if (Number.isNaN(value)) throw new Error(`Invalid radius value: "${input}"`);
98
+ return { value, unit: "px", original: trimmed.endsWith("px") ? trimmed : `${value}px` };
99
+ }
100
+ function parseCorners(input) {
101
+ const parts = input.trim().split(/\s+/);
102
+ if (parts.length === 1) {
103
+ const v = parseRadius(parts[0]);
104
+ return { topLeft: v, topRight: v, bottomRight: v, bottomLeft: v };
105
+ }
106
+ if (parts.length === 2) {
107
+ const tlbr = parseRadius(parts[0]);
108
+ const trbl = parseRadius(parts[1]);
109
+ return { topLeft: tlbr, topRight: trbl, bottomRight: tlbr, bottomLeft: trbl };
110
+ }
111
+ if (parts.length === 3) {
112
+ const tl = parseRadius(parts[0]);
113
+ const trbl = parseRadius(parts[1]);
114
+ const br = parseRadius(parts[2]);
115
+ return { topLeft: tl, topRight: trbl, bottomRight: br, bottomLeft: trbl };
116
+ }
117
+ if (parts.length >= 4) {
118
+ return {
119
+ topLeft: parseRadius(parts[0]),
120
+ topRight: parseRadius(parts[1]),
121
+ bottomRight: parseRadius(parts[2]),
122
+ bottomLeft: parseRadius(parts[3])
123
+ };
124
+ }
125
+ throw new Error(`Invalid border-radius shorthand: "${input}"`);
126
+ }
127
+
128
+ // src/scale.ts
129
+ function createLinearScale(base = 0, step = 4, count = 6) {
130
+ const result = {};
131
+ for (let i = 0; i < count; i++) {
132
+ const value = base + step * i;
133
+ result[String(i)] = parseRadius(value);
134
+ }
135
+ return result;
136
+ }
137
+ function createScale(values) {
138
+ const result = {};
139
+ for (const [name, value] of Object.entries(values)) {
140
+ result[name] = parseRadius(value);
141
+ }
142
+ return result;
143
+ }
144
+ function scaleBy(scale, factor) {
145
+ const result = {};
146
+ for (const [name, rv] of Object.entries(scale)) {
147
+ const newValue = round(rv.value * factor);
148
+ result[name] = {
149
+ value: newValue,
150
+ unit: rv.unit,
151
+ original: `${newValue}${rv.unit}`
152
+ };
153
+ }
154
+ return result;
155
+ }
156
+ function clampScale(scale, min, max) {
157
+ const result = {};
158
+ for (const [name, rv] of Object.entries(scale)) {
159
+ const clamped = Math.max(min, Math.min(max, rv.value));
160
+ result[name] = {
161
+ value: clamped,
162
+ unit: rv.unit,
163
+ original: `${clamped}${rv.unit}`
164
+ };
165
+ }
166
+ return result;
167
+ }
168
+ function sortedLevels(scale) {
169
+ return Object.keys(scale).sort((a, b) => {
170
+ return toPx(scale[a]) - toPx(scale[b]);
171
+ });
172
+ }
173
+ function stepRadius(scale, current, direction) {
174
+ const ordered = sortedLevels(scale);
175
+ const idx = ordered.indexOf(current);
176
+ if (idx === -1) return current;
177
+ const next = direction === "up" ? idx + 1 : idx - 1;
178
+ const clamped = Math.max(0, Math.min(ordered.length - 1, next));
179
+ return ordered[clamped];
180
+ }
181
+ function round(value) {
182
+ return Math.round(value * 1e3) / 1e3;
183
+ }
184
+ function toPx(rv) {
185
+ if (rv.unit === "rem") return rv.value * 16;
186
+ return rv.value;
187
+ }
188
+
189
+ // src/corners.ts
190
+ function toRadiusValue(input) {
191
+ if (typeof input === "object" && "value" in input) return input;
192
+ return parseRadius(input);
193
+ }
194
+ var ZERO = { value: 0, unit: "px", original: "0px" };
195
+ function uniformCorners(radius) {
196
+ const v = toRadiusValue(radius);
197
+ return { topLeft: v, topRight: v, bottomRight: v, bottomLeft: v };
198
+ }
199
+ function setCorner(corners, corner, value) {
200
+ return __spreadProps(__spreadValues({}, corners), { [corner]: toRadiusValue(value) });
201
+ }
202
+ function setTop(corners, value) {
203
+ const v = toRadiusValue(value);
204
+ return __spreadProps(__spreadValues({}, corners), { topLeft: v, topRight: v });
205
+ }
206
+ function setBottom(corners, value) {
207
+ const v = toRadiusValue(value);
208
+ return __spreadProps(__spreadValues({}, corners), { bottomLeft: v, bottomRight: v });
209
+ }
210
+ function setLeft(corners, value) {
211
+ const v = toRadiusValue(value);
212
+ return __spreadProps(__spreadValues({}, corners), { topLeft: v, bottomLeft: v });
213
+ }
214
+ function setRight(corners, value) {
215
+ const v = toRadiusValue(value);
216
+ return __spreadProps(__spreadValues({}, corners), { topRight: v, bottomRight: v });
217
+ }
218
+ function roundCorners(radius, ...corners) {
219
+ const v = toRadiusValue(radius);
220
+ return {
221
+ topLeft: corners.includes("topLeft") ? v : ZERO,
222
+ topRight: corners.includes("topRight") ? v : ZERO,
223
+ bottomRight: corners.includes("bottomRight") ? v : ZERO,
224
+ bottomLeft: corners.includes("bottomLeft") ? v : ZERO
225
+ };
226
+ }
227
+
228
+ // src/nesting.ts
229
+ function toRadiusValue2(input) {
230
+ if (typeof input === "object" && "value" in input) return input;
231
+ return parseRadius(input);
232
+ }
233
+ function innerRadius(outer, gap) {
234
+ const o = toRadiusValue2(outer);
235
+ const inner = Math.max(0, o.value - gap);
236
+ return {
237
+ value: inner,
238
+ unit: o.unit,
239
+ original: `${inner}${o.unit}`
240
+ };
241
+ }
242
+ function innerCorners(outer, gap) {
243
+ return {
244
+ topLeft: innerRadius(outer.topLeft, gap),
245
+ topRight: innerRadius(outer.topRight, gap),
246
+ bottomRight: innerRadius(outer.bottomRight, gap),
247
+ bottomLeft: innerRadius(outer.bottomLeft, gap)
248
+ };
249
+ }
250
+ function requiredGap(outer, inner) {
251
+ const o = toRadiusValue2(outer);
252
+ const i = toRadiusValue2(inner);
253
+ return Math.max(0, o.value - i.value);
254
+ }
255
+ function nestingPair(outerRadius, gap) {
256
+ const outer = parseRadius(outerRadius);
257
+ const inner = innerRadius(outer, gap);
258
+ return { outer, inner };
259
+ }
260
+
261
+ // src/responsive.ts
262
+ var BREAKPOINTS = {
263
+ sm: 640,
264
+ md: 768,
265
+ lg: 1024,
266
+ xl: 1280,
267
+ "2xl": 1536
268
+ };
269
+ function responsiveRadius(config, breakpoints = BREAKPOINTS) {
270
+ const defaultEntry = config["default"];
271
+ if (defaultEntry === void 0) {
272
+ throw new Error('responsiveRadius: "default" entry is required');
273
+ }
274
+ const defaultValue = parseRadius(defaultEntry);
275
+ const bps = {};
276
+ for (const [key, value] of Object.entries(config)) {
277
+ if (key === "default") continue;
278
+ if (!(key in breakpoints)) {
279
+ throw new Error(
280
+ `responsiveRadius: unknown breakpoint "${key}". Available: ${Object.keys(breakpoints).join(", ")}`
281
+ );
282
+ }
283
+ bps[key] = parseRadius(value);
284
+ }
285
+ return { default: defaultValue, breakpoints: bps };
286
+ }
287
+ function mobileRadius(value, factor = 0.75) {
288
+ const scaled = Math.max(0, Math.round(value.value * factor));
289
+ return {
290
+ value: scaled,
291
+ unit: value.unit,
292
+ original: `${scaled}${value.unit}`
293
+ };
294
+ }
295
+ function sortedBreakpoints(responsive, breakpoints = BREAKPOINTS) {
296
+ return Object.entries(responsive.breakpoints).map(
297
+ ([name, value]) => {
298
+ var _a;
299
+ return [name, (_a = breakpoints[name]) != null ? _a : 0, value];
300
+ }
301
+ ).sort((a, b) => a[1] - b[1]);
302
+ }
303
+
304
+ // src/format.ts
305
+ function round2(value, decimals = 4) {
306
+ const f = Math.pow(10, decimals);
307
+ return Math.round(value * f) / f;
308
+ }
309
+ function toCSS(value) {
310
+ return `${value.value}${value.unit}`;
311
+ }
312
+ function toRem(value, base = 16) {
313
+ if (value.unit === "rem") return `${value.value}rem`;
314
+ if (value.unit === "%") return value.original;
315
+ const rem = round2(value.value / base);
316
+ return `${rem}rem`;
317
+ }
318
+ function toPx2(value, base = 16) {
319
+ if (value.unit === "px") return `${value.value}px`;
320
+ if (value.unit === "%") return value.original;
321
+ const px = round2(value.value * base);
322
+ return `${px}px`;
323
+ }
324
+ function toCSSShorthand(corners) {
325
+ const tl = toCSS(corners.topLeft);
326
+ const tr = toCSS(corners.topRight);
327
+ const br = toCSS(corners.bottomRight);
328
+ const bl = toCSS(corners.bottomLeft);
329
+ if (tl === tr && tr === br && br === bl) return tl;
330
+ if (tl === br && tr === bl) return `${tl} ${tr}`;
331
+ if (tr === bl) return `${tl} ${tr} ${br}`;
332
+ return `${tl} ${tr} ${br} ${bl}`;
333
+ }
334
+ function toCSSProperties(corners) {
335
+ return {
336
+ borderTopLeftRadius: toCSS(corners.topLeft),
337
+ borderTopRightRadius: toCSS(corners.topRight),
338
+ borderBottomRightRadius: toCSS(corners.bottomRight),
339
+ borderBottomLeftRadius: toCSS(corners.bottomLeft)
340
+ };
341
+ }
342
+ function toCSSDeclaration(corners) {
343
+ return `border-radius: ${toCSSShorthand(corners)};`;
344
+ }
345
+ function toTailwindClass(value) {
346
+ return `rounded-[${toCSS(value)}]`;
347
+ }
348
+ function toTailwindCorners(corners) {
349
+ const tl = toCSS(corners.topLeft);
350
+ const tr = toCSS(corners.topRight);
351
+ const br = toCSS(corners.bottomRight);
352
+ const bl = toCSS(corners.bottomLeft);
353
+ if (tl === tr && tr === br && br === bl) {
354
+ return `rounded-[${tl}]`;
355
+ }
356
+ return [
357
+ `rounded-tl-[${tl}]`,
358
+ `rounded-tr-[${tr}]`,
359
+ `rounded-br-[${br}]`,
360
+ `rounded-bl-[${bl}]`
361
+ ].join(" ");
362
+ }
363
+ function toCSSVar(level) {
364
+ return `var(--radius-${level})`;
365
+ }
366
+
367
+ // src/resolve.ts
368
+ var import_tokens = require("@ariaui/tokens");
369
+ var RADIUS_KEYS = {
370
+ none: "radius-none",
371
+ xxs: "radius-xxs",
372
+ xs: "radius-xs",
373
+ sm: "radius-sm",
374
+ md: "radius-md",
375
+ lg: "radius-lg",
376
+ xl: "radius-xl",
377
+ "2xl": "radius-2xl",
378
+ "3xl": "radius-3xl",
379
+ "4xl": "radius-4xl",
380
+ full: "radius-full"
381
+ };
382
+ function resolveRadius(level) {
383
+ const tokenKey = RADIUS_KEYS[level];
384
+ const tokenValue = import_tokens.light[tokenKey];
385
+ if (tokenValue === void 0) {
386
+ throw new Error(`Radius token not found: "${level}" (key: "${tokenKey}")`);
387
+ }
388
+ return parseRadius(tokenValue);
389
+ }
390
+ function resolveRadiusScale() {
391
+ const result = {};
392
+ for (const level of Object.keys(RADIUS_KEYS)) {
393
+ result[level] = resolveRadius(level);
394
+ }
395
+ return result;
396
+ }
397
+ function resolveBaseRadius() {
398
+ const value = import_tokens.light["radius"];
399
+ if (value === void 0) {
400
+ throw new Error('Base radius token "radius" not found');
401
+ }
402
+ return parseRadius(value);
403
+ }
404
+ function resolveThemeAliases() {
405
+ return {
406
+ lg: "var(--radius)",
407
+ md: "calc(var(--radius) - 2px)",
408
+ sm: "calc(var(--radius) - 4px)"
409
+ };
410
+ }
411
+ function resolveInnerRadius(level, gap) {
412
+ const outer = resolveRadius(level);
413
+ return innerRadius(outer, gap);
414
+ }
415
+ // Annotate the CommonJS export names for ESM import in node:
416
+ 0 && (module.exports = {
417
+ BREAKPOINTS,
418
+ clampScale,
419
+ createLinearScale,
420
+ createScale,
421
+ innerCorners,
422
+ innerRadius,
423
+ mobileRadius,
424
+ nestingPair,
425
+ parseCorners,
426
+ parseRadius,
427
+ requiredGap,
428
+ resolveBaseRadius,
429
+ resolveInnerRadius,
430
+ resolveRadius,
431
+ resolveRadiusScale,
432
+ resolveThemeAliases,
433
+ responsiveRadius,
434
+ roundCorners,
435
+ scaleBy,
436
+ setBottom,
437
+ setCorner,
438
+ setLeft,
439
+ setRight,
440
+ setTop,
441
+ sortedBreakpoints,
442
+ sortedLevels,
443
+ stepRadius,
444
+ toCSS,
445
+ toCSSDeclaration,
446
+ toCSSProperties,
447
+ toCSSShorthand,
448
+ toCSSVar,
449
+ toPx,
450
+ toRem,
451
+ toTailwindClass,
452
+ toTailwindCorners,
453
+ uniformCorners
454
+ });
@@ -0,0 +1,42 @@
1
+ import { RadiusValue, RadiusLevel } from './index.cjs';
2
+ export { BREAKPOINTS, Breakpoints, Corner, CornerRadii, RadiusScale, ResponsiveRadius, clampScale, createLinearScale, createScale, innerCorners, innerRadius, mobileRadius, nestingPair, parseCorners, parseRadius, requiredGap, responsiveRadius, roundCorners, scaleBy, setBottom, setCorner, setLeft, setRight, setTop, sortedBreakpoints, sortedLevels, stepRadius, toCSS, toCSSDeclaration, toCSSProperties, toCSSShorthand, toCSSVar, toPx, toRem, toTailwindClass, toTailwindCorners, uniformCorners } from './index.cjs';
3
+
4
+ /**
5
+ * Resolve a token radius level to a `RadiusValue`.
6
+ *
7
+ * @example
8
+ * resolveRadius("md") → { value: 8, unit: "px", original: "8px" }
9
+ * resolveRadius("full") → { value: 9999, unit: "px", original: "9999px" }
10
+ */
11
+ declare function resolveRadius(level: RadiusLevel): RadiusValue;
12
+ /**
13
+ * Resolve the full token radius scale.
14
+ */
15
+ declare function resolveRadiusScale(): Record<RadiusLevel, RadiusValue>;
16
+ /**
17
+ * Resolve the base `--radius` token (used by the `@theme` calc expressions).
18
+ *
19
+ * @example
20
+ * resolveBaseRadius() → { value: 8, unit: "px", original: "8px" }
21
+ */
22
+ declare function resolveBaseRadius(): RadiusValue;
23
+ /**
24
+ * Get the `@theme` calc-based aliases that Tailwind uses.
25
+ *
26
+ * These are the expressions from `css.ts` that derive from `--radius`:
27
+ * - `--radius-lg: var(--radius)`
28
+ * - `--radius-md: calc(var(--radius) - 2px)`
29
+ * - `--radius-sm: calc(var(--radius) - 4px)`
30
+ */
31
+ declare function resolveThemeAliases(): Record<string, string>;
32
+ /**
33
+ * Derive inner radius from a token level + gap.
34
+ *
35
+ * Convenience wrapper: resolves the token level, then computes inner radius.
36
+ *
37
+ * @example
38
+ * resolveInnerRadius("xl", 8) → { value: 4, unit: "px", original: "4px" }
39
+ */
40
+ declare function resolveInnerRadius(level: RadiusLevel, gap: number): RadiusValue;
41
+
42
+ export { RadiusLevel, RadiusValue, resolveBaseRadius, resolveInnerRadius, resolveRadius, resolveRadiusScale, resolveThemeAliases };
@@ -0,0 +1,42 @@
1
+ import { RadiusValue, RadiusLevel } from './index.js';
2
+ export { BREAKPOINTS, Breakpoints, Corner, CornerRadii, RadiusScale, ResponsiveRadius, clampScale, createLinearScale, createScale, innerCorners, innerRadius, mobileRadius, nestingPair, parseCorners, parseRadius, requiredGap, responsiveRadius, roundCorners, scaleBy, setBottom, setCorner, setLeft, setRight, setTop, sortedBreakpoints, sortedLevels, stepRadius, toCSS, toCSSDeclaration, toCSSProperties, toCSSShorthand, toCSSVar, toPx, toRem, toTailwindClass, toTailwindCorners, uniformCorners } from './index.js';
3
+
4
+ /**
5
+ * Resolve a token radius level to a `RadiusValue`.
6
+ *
7
+ * @example
8
+ * resolveRadius("md") → { value: 8, unit: "px", original: "8px" }
9
+ * resolveRadius("full") → { value: 9999, unit: "px", original: "9999px" }
10
+ */
11
+ declare function resolveRadius(level: RadiusLevel): RadiusValue;
12
+ /**
13
+ * Resolve the full token radius scale.
14
+ */
15
+ declare function resolveRadiusScale(): Record<RadiusLevel, RadiusValue>;
16
+ /**
17
+ * Resolve the base `--radius` token (used by the `@theme` calc expressions).
18
+ *
19
+ * @example
20
+ * resolveBaseRadius() → { value: 8, unit: "px", original: "8px" }
21
+ */
22
+ declare function resolveBaseRadius(): RadiusValue;
23
+ /**
24
+ * Get the `@theme` calc-based aliases that Tailwind uses.
25
+ *
26
+ * These are the expressions from `css.ts` that derive from `--radius`:
27
+ * - `--radius-lg: var(--radius)`
28
+ * - `--radius-md: calc(var(--radius) - 2px)`
29
+ * - `--radius-sm: calc(var(--radius) - 4px)`
30
+ */
31
+ declare function resolveThemeAliases(): Record<string, string>;
32
+ /**
33
+ * Derive inner radius from a token level + gap.
34
+ *
35
+ * Convenience wrapper: resolves the token level, then computes inner radius.
36
+ *
37
+ * @example
38
+ * resolveInnerRadius("xl", 8) → { value: 4, unit: "px", original: "4px" }
39
+ */
40
+ declare function resolveInnerRadius(level: RadiusLevel, gap: number): RadiusValue;
41
+
42
+ export { RadiusLevel, RadiusValue, resolveBaseRadius, resolveInnerRadius, resolveRadius, resolveRadiusScale, resolveThemeAliases };
package/dist/tokens.js ADDED
@@ -0,0 +1,122 @@
1
+ import {
2
+ BREAKPOINTS,
3
+ clampScale,
4
+ createLinearScale,
5
+ createScale,
6
+ innerCorners,
7
+ innerRadius,
8
+ mobileRadius,
9
+ nestingPair,
10
+ parseCorners,
11
+ parseRadius,
12
+ requiredGap,
13
+ responsiveRadius,
14
+ roundCorners,
15
+ scaleBy,
16
+ setBottom,
17
+ setCorner,
18
+ setLeft,
19
+ setRight,
20
+ setTop,
21
+ sortedBreakpoints,
22
+ sortedLevels,
23
+ stepRadius,
24
+ toCSS,
25
+ toCSSDeclaration,
26
+ toCSSProperties,
27
+ toCSSShorthand,
28
+ toCSSVar,
29
+ toPx,
30
+ toRem,
31
+ toTailwindClass,
32
+ toTailwindCorners,
33
+ uniformCorners
34
+ } from "./chunk-3Y6IG3UW.js";
35
+
36
+ // src/resolve.ts
37
+ import { light } from "@ariaui/tokens";
38
+ var RADIUS_KEYS = {
39
+ none: "radius-none",
40
+ xxs: "radius-xxs",
41
+ xs: "radius-xs",
42
+ sm: "radius-sm",
43
+ md: "radius-md",
44
+ lg: "radius-lg",
45
+ xl: "radius-xl",
46
+ "2xl": "radius-2xl",
47
+ "3xl": "radius-3xl",
48
+ "4xl": "radius-4xl",
49
+ full: "radius-full"
50
+ };
51
+ function resolveRadius(level) {
52
+ const tokenKey = RADIUS_KEYS[level];
53
+ const tokenValue = light[tokenKey];
54
+ if (tokenValue === void 0) {
55
+ throw new Error(`Radius token not found: "${level}" (key: "${tokenKey}")`);
56
+ }
57
+ return parseRadius(tokenValue);
58
+ }
59
+ function resolveRadiusScale() {
60
+ const result = {};
61
+ for (const level of Object.keys(RADIUS_KEYS)) {
62
+ result[level] = resolveRadius(level);
63
+ }
64
+ return result;
65
+ }
66
+ function resolveBaseRadius() {
67
+ const value = light["radius"];
68
+ if (value === void 0) {
69
+ throw new Error('Base radius token "radius" not found');
70
+ }
71
+ return parseRadius(value);
72
+ }
73
+ function resolveThemeAliases() {
74
+ return {
75
+ lg: "var(--radius)",
76
+ md: "calc(var(--radius) - 2px)",
77
+ sm: "calc(var(--radius) - 4px)"
78
+ };
79
+ }
80
+ function resolveInnerRadius(level, gap) {
81
+ const outer = resolveRadius(level);
82
+ return innerRadius(outer, gap);
83
+ }
84
+ export {
85
+ BREAKPOINTS,
86
+ clampScale,
87
+ createLinearScale,
88
+ createScale,
89
+ innerCorners,
90
+ innerRadius,
91
+ mobileRadius,
92
+ nestingPair,
93
+ parseCorners,
94
+ parseRadius,
95
+ requiredGap,
96
+ resolveBaseRadius,
97
+ resolveInnerRadius,
98
+ resolveRadius,
99
+ resolveRadiusScale,
100
+ resolveThemeAliases,
101
+ responsiveRadius,
102
+ roundCorners,
103
+ scaleBy,
104
+ setBottom,
105
+ setCorner,
106
+ setLeft,
107
+ setRight,
108
+ setTop,
109
+ sortedBreakpoints,
110
+ sortedLevels,
111
+ stepRadius,
112
+ toCSS,
113
+ toCSSDeclaration,
114
+ toCSSProperties,
115
+ toCSSShorthand,
116
+ toCSSVar,
117
+ toPx,
118
+ toRem,
119
+ toTailwindClass,
120
+ toTailwindCorners,
121
+ uniformCorners
122
+ };
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@ariaui/radius",
3
+ "version": "0.1.1",
4
+ "type": "module",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "./tokens": {
16
+ "types": "./dist/tokens.d.ts",
17
+ "import": "./dist/tokens.js",
18
+ "require": "./dist/tokens.cjs",
19
+ "default": "./dist/tokens.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "license": "MIT",
26
+ "peerDependencies": {
27
+ "@ariaui/tokens": "0.2.0"
28
+ },
29
+ "peerDependenciesMeta": {
30
+ "@ariaui/tokens": {
31
+ "optional": true
32
+ }
33
+ },
34
+ "devDependencies": {
35
+ "@ariaui/tokens": "0.2.0"
36
+ },
37
+ "scripts": {
38
+ "build": "rimraf dist && tsup",
39
+ "dev": "rimraf dist && tsup --watch",
40
+ "lint": "eslint \"**/*.ts\"",
41
+ "clean": "rimraf node_modules && rimraf dist",
42
+ "test": "vitest run",
43
+ "test:watch": "vitest watch"
44
+ }
45
+ }