@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/animation.cjs +139 -0
- package/lib/animation.d.cts +54 -0
- package/lib/animation.d.ts +54 -0
- package/lib/animation.js +107 -0
- package/lib/color.cjs +84 -0
- package/lib/color.d.cts +27 -0
- package/lib/color.d.ts +27 -0
- package/lib/color.js +50 -0
- package/lib/index.cjs +351 -0
- package/lib/index.d.cts +132 -0
- package/lib/index.d.ts +132 -0
- package/lib/index.js +281 -0
- package/lib/react.cjs +127 -0
- package/lib/react.d.cts +27 -0
- package/lib/react.d.ts +27 -0
- package/lib/react.js +86 -0
- package/lib/typography.cjs +56 -0
- package/lib/typography.d.cts +15 -0
- package/lib/typography.d.ts +15 -0
- package/lib/typography.js +26 -0
- package/package.json +66 -0
|
@@ -0,0 +1,139 @@
|
|
|
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/animation.ts
|
|
21
|
+
var animation_exports = {};
|
|
22
|
+
__export(animation_exports, {
|
|
23
|
+
createAnimationStyle: () => createAnimationStyle,
|
|
24
|
+
createTransitionStyle: () => createTransitionStyle,
|
|
25
|
+
getReducedMotionQuery: () => getReducedMotionQuery,
|
|
26
|
+
motionDurations: () => motionDurations,
|
|
27
|
+
motionEasings: () => motionEasings,
|
|
28
|
+
motionKeyframesCss: () => motionKeyframesCss,
|
|
29
|
+
motionMsToNumber: () => motionMsToNumber,
|
|
30
|
+
motionPresets: () => motionPresets
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(animation_exports);
|
|
33
|
+
var motionDurations = {
|
|
34
|
+
// Resolve via `@refineui/tokens` CSS (Foundation → semanticInteraction roles)
|
|
35
|
+
instant: "var(--refineui-motion-duration-instant)",
|
|
36
|
+
fast: "var(--refineui-motion-duration-fast)",
|
|
37
|
+
normal: "var(--refineui-motion-duration-normal)",
|
|
38
|
+
slow: "var(--refineui-motion-duration-slow)",
|
|
39
|
+
toast: "var(--refineui-motion-duration-panel)"
|
|
40
|
+
};
|
|
41
|
+
var motionEasings = {
|
|
42
|
+
standard: "var(--refineui-motion-easing-standard)",
|
|
43
|
+
emphasized: "var(--refineui-motion-easing-emphasized)",
|
|
44
|
+
linear: "var(--refineui-motion-easing-linear)"
|
|
45
|
+
};
|
|
46
|
+
var motionPresets = {
|
|
47
|
+
fadeIn: { keyframes: "refineui-fade-in", duration: "normal", easing: "standard", fillMode: "both" },
|
|
48
|
+
fadeOut: { keyframes: "refineui-fade-out", duration: "normal", easing: "standard", fillMode: "both" },
|
|
49
|
+
fadeInUp: { keyframes: "refineui-fade-in-up", duration: "normal", easing: "standard", fillMode: "both" },
|
|
50
|
+
fadeInDown: { keyframes: "refineui-fade-in-down", duration: "normal", easing: "standard", fillMode: "both" },
|
|
51
|
+
scaleIn: { keyframes: "refineui-scale-in", duration: "normal", easing: "emphasized", fillMode: "both" },
|
|
52
|
+
scaleOut: { keyframes: "refineui-scale-out", duration: "normal", easing: "emphasized", fillMode: "both" }
|
|
53
|
+
};
|
|
54
|
+
function createAnimationStyle(options) {
|
|
55
|
+
const preset = motionPresets[options.preset];
|
|
56
|
+
const duration = options.duration ?? preset.duration;
|
|
57
|
+
const easing = options.easing ?? preset.easing;
|
|
58
|
+
if (options.reduceMotion) {
|
|
59
|
+
return {
|
|
60
|
+
animationName: "none",
|
|
61
|
+
animationDuration: motionDurations.instant,
|
|
62
|
+
animationDelay: "0ms"
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
animationName: preset.keyframes,
|
|
67
|
+
animationDuration: typeof duration === "string" && duration in motionDurations ? motionDurations[duration] : duration,
|
|
68
|
+
animationTimingFunction: typeof easing === "string" && easing in motionEasings ? motionEasings[easing] : easing,
|
|
69
|
+
animationDelay: `${Math.max(0, options.delayMs ?? 0)}ms`,
|
|
70
|
+
animationIterationCount: options.iterationCount ?? 1,
|
|
71
|
+
animationDirection: options.direction ?? "normal",
|
|
72
|
+
animationPlayState: options.playState ?? "running",
|
|
73
|
+
animationFillMode: options.fillMode ?? preset.fillMode ?? "both"
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function createTransitionStyle(options) {
|
|
77
|
+
const duration = options.duration ?? "fast";
|
|
78
|
+
const easing = options.easing ?? "standard";
|
|
79
|
+
const props = Array.isArray(options.properties) ? options.properties.join(", ") : options.properties;
|
|
80
|
+
if (options.reduceMotion) {
|
|
81
|
+
return {
|
|
82
|
+
transitionProperty: props,
|
|
83
|
+
transitionDuration: motionDurations.instant,
|
|
84
|
+
transitionTimingFunction: motionEasings.linear,
|
|
85
|
+
transitionDelay: "0ms"
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
transitionProperty: props,
|
|
90
|
+
transitionDuration: typeof duration === "string" && duration in motionDurations ? motionDurations[duration] : duration,
|
|
91
|
+
transitionTimingFunction: typeof easing === "string" && easing in motionEasings ? motionEasings[easing] : easing,
|
|
92
|
+
transitionDelay: `${Math.max(0, options.delayMs ?? 0)}ms`
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function getReducedMotionQuery() {
|
|
96
|
+
return "@media (prefers-reduced-motion: reduce)";
|
|
97
|
+
}
|
|
98
|
+
function motionMsToNumber(value) {
|
|
99
|
+
if (value.endsWith("ms")) return Number.parseFloat(value.slice(0, -2)) || 0;
|
|
100
|
+
if (value.endsWith("s")) return (Number.parseFloat(value.slice(0, -1)) || 0) * 1e3;
|
|
101
|
+
return Number.parseFloat(value) || 0;
|
|
102
|
+
}
|
|
103
|
+
var motionKeyframesCss = `
|
|
104
|
+
@keyframes refineui-fade-in {
|
|
105
|
+
from { opacity: 0; }
|
|
106
|
+
to { opacity: 1; }
|
|
107
|
+
}
|
|
108
|
+
@keyframes refineui-fade-out {
|
|
109
|
+
from { opacity: 1; }
|
|
110
|
+
to { opacity: 0; }
|
|
111
|
+
}
|
|
112
|
+
@keyframes refineui-fade-in-up {
|
|
113
|
+
from { opacity: 0; transform: translateY(4px); }
|
|
114
|
+
to { opacity: 1; transform: translateY(0); }
|
|
115
|
+
}
|
|
116
|
+
@keyframes refineui-fade-in-down {
|
|
117
|
+
from { opacity: 0; transform: translateY(-4px); }
|
|
118
|
+
to { opacity: 1; transform: translateY(0); }
|
|
119
|
+
}
|
|
120
|
+
@keyframes refineui-scale-in {
|
|
121
|
+
from { opacity: 0; transform: scale(0.98); }
|
|
122
|
+
to { opacity: 1; transform: scale(1); }
|
|
123
|
+
}
|
|
124
|
+
@keyframes refineui-scale-out {
|
|
125
|
+
from { opacity: 1; transform: scale(1); }
|
|
126
|
+
to { opacity: 0; transform: scale(0.98); }
|
|
127
|
+
}
|
|
128
|
+
`;
|
|
129
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
130
|
+
0 && (module.exports = {
|
|
131
|
+
createAnimationStyle,
|
|
132
|
+
createTransitionStyle,
|
|
133
|
+
getReducedMotionQuery,
|
|
134
|
+
motionDurations,
|
|
135
|
+
motionEasings,
|
|
136
|
+
motionKeyframesCss,
|
|
137
|
+
motionMsToNumber,
|
|
138
|
+
motionPresets
|
|
139
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
declare const motionDurations: {
|
|
4
|
+
readonly instant: "var(--refineui-motion-duration-instant)";
|
|
5
|
+
readonly fast: "var(--refineui-motion-duration-fast)";
|
|
6
|
+
readonly normal: "var(--refineui-motion-duration-normal)";
|
|
7
|
+
readonly slow: "var(--refineui-motion-duration-slow)";
|
|
8
|
+
readonly toast: "var(--refineui-motion-duration-panel)";
|
|
9
|
+
};
|
|
10
|
+
declare const motionEasings: {
|
|
11
|
+
readonly standard: "var(--refineui-motion-easing-standard)";
|
|
12
|
+
readonly emphasized: "var(--refineui-motion-easing-emphasized)";
|
|
13
|
+
readonly linear: "var(--refineui-motion-easing-linear)";
|
|
14
|
+
};
|
|
15
|
+
type MotionDuration = keyof typeof motionDurations;
|
|
16
|
+
type MotionEasing = keyof typeof motionEasings;
|
|
17
|
+
type MotionPresetName = "fadeIn" | "fadeOut" | "fadeInUp" | "fadeInDown" | "scaleIn" | "scaleOut";
|
|
18
|
+
type MotionPreset = Readonly<{
|
|
19
|
+
keyframes: string;
|
|
20
|
+
duration: MotionDuration;
|
|
21
|
+
easing: MotionEasing;
|
|
22
|
+
fillMode?: CSSProperties["animationFillMode"];
|
|
23
|
+
}>;
|
|
24
|
+
declare const motionPresets: Readonly<Record<MotionPresetName, MotionPreset>>;
|
|
25
|
+
type AnimationStyleOptions = Readonly<{
|
|
26
|
+
preset: MotionPresetName;
|
|
27
|
+
duration?: MotionDuration | string;
|
|
28
|
+
easing?: MotionEasing | string;
|
|
29
|
+
delayMs?: number;
|
|
30
|
+
iterationCount?: CSSProperties["animationIterationCount"];
|
|
31
|
+
direction?: CSSProperties["animationDirection"];
|
|
32
|
+
playState?: CSSProperties["animationPlayState"];
|
|
33
|
+
fillMode?: CSSProperties["animationFillMode"];
|
|
34
|
+
reduceMotion?: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
declare function createAnimationStyle(options: AnimationStyleOptions): CSSProperties;
|
|
37
|
+
type TransitionStyleOptions = Readonly<{
|
|
38
|
+
properties: string | readonly string[];
|
|
39
|
+
duration?: MotionDuration | string;
|
|
40
|
+
easing?: MotionEasing | string;
|
|
41
|
+
delayMs?: number;
|
|
42
|
+
reduceMotion?: boolean;
|
|
43
|
+
}>;
|
|
44
|
+
declare function createTransitionStyle(options: TransitionStyleOptions): CSSProperties;
|
|
45
|
+
declare function getReducedMotionQuery(): string;
|
|
46
|
+
/** "180ms" -> 180 */
|
|
47
|
+
declare function motionMsToNumber(value: string): number;
|
|
48
|
+
/**
|
|
49
|
+
* Optional CSS you can include once in a global stylesheet.
|
|
50
|
+
* If you use `createAnimationStyle`, ensure these keyframes exist.
|
|
51
|
+
*/
|
|
52
|
+
declare const motionKeyframesCss = "\n@keyframes refineui-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n@keyframes refineui-fade-out {\n from { opacity: 1; }\n to { opacity: 0; }\n}\n@keyframes refineui-fade-in-up {\n from { opacity: 0; transform: translateY(4px); }\n to { opacity: 1; transform: translateY(0); }\n}\n@keyframes refineui-fade-in-down {\n from { opacity: 0; transform: translateY(-4px); }\n to { opacity: 1; transform: translateY(0); }\n}\n@keyframes refineui-scale-in {\n from { opacity: 0; transform: scale(0.98); }\n to { opacity: 1; transform: scale(1); }\n}\n@keyframes refineui-scale-out {\n from { opacity: 1; transform: scale(1); }\n to { opacity: 0; transform: scale(0.98); }\n}\n";
|
|
53
|
+
|
|
54
|
+
export { type AnimationStyleOptions, type MotionDuration, type MotionEasing, type MotionPresetName, type TransitionStyleOptions, createAnimationStyle, createTransitionStyle, getReducedMotionQuery, motionDurations, motionEasings, motionKeyframesCss, motionMsToNumber, motionPresets };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
declare const motionDurations: {
|
|
4
|
+
readonly instant: "var(--refineui-motion-duration-instant)";
|
|
5
|
+
readonly fast: "var(--refineui-motion-duration-fast)";
|
|
6
|
+
readonly normal: "var(--refineui-motion-duration-normal)";
|
|
7
|
+
readonly slow: "var(--refineui-motion-duration-slow)";
|
|
8
|
+
readonly toast: "var(--refineui-motion-duration-panel)";
|
|
9
|
+
};
|
|
10
|
+
declare const motionEasings: {
|
|
11
|
+
readonly standard: "var(--refineui-motion-easing-standard)";
|
|
12
|
+
readonly emphasized: "var(--refineui-motion-easing-emphasized)";
|
|
13
|
+
readonly linear: "var(--refineui-motion-easing-linear)";
|
|
14
|
+
};
|
|
15
|
+
type MotionDuration = keyof typeof motionDurations;
|
|
16
|
+
type MotionEasing = keyof typeof motionEasings;
|
|
17
|
+
type MotionPresetName = "fadeIn" | "fadeOut" | "fadeInUp" | "fadeInDown" | "scaleIn" | "scaleOut";
|
|
18
|
+
type MotionPreset = Readonly<{
|
|
19
|
+
keyframes: string;
|
|
20
|
+
duration: MotionDuration;
|
|
21
|
+
easing: MotionEasing;
|
|
22
|
+
fillMode?: CSSProperties["animationFillMode"];
|
|
23
|
+
}>;
|
|
24
|
+
declare const motionPresets: Readonly<Record<MotionPresetName, MotionPreset>>;
|
|
25
|
+
type AnimationStyleOptions = Readonly<{
|
|
26
|
+
preset: MotionPresetName;
|
|
27
|
+
duration?: MotionDuration | string;
|
|
28
|
+
easing?: MotionEasing | string;
|
|
29
|
+
delayMs?: number;
|
|
30
|
+
iterationCount?: CSSProperties["animationIterationCount"];
|
|
31
|
+
direction?: CSSProperties["animationDirection"];
|
|
32
|
+
playState?: CSSProperties["animationPlayState"];
|
|
33
|
+
fillMode?: CSSProperties["animationFillMode"];
|
|
34
|
+
reduceMotion?: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
declare function createAnimationStyle(options: AnimationStyleOptions): CSSProperties;
|
|
37
|
+
type TransitionStyleOptions = Readonly<{
|
|
38
|
+
properties: string | readonly string[];
|
|
39
|
+
duration?: MotionDuration | string;
|
|
40
|
+
easing?: MotionEasing | string;
|
|
41
|
+
delayMs?: number;
|
|
42
|
+
reduceMotion?: boolean;
|
|
43
|
+
}>;
|
|
44
|
+
declare function createTransitionStyle(options: TransitionStyleOptions): CSSProperties;
|
|
45
|
+
declare function getReducedMotionQuery(): string;
|
|
46
|
+
/** "180ms" -> 180 */
|
|
47
|
+
declare function motionMsToNumber(value: string): number;
|
|
48
|
+
/**
|
|
49
|
+
* Optional CSS you can include once in a global stylesheet.
|
|
50
|
+
* If you use `createAnimationStyle`, ensure these keyframes exist.
|
|
51
|
+
*/
|
|
52
|
+
declare const motionKeyframesCss = "\n@keyframes refineui-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n@keyframes refineui-fade-out {\n from { opacity: 1; }\n to { opacity: 0; }\n}\n@keyframes refineui-fade-in-up {\n from { opacity: 0; transform: translateY(4px); }\n to { opacity: 1; transform: translateY(0); }\n}\n@keyframes refineui-fade-in-down {\n from { opacity: 0; transform: translateY(-4px); }\n to { opacity: 1; transform: translateY(0); }\n}\n@keyframes refineui-scale-in {\n from { opacity: 0; transform: scale(0.98); }\n to { opacity: 1; transform: scale(1); }\n}\n@keyframes refineui-scale-out {\n from { opacity: 1; transform: scale(1); }\n to { opacity: 0; transform: scale(0.98); }\n}\n";
|
|
53
|
+
|
|
54
|
+
export { type AnimationStyleOptions, type MotionDuration, type MotionEasing, type MotionPresetName, type TransitionStyleOptions, createAnimationStyle, createTransitionStyle, getReducedMotionQuery, motionDurations, motionEasings, motionKeyframesCss, motionMsToNumber, motionPresets };
|
package/lib/animation.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
export {
|
|
99
|
+
createAnimationStyle,
|
|
100
|
+
createTransitionStyle,
|
|
101
|
+
getReducedMotionQuery,
|
|
102
|
+
motionDurations,
|
|
103
|
+
motionEasings,
|
|
104
|
+
motionKeyframesCss,
|
|
105
|
+
motionMsToNumber,
|
|
106
|
+
motionPresets
|
|
107
|
+
};
|
package/lib/color.cjs
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
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/color.ts
|
|
21
|
+
var color_exports = {};
|
|
22
|
+
__export(color_exports, {
|
|
23
|
+
hexToRgba: () => hexToRgba,
|
|
24
|
+
isColorTokenRef: () => isColorTokenRef,
|
|
25
|
+
paletteColorCssVar: () => paletteColorCssVar,
|
|
26
|
+
paletteColorToken: () => paletteColorToken,
|
|
27
|
+
resolveColorToken: () => resolveColorToken,
|
|
28
|
+
resolveColorTokenValue: () => resolveColorTokenValue,
|
|
29
|
+
semanticColorCssVar: () => semanticColorCssVar,
|
|
30
|
+
semanticColorToken: () => semanticColorToken,
|
|
31
|
+
shadowWithColor: () => shadowWithColor,
|
|
32
|
+
toKebab: () => toKebab
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(color_exports);
|
|
35
|
+
function toKebab(str) {
|
|
36
|
+
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();
|
|
37
|
+
}
|
|
38
|
+
function semanticColorToken(name) {
|
|
39
|
+
return { type: "semantic", name };
|
|
40
|
+
}
|
|
41
|
+
function paletteColorToken(name) {
|
|
42
|
+
return { type: "palette", name };
|
|
43
|
+
}
|
|
44
|
+
function semanticColorCssVar(name) {
|
|
45
|
+
return `var(--refineui-color-alias-${toKebab(name)})`;
|
|
46
|
+
}
|
|
47
|
+
function paletteColorCssVar(name) {
|
|
48
|
+
return `var(--refineui-color-${toKebab(name)})`;
|
|
49
|
+
}
|
|
50
|
+
function resolveColorToken(token) {
|
|
51
|
+
return token.type === "semantic" ? semanticColorCssVar(token.name) : paletteColorCssVar(token.name);
|
|
52
|
+
}
|
|
53
|
+
function isColorTokenRef(value) {
|
|
54
|
+
if (typeof value !== "object" || value === null) return false;
|
|
55
|
+
const candidate = value;
|
|
56
|
+
if (candidate.type !== "semantic" && candidate.type !== "palette") return false;
|
|
57
|
+
return typeof candidate.name === "string";
|
|
58
|
+
}
|
|
59
|
+
function resolveColorTokenValue(value) {
|
|
60
|
+
return typeof value === "string" ? value : resolveColorToken(value);
|
|
61
|
+
}
|
|
62
|
+
function hexToRgba(hex, alpha) {
|
|
63
|
+
const h = hex.replace("#", "");
|
|
64
|
+
const r = h.length === 3 ? parseInt(h[0] + h[0], 16) : parseInt(h.slice(0, 2), 16);
|
|
65
|
+
const g = h.length === 3 ? parseInt(h[1] + h[1], 16) : parseInt(h.slice(2, 4), 16);
|
|
66
|
+
const b = h.length === 3 ? parseInt(h[2] + h[2], 16) : parseInt(h.slice(4, 6), 16);
|
|
67
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
68
|
+
}
|
|
69
|
+
function shadowWithColor(keyDim, ambientDim, keyColor, ambientColor) {
|
|
70
|
+
return `${keyDim} ${keyColor}, ${ambientDim} ${ambientColor}`;
|
|
71
|
+
}
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
hexToRgba,
|
|
75
|
+
isColorTokenRef,
|
|
76
|
+
paletteColorCssVar,
|
|
77
|
+
paletteColorToken,
|
|
78
|
+
resolveColorToken,
|
|
79
|
+
resolveColorTokenValue,
|
|
80
|
+
semanticColorCssVar,
|
|
81
|
+
semanticColorToken,
|
|
82
|
+
shadowWithColor,
|
|
83
|
+
toKebab
|
|
84
|
+
});
|
package/lib/color.d.cts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type SemanticColorTokenRef<TName extends string = string> = Readonly<{
|
|
2
|
+
type: "semantic";
|
|
3
|
+
name: TName;
|
|
4
|
+
}>;
|
|
5
|
+
type PaletteColorTokenRef<TName extends string = string> = Readonly<{
|
|
6
|
+
type: "palette";
|
|
7
|
+
name: TName;
|
|
8
|
+
}>;
|
|
9
|
+
type ColorTokenRef = SemanticColorTokenRef | PaletteColorTokenRef;
|
|
10
|
+
type ColorTokenValue = ColorTokenRef | string;
|
|
11
|
+
declare function toKebab(str: string): string;
|
|
12
|
+
declare function semanticColorToken<TName extends string>(name: TName): SemanticColorTokenRef<TName>;
|
|
13
|
+
declare function paletteColorToken<TName extends string>(name: TName): PaletteColorTokenRef<TName>;
|
|
14
|
+
declare function semanticColorCssVar(name: string): string;
|
|
15
|
+
declare function paletteColorCssVar(name: string): string;
|
|
16
|
+
declare function resolveColorToken(token: ColorTokenRef): string;
|
|
17
|
+
declare function isColorTokenRef(value: unknown): value is ColorTokenRef;
|
|
18
|
+
declare function resolveColorTokenValue<T extends string>(value: T): T;
|
|
19
|
+
declare function resolveColorTokenValue(value: ColorTokenRef): string;
|
|
20
|
+
/**
|
|
21
|
+
* Convert hex to rgba (e.g. palette colors)
|
|
22
|
+
*/
|
|
23
|
+
declare function hexToRgba(hex: string, alpha: number): string;
|
|
24
|
+
/** Build a box-shadow string from dimensions (x y blur spread) + colors */
|
|
25
|
+
declare function shadowWithColor(keyDim: string, ambientDim: string, keyColor: string, ambientColor: string): string;
|
|
26
|
+
|
|
27
|
+
export { type ColorTokenRef, type ColorTokenValue, type PaletteColorTokenRef, type SemanticColorTokenRef, hexToRgba, isColorTokenRef, paletteColorCssVar, paletteColorToken, resolveColorToken, resolveColorTokenValue, semanticColorCssVar, semanticColorToken, shadowWithColor, toKebab };
|
package/lib/color.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type SemanticColorTokenRef<TName extends string = string> = Readonly<{
|
|
2
|
+
type: "semantic";
|
|
3
|
+
name: TName;
|
|
4
|
+
}>;
|
|
5
|
+
type PaletteColorTokenRef<TName extends string = string> = Readonly<{
|
|
6
|
+
type: "palette";
|
|
7
|
+
name: TName;
|
|
8
|
+
}>;
|
|
9
|
+
type ColorTokenRef = SemanticColorTokenRef | PaletteColorTokenRef;
|
|
10
|
+
type ColorTokenValue = ColorTokenRef | string;
|
|
11
|
+
declare function toKebab(str: string): string;
|
|
12
|
+
declare function semanticColorToken<TName extends string>(name: TName): SemanticColorTokenRef<TName>;
|
|
13
|
+
declare function paletteColorToken<TName extends string>(name: TName): PaletteColorTokenRef<TName>;
|
|
14
|
+
declare function semanticColorCssVar(name: string): string;
|
|
15
|
+
declare function paletteColorCssVar(name: string): string;
|
|
16
|
+
declare function resolveColorToken(token: ColorTokenRef): string;
|
|
17
|
+
declare function isColorTokenRef(value: unknown): value is ColorTokenRef;
|
|
18
|
+
declare function resolveColorTokenValue<T extends string>(value: T): T;
|
|
19
|
+
declare function resolveColorTokenValue(value: ColorTokenRef): string;
|
|
20
|
+
/**
|
|
21
|
+
* Convert hex to rgba (e.g. palette colors)
|
|
22
|
+
*/
|
|
23
|
+
declare function hexToRgba(hex: string, alpha: number): string;
|
|
24
|
+
/** Build a box-shadow string from dimensions (x y blur spread) + colors */
|
|
25
|
+
declare function shadowWithColor(keyDim: string, ambientDim: string, keyColor: string, ambientColor: string): string;
|
|
26
|
+
|
|
27
|
+
export { type ColorTokenRef, type ColorTokenValue, type PaletteColorTokenRef, type SemanticColorTokenRef, hexToRgba, isColorTokenRef, paletteColorCssVar, paletteColorToken, resolveColorToken, resolveColorTokenValue, semanticColorCssVar, semanticColorToken, shadowWithColor, toKebab };
|
package/lib/color.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
function semanticColorToken(name) {
|
|
6
|
+
return { type: "semantic", name };
|
|
7
|
+
}
|
|
8
|
+
function paletteColorToken(name) {
|
|
9
|
+
return { type: "palette", name };
|
|
10
|
+
}
|
|
11
|
+
function semanticColorCssVar(name) {
|
|
12
|
+
return `var(--refineui-color-alias-${toKebab(name)})`;
|
|
13
|
+
}
|
|
14
|
+
function paletteColorCssVar(name) {
|
|
15
|
+
return `var(--refineui-color-${toKebab(name)})`;
|
|
16
|
+
}
|
|
17
|
+
function resolveColorToken(token) {
|
|
18
|
+
return token.type === "semantic" ? semanticColorCssVar(token.name) : paletteColorCssVar(token.name);
|
|
19
|
+
}
|
|
20
|
+
function isColorTokenRef(value) {
|
|
21
|
+
if (typeof value !== "object" || value === null) return false;
|
|
22
|
+
const candidate = value;
|
|
23
|
+
if (candidate.type !== "semantic" && candidate.type !== "palette") return false;
|
|
24
|
+
return typeof candidate.name === "string";
|
|
25
|
+
}
|
|
26
|
+
function resolveColorTokenValue(value) {
|
|
27
|
+
return typeof value === "string" ? value : resolveColorToken(value);
|
|
28
|
+
}
|
|
29
|
+
function hexToRgba(hex, alpha) {
|
|
30
|
+
const h = hex.replace("#", "");
|
|
31
|
+
const r = h.length === 3 ? parseInt(h[0] + h[0], 16) : parseInt(h.slice(0, 2), 16);
|
|
32
|
+
const g = h.length === 3 ? parseInt(h[1] + h[1], 16) : parseInt(h.slice(2, 4), 16);
|
|
33
|
+
const b = h.length === 3 ? parseInt(h[2] + h[2], 16) : parseInt(h.slice(4, 6), 16);
|
|
34
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
35
|
+
}
|
|
36
|
+
function shadowWithColor(keyDim, ambientDim, keyColor, ambientColor) {
|
|
37
|
+
return `${keyDim} ${keyColor}, ${ambientDim} ${ambientColor}`;
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
hexToRgba,
|
|
41
|
+
isColorTokenRef,
|
|
42
|
+
paletteColorCssVar,
|
|
43
|
+
paletteColorToken,
|
|
44
|
+
resolveColorToken,
|
|
45
|
+
resolveColorTokenValue,
|
|
46
|
+
semanticColorCssVar,
|
|
47
|
+
semanticColorToken,
|
|
48
|
+
shadowWithColor,
|
|
49
|
+
toKebab
|
|
50
|
+
};
|