@refineui/utilities 0.0.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.
package/lib/index.js ADDED
@@ -0,0 +1,281 @@
1
+ // src/animation.ts
2
+ var motionDurations = {
3
+ // Resolve via `@refineui/tokens` CSS (Foundation → semanticInteraction roles)
4
+ instant: "var(--refineui-motion-duration-instant)",
5
+ fast: "var(--refineui-motion-duration-fast)",
6
+ normal: "var(--refineui-motion-duration-normal)",
7
+ slow: "var(--refineui-motion-duration-slow)",
8
+ toast: "var(--refineui-motion-duration-panel)"
9
+ };
10
+ var motionEasings = {
11
+ standard: "var(--refineui-motion-easing-standard)",
12
+ emphasized: "var(--refineui-motion-easing-emphasized)",
13
+ linear: "var(--refineui-motion-easing-linear)"
14
+ };
15
+ var motionPresets = {
16
+ fadeIn: { keyframes: "refineui-fade-in", duration: "normal", easing: "standard", fillMode: "both" },
17
+ fadeOut: { keyframes: "refineui-fade-out", duration: "normal", easing: "standard", fillMode: "both" },
18
+ fadeInUp: { keyframes: "refineui-fade-in-up", duration: "normal", easing: "standard", fillMode: "both" },
19
+ fadeInDown: { keyframes: "refineui-fade-in-down", duration: "normal", easing: "standard", fillMode: "both" },
20
+ scaleIn: { keyframes: "refineui-scale-in", duration: "normal", easing: "emphasized", fillMode: "both" },
21
+ scaleOut: { keyframes: "refineui-scale-out", duration: "normal", easing: "emphasized", fillMode: "both" }
22
+ };
23
+ function createAnimationStyle(options) {
24
+ const preset = motionPresets[options.preset];
25
+ const duration = options.duration ?? preset.duration;
26
+ const easing = options.easing ?? preset.easing;
27
+ if (options.reduceMotion) {
28
+ return {
29
+ animationName: "none",
30
+ animationDuration: motionDurations.instant,
31
+ animationDelay: "0ms"
32
+ };
33
+ }
34
+ return {
35
+ animationName: preset.keyframes,
36
+ animationDuration: typeof duration === "string" && duration in motionDurations ? motionDurations[duration] : duration,
37
+ animationTimingFunction: typeof easing === "string" && easing in motionEasings ? motionEasings[easing] : easing,
38
+ animationDelay: `${Math.max(0, options.delayMs ?? 0)}ms`,
39
+ animationIterationCount: options.iterationCount ?? 1,
40
+ animationDirection: options.direction ?? "normal",
41
+ animationPlayState: options.playState ?? "running",
42
+ animationFillMode: options.fillMode ?? preset.fillMode ?? "both"
43
+ };
44
+ }
45
+ function createTransitionStyle(options) {
46
+ const duration = options.duration ?? "fast";
47
+ const easing = options.easing ?? "standard";
48
+ const props = Array.isArray(options.properties) ? options.properties.join(", ") : options.properties;
49
+ if (options.reduceMotion) {
50
+ return {
51
+ transitionProperty: props,
52
+ transitionDuration: motionDurations.instant,
53
+ transitionTimingFunction: motionEasings.linear,
54
+ transitionDelay: "0ms"
55
+ };
56
+ }
57
+ return {
58
+ transitionProperty: props,
59
+ transitionDuration: typeof duration === "string" && duration in motionDurations ? motionDurations[duration] : duration,
60
+ transitionTimingFunction: typeof easing === "string" && easing in motionEasings ? motionEasings[easing] : easing,
61
+ transitionDelay: `${Math.max(0, options.delayMs ?? 0)}ms`
62
+ };
63
+ }
64
+ function getReducedMotionQuery() {
65
+ return "@media (prefers-reduced-motion: reduce)";
66
+ }
67
+ function motionMsToNumber(value) {
68
+ if (value.endsWith("ms")) return Number.parseFloat(value.slice(0, -2)) || 0;
69
+ if (value.endsWith("s")) return (Number.parseFloat(value.slice(0, -1)) || 0) * 1e3;
70
+ return Number.parseFloat(value) || 0;
71
+ }
72
+ var motionKeyframesCss = `
73
+ @keyframes refineui-fade-in {
74
+ from { opacity: 0; }
75
+ to { opacity: 1; }
76
+ }
77
+ @keyframes refineui-fade-out {
78
+ from { opacity: 1; }
79
+ to { opacity: 0; }
80
+ }
81
+ @keyframes refineui-fade-in-up {
82
+ from { opacity: 0; transform: translateY(4px); }
83
+ to { opacity: 1; transform: translateY(0); }
84
+ }
85
+ @keyframes refineui-fade-in-down {
86
+ from { opacity: 0; transform: translateY(-4px); }
87
+ to { opacity: 1; transform: translateY(0); }
88
+ }
89
+ @keyframes refineui-scale-in {
90
+ from { opacity: 0; transform: scale(0.98); }
91
+ to { opacity: 1; transform: scale(1); }
92
+ }
93
+ @keyframes refineui-scale-out {
94
+ from { opacity: 1; transform: scale(1); }
95
+ to { opacity: 0; transform: scale(0.98); }
96
+ }
97
+ `;
98
+
99
+ // src/color.ts
100
+ function toKebab(str) {
101
+ return str.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2").replace(/([a-zA-Z])(\d)/g, "$1-$2").toLowerCase();
102
+ }
103
+ function semanticColorToken(name) {
104
+ return { type: "semantic", name };
105
+ }
106
+ function paletteColorToken(name) {
107
+ return { type: "palette", name };
108
+ }
109
+ function semanticColorCssVar(name) {
110
+ return `var(--refineui-color-alias-${toKebab(name)})`;
111
+ }
112
+ function paletteColorCssVar(name) {
113
+ return `var(--refineui-color-${toKebab(name)})`;
114
+ }
115
+ function resolveColorToken(token) {
116
+ return token.type === "semantic" ? semanticColorCssVar(token.name) : paletteColorCssVar(token.name);
117
+ }
118
+ function isColorTokenRef(value) {
119
+ if (typeof value !== "object" || value === null) return false;
120
+ const candidate = value;
121
+ if (candidate.type !== "semantic" && candidate.type !== "palette") return false;
122
+ return typeof candidate.name === "string";
123
+ }
124
+ function resolveColorTokenValue(value) {
125
+ return typeof value === "string" ? value : resolveColorToken(value);
126
+ }
127
+ function hexToRgba(hex, alpha) {
128
+ const h = hex.replace("#", "");
129
+ const r = h.length === 3 ? parseInt(h[0] + h[0], 16) : parseInt(h.slice(0, 2), 16);
130
+ const g = h.length === 3 ? parseInt(h[1] + h[1], 16) : parseInt(h.slice(2, 4), 16);
131
+ const b = h.length === 3 ? parseInt(h[2] + h[2], 16) : parseInt(h.slice(4, 6), 16);
132
+ return `rgba(${r}, ${g}, ${b}, ${alpha})`;
133
+ }
134
+ function shadowWithColor(keyDim, ambientDim, keyColor, ambientColor) {
135
+ return `${keyDim} ${keyColor}, ${ambientDim} ${ambientColor}`;
136
+ }
137
+
138
+ // src/dom.ts
139
+ var dataAttr = (guard) => {
140
+ return guard ? "" : void 0;
141
+ };
142
+ var ariaAttr = (guard) => {
143
+ return guard ? "true" : void 0;
144
+ };
145
+ var elementProps = (props) => props;
146
+ var inputProps = (props) => props;
147
+ var labelProps = (props) => props;
148
+ var buttonProps = (props) => props;
149
+ var imgProps = (props) => props;
150
+
151
+ // src/bodyScrollLock.ts
152
+ var lockCount = 0;
153
+ var bodyOverflow = "";
154
+ var htmlOverflow = "";
155
+ var bodyPosition = "";
156
+ var bodyTop = "";
157
+ var bodyWidth = "";
158
+ var lockedScrollY = 0;
159
+ function applyLock() {
160
+ if (typeof document === "undefined") return;
161
+ lockedScrollY = window.scrollY;
162
+ bodyOverflow = document.body.style.overflow;
163
+ htmlOverflow = document.documentElement.style.overflow;
164
+ bodyPosition = document.body.style.position;
165
+ bodyTop = document.body.style.top;
166
+ bodyWidth = document.body.style.width;
167
+ document.body.style.overflow = "hidden";
168
+ document.documentElement.style.overflow = "hidden";
169
+ document.body.style.position = "fixed";
170
+ document.body.style.top = `-${lockedScrollY}px`;
171
+ document.body.style.width = "100%";
172
+ }
173
+ function releaseLock() {
174
+ if (typeof document === "undefined") return;
175
+ document.body.style.overflow = bodyOverflow;
176
+ document.documentElement.style.overflow = htmlOverflow;
177
+ document.body.style.position = bodyPosition;
178
+ document.body.style.top = bodyTop;
179
+ document.body.style.width = bodyWidth;
180
+ window.scrollTo(0, lockedScrollY);
181
+ }
182
+ function acquireBodyScrollLock() {
183
+ if (typeof document === "undefined") return () => {
184
+ };
185
+ lockCount += 1;
186
+ if (lockCount === 1) applyLock();
187
+ return () => {
188
+ lockCount -= 1;
189
+ if (lockCount <= 0) {
190
+ lockCount = 0;
191
+ releaseLock();
192
+ }
193
+ };
194
+ }
195
+
196
+ // src/composeRefs.ts
197
+ import * as React from "react";
198
+ function setRef(ref, value) {
199
+ if (typeof ref === "function") {
200
+ ref(value);
201
+ } else if (ref != null) {
202
+ ref.current = value;
203
+ }
204
+ }
205
+ function composeRefs(...refs) {
206
+ return (instance) => refs.forEach((ref) => setRef(ref, instance));
207
+ }
208
+ function useComposedRefs(...refs) {
209
+ return React.useCallback(composeRefs(...refs), refs);
210
+ }
211
+ var composeRef = composeRefs;
212
+
213
+ // src/mergeTriggerChild.ts
214
+ import { Children, Fragment, isValidElement } from "react";
215
+ function getMergeableTriggerChild(children) {
216
+ let node;
217
+ try {
218
+ node = Children.only(children);
219
+ } catch {
220
+ return null;
221
+ }
222
+ if (!isValidElement(node)) return null;
223
+ if (node.type === Fragment) {
224
+ const inner = Children.toArray(node.props.children);
225
+ if (inner.length !== 1 || !isValidElement(inner[0])) return null;
226
+ return inner[0];
227
+ }
228
+ return node;
229
+ }
230
+
231
+ // src/typography.ts
232
+ function semanticTextToken(name) {
233
+ return { type: "semantic-text", name };
234
+ }
235
+ function foundationTypographyToken(name) {
236
+ return { type: "foundation-typography", name };
237
+ }
238
+ function foundationTypographyUtilityClass(foundationKey) {
239
+ return `refineui-typo-${toKebab(foundationKey)}`;
240
+ }
241
+ function isSemanticTextTokenRef(value) {
242
+ if (typeof value !== "object" || value === null) return false;
243
+ const candidate = value;
244
+ return candidate.type === "semantic-text" && typeof candidate.name === "string";
245
+ }
246
+ export {
247
+ acquireBodyScrollLock,
248
+ ariaAttr,
249
+ buttonProps,
250
+ composeRef,
251
+ composeRefs,
252
+ createAnimationStyle,
253
+ createTransitionStyle,
254
+ dataAttr,
255
+ elementProps,
256
+ foundationTypographyToken,
257
+ foundationTypographyUtilityClass,
258
+ getMergeableTriggerChild,
259
+ getReducedMotionQuery,
260
+ hexToRgba,
261
+ imgProps,
262
+ inputProps,
263
+ isColorTokenRef,
264
+ isSemanticTextTokenRef,
265
+ labelProps,
266
+ motionDurations,
267
+ motionEasings,
268
+ motionKeyframesCss,
269
+ motionMsToNumber,
270
+ motionPresets,
271
+ paletteColorCssVar,
272
+ paletteColorToken,
273
+ resolveColorToken,
274
+ resolveColorTokenValue,
275
+ semanticColorCssVar,
276
+ semanticColorToken,
277
+ semanticTextToken,
278
+ shadowWithColor,
279
+ toKebab,
280
+ useComposedRefs
281
+ };
package/lib/react.cjs ADDED
@@ -0,0 +1,127 @@
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
+ // src/react.ts
31
+ var react_exports = {};
32
+ __export(react_exports, {
33
+ acquireBodyScrollLock: () => acquireBodyScrollLock,
34
+ composeRef: () => composeRef,
35
+ composeRefs: () => composeRefs,
36
+ getMergeableTriggerChild: () => getMergeableTriggerChild,
37
+ useComposedRefs: () => useComposedRefs
38
+ });
39
+ module.exports = __toCommonJS(react_exports);
40
+
41
+ // src/bodyScrollLock.ts
42
+ var lockCount = 0;
43
+ var bodyOverflow = "";
44
+ var htmlOverflow = "";
45
+ var bodyPosition = "";
46
+ var bodyTop = "";
47
+ var bodyWidth = "";
48
+ var lockedScrollY = 0;
49
+ function applyLock() {
50
+ if (typeof document === "undefined") return;
51
+ lockedScrollY = window.scrollY;
52
+ bodyOverflow = document.body.style.overflow;
53
+ htmlOverflow = document.documentElement.style.overflow;
54
+ bodyPosition = document.body.style.position;
55
+ bodyTop = document.body.style.top;
56
+ bodyWidth = document.body.style.width;
57
+ document.body.style.overflow = "hidden";
58
+ document.documentElement.style.overflow = "hidden";
59
+ document.body.style.position = "fixed";
60
+ document.body.style.top = `-${lockedScrollY}px`;
61
+ document.body.style.width = "100%";
62
+ }
63
+ function releaseLock() {
64
+ if (typeof document === "undefined") return;
65
+ document.body.style.overflow = bodyOverflow;
66
+ document.documentElement.style.overflow = htmlOverflow;
67
+ document.body.style.position = bodyPosition;
68
+ document.body.style.top = bodyTop;
69
+ document.body.style.width = bodyWidth;
70
+ window.scrollTo(0, lockedScrollY);
71
+ }
72
+ function acquireBodyScrollLock() {
73
+ if (typeof document === "undefined") return () => {
74
+ };
75
+ lockCount += 1;
76
+ if (lockCount === 1) applyLock();
77
+ return () => {
78
+ lockCount -= 1;
79
+ if (lockCount <= 0) {
80
+ lockCount = 0;
81
+ releaseLock();
82
+ }
83
+ };
84
+ }
85
+
86
+ // src/composeRefs.ts
87
+ var React = __toESM(require("react"), 1);
88
+ function setRef(ref, value) {
89
+ if (typeof ref === "function") {
90
+ ref(value);
91
+ } else if (ref != null) {
92
+ ref.current = value;
93
+ }
94
+ }
95
+ function composeRefs(...refs) {
96
+ return (instance) => refs.forEach((ref) => setRef(ref, instance));
97
+ }
98
+ function useComposedRefs(...refs) {
99
+ return React.useCallback(composeRefs(...refs), refs);
100
+ }
101
+ var composeRef = composeRefs;
102
+
103
+ // src/mergeTriggerChild.ts
104
+ var import_react = require("react");
105
+ function getMergeableTriggerChild(children) {
106
+ let node;
107
+ try {
108
+ node = import_react.Children.only(children);
109
+ } catch {
110
+ return null;
111
+ }
112
+ if (!(0, import_react.isValidElement)(node)) return null;
113
+ if (node.type === import_react.Fragment) {
114
+ const inner = import_react.Children.toArray(node.props.children);
115
+ if (inner.length !== 1 || !(0, import_react.isValidElement)(inner[0])) return null;
116
+ return inner[0];
117
+ }
118
+ return node;
119
+ }
120
+ // Annotate the CommonJS export names for ESM import in node:
121
+ 0 && (module.exports = {
122
+ acquireBodyScrollLock,
123
+ composeRef,
124
+ composeRefs,
125
+ getMergeableTriggerChild,
126
+ useComposedRefs
127
+ });
@@ -0,0 +1,27 @@
1
+ import { Ref, ReactNode, ReactElement } from 'react';
2
+
3
+ /**
4
+ * Root document scroll lock with ref-counting for nested overlays.
5
+ *
6
+ * Radix often uses `react-remove-scroll` with portals/focus scope.
7
+ * RefineUI locks only document `overflow`/`position` without extra dependencies.
8
+ */
9
+ /**
10
+ * Block background (document) scroll while menus/modals are open.
11
+ * @returns Release function — call on unmount/close
12
+ */
13
+ declare function acquireBodyScrollLock(): () => void;
14
+
15
+ declare function composeRefs<T>(...refs: (Ref<T> | undefined)[]): (instance: T | null) => void;
16
+ /** Radix `useComposedRefs` — stable ref callback when merging cloneElement + forwardRef */
17
+ declare function useComposedRefs<T>(...refs: (Ref<T> | undefined)[]): (instance: T | null) => void;
18
+ /** @deprecated Prefer `composeRefs` */
19
+ declare const composeRef: typeof composeRefs;
20
+
21
+ /**
22
+ * Resolve a single mergeable child so events/refs attach to one element.
23
+ * (Unwraps one Fragment layer; otherwise returns `null` — caller supplies a default button/span wrapper.)
24
+ */
25
+ declare function getMergeableTriggerChild(children: ReactNode): ReactElement | null;
26
+
27
+ export { acquireBodyScrollLock, composeRef, composeRefs, getMergeableTriggerChild, useComposedRefs };
package/lib/react.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import { Ref, ReactNode, ReactElement } from 'react';
2
+
3
+ /**
4
+ * Root document scroll lock with ref-counting for nested overlays.
5
+ *
6
+ * Radix often uses `react-remove-scroll` with portals/focus scope.
7
+ * RefineUI locks only document `overflow`/`position` without extra dependencies.
8
+ */
9
+ /**
10
+ * Block background (document) scroll while menus/modals are open.
11
+ * @returns Release function — call on unmount/close
12
+ */
13
+ declare function acquireBodyScrollLock(): () => void;
14
+
15
+ declare function composeRefs<T>(...refs: (Ref<T> | undefined)[]): (instance: T | null) => void;
16
+ /** Radix `useComposedRefs` — stable ref callback when merging cloneElement + forwardRef */
17
+ declare function useComposedRefs<T>(...refs: (Ref<T> | undefined)[]): (instance: T | null) => void;
18
+ /** @deprecated Prefer `composeRefs` */
19
+ declare const composeRef: typeof composeRefs;
20
+
21
+ /**
22
+ * Resolve a single mergeable child so events/refs attach to one element.
23
+ * (Unwraps one Fragment layer; otherwise returns `null` — caller supplies a default button/span wrapper.)
24
+ */
25
+ declare function getMergeableTriggerChild(children: ReactNode): ReactElement | null;
26
+
27
+ export { acquireBodyScrollLock, composeRef, composeRefs, getMergeableTriggerChild, useComposedRefs };
package/lib/react.js ADDED
@@ -0,0 +1,86 @@
1
+ // src/bodyScrollLock.ts
2
+ var lockCount = 0;
3
+ var bodyOverflow = "";
4
+ var htmlOverflow = "";
5
+ var bodyPosition = "";
6
+ var bodyTop = "";
7
+ var bodyWidth = "";
8
+ var lockedScrollY = 0;
9
+ function applyLock() {
10
+ if (typeof document === "undefined") return;
11
+ lockedScrollY = window.scrollY;
12
+ bodyOverflow = document.body.style.overflow;
13
+ htmlOverflow = document.documentElement.style.overflow;
14
+ bodyPosition = document.body.style.position;
15
+ bodyTop = document.body.style.top;
16
+ bodyWidth = document.body.style.width;
17
+ document.body.style.overflow = "hidden";
18
+ document.documentElement.style.overflow = "hidden";
19
+ document.body.style.position = "fixed";
20
+ document.body.style.top = `-${lockedScrollY}px`;
21
+ document.body.style.width = "100%";
22
+ }
23
+ function releaseLock() {
24
+ if (typeof document === "undefined") return;
25
+ document.body.style.overflow = bodyOverflow;
26
+ document.documentElement.style.overflow = htmlOverflow;
27
+ document.body.style.position = bodyPosition;
28
+ document.body.style.top = bodyTop;
29
+ document.body.style.width = bodyWidth;
30
+ window.scrollTo(0, lockedScrollY);
31
+ }
32
+ function acquireBodyScrollLock() {
33
+ if (typeof document === "undefined") return () => {
34
+ };
35
+ lockCount += 1;
36
+ if (lockCount === 1) applyLock();
37
+ return () => {
38
+ lockCount -= 1;
39
+ if (lockCount <= 0) {
40
+ lockCount = 0;
41
+ releaseLock();
42
+ }
43
+ };
44
+ }
45
+
46
+ // src/composeRefs.ts
47
+ import * as React from "react";
48
+ function setRef(ref, value) {
49
+ if (typeof ref === "function") {
50
+ ref(value);
51
+ } else if (ref != null) {
52
+ ref.current = value;
53
+ }
54
+ }
55
+ function composeRefs(...refs) {
56
+ return (instance) => refs.forEach((ref) => setRef(ref, instance));
57
+ }
58
+ function useComposedRefs(...refs) {
59
+ return React.useCallback(composeRefs(...refs), refs);
60
+ }
61
+ var composeRef = composeRefs;
62
+
63
+ // src/mergeTriggerChild.ts
64
+ import { Children, Fragment, isValidElement } from "react";
65
+ function getMergeableTriggerChild(children) {
66
+ let node;
67
+ try {
68
+ node = Children.only(children);
69
+ } catch {
70
+ return null;
71
+ }
72
+ if (!isValidElement(node)) return null;
73
+ if (node.type === Fragment) {
74
+ const inner = Children.toArray(node.props.children);
75
+ if (inner.length !== 1 || !isValidElement(inner[0])) return null;
76
+ return inner[0];
77
+ }
78
+ return node;
79
+ }
80
+ export {
81
+ acquireBodyScrollLock,
82
+ composeRef,
83
+ composeRefs,
84
+ getMergeableTriggerChild,
85
+ useComposedRefs
86
+ };
@@ -0,0 +1,56 @@
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
+ // src/typography.ts
21
+ var typography_exports = {};
22
+ __export(typography_exports, {
23
+ foundationTypographyToken: () => foundationTypographyToken,
24
+ foundationTypographyUtilityClass: () => foundationTypographyUtilityClass,
25
+ isSemanticTextTokenRef: () => isSemanticTextTokenRef,
26
+ semanticTextToken: () => semanticTextToken
27
+ });
28
+ module.exports = __toCommonJS(typography_exports);
29
+
30
+ // src/color.ts
31
+ function toKebab(str) {
32
+ return str.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2").replace(/([a-zA-Z])(\d)/g, "$1-$2").toLowerCase();
33
+ }
34
+
35
+ // src/typography.ts
36
+ function semanticTextToken(name) {
37
+ return { type: "semantic-text", name };
38
+ }
39
+ function foundationTypographyToken(name) {
40
+ return { type: "foundation-typography", name };
41
+ }
42
+ function foundationTypographyUtilityClass(foundationKey) {
43
+ return `refineui-typo-${toKebab(foundationKey)}`;
44
+ }
45
+ function isSemanticTextTokenRef(value) {
46
+ if (typeof value !== "object" || value === null) return false;
47
+ const candidate = value;
48
+ return candidate.type === "semantic-text" && typeof candidate.name === "string";
49
+ }
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ foundationTypographyToken,
53
+ foundationTypographyUtilityClass,
54
+ isSemanticTextTokenRef,
55
+ semanticTextToken
56
+ });
@@ -0,0 +1,15 @@
1
+ type SemanticTextTokenRef<TName extends string = string> = Readonly<{
2
+ type: "semantic-text";
3
+ name: TName;
4
+ }>;
5
+ type FoundationTypographyTokenRef<TName extends string = string> = Readonly<{
6
+ type: "foundation-typography";
7
+ name: TName;
8
+ }>;
9
+ declare function semanticTextToken<TName extends string>(name: TName): SemanticTextTokenRef<TName>;
10
+ declare function foundationTypographyToken<TName extends string>(name: TName): FoundationTypographyTokenRef<TName>;
11
+ /** Tailwind `@utility refineui-typo-*` class for a Foundation typography key (`body2`, `caption1`, …). */
12
+ declare function foundationTypographyUtilityClass(foundationKey: string): string;
13
+ declare function isSemanticTextTokenRef(value: unknown): value is SemanticTextTokenRef;
14
+
15
+ export { type FoundationTypographyTokenRef, type SemanticTextTokenRef, foundationTypographyToken, foundationTypographyUtilityClass, isSemanticTextTokenRef, semanticTextToken };
@@ -0,0 +1,15 @@
1
+ type SemanticTextTokenRef<TName extends string = string> = Readonly<{
2
+ type: "semantic-text";
3
+ name: TName;
4
+ }>;
5
+ type FoundationTypographyTokenRef<TName extends string = string> = Readonly<{
6
+ type: "foundation-typography";
7
+ name: TName;
8
+ }>;
9
+ declare function semanticTextToken<TName extends string>(name: TName): SemanticTextTokenRef<TName>;
10
+ declare function foundationTypographyToken<TName extends string>(name: TName): FoundationTypographyTokenRef<TName>;
11
+ /** Tailwind `@utility refineui-typo-*` class for a Foundation typography key (`body2`, `caption1`, …). */
12
+ declare function foundationTypographyUtilityClass(foundationKey: string): string;
13
+ declare function isSemanticTextTokenRef(value: unknown): value is SemanticTextTokenRef;
14
+
15
+ export { type FoundationTypographyTokenRef, type SemanticTextTokenRef, foundationTypographyToken, foundationTypographyUtilityClass, isSemanticTextTokenRef, semanticTextToken };
@@ -0,0 +1,26 @@
1
+ // src/color.ts
2
+ function toKebab(str) {
3
+ return str.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2").replace(/([a-zA-Z])(\d)/g, "$1-$2").toLowerCase();
4
+ }
5
+
6
+ // src/typography.ts
7
+ function semanticTextToken(name) {
8
+ return { type: "semantic-text", name };
9
+ }
10
+ function foundationTypographyToken(name) {
11
+ return { type: "foundation-typography", name };
12
+ }
13
+ function foundationTypographyUtilityClass(foundationKey) {
14
+ return `refineui-typo-${toKebab(foundationKey)}`;
15
+ }
16
+ function isSemanticTextTokenRef(value) {
17
+ if (typeof value !== "object" || value === null) return false;
18
+ const candidate = value;
19
+ return candidate.type === "semantic-text" && typeof candidate.name === "string";
20
+ }
21
+ export {
22
+ foundationTypographyToken,
23
+ foundationTypographyUtilityClass,
24
+ isSemanticTextTokenRef,
25
+ semanticTextToken
26
+ };