@work-rjkashyap/unified-ui 0.1.0
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/CHANGELOG.md +152 -0
- package/README.md +365 -0
- package/dist/chunk-2JFREULQ.cjs +29 -0
- package/dist/chunk-2RGLRX6K.cjs +279 -0
- package/dist/chunk-3HHJAYQI.cjs +469 -0
- package/dist/chunk-5S5DMH5G.cjs +5983 -0
- package/dist/chunk-BIW2RPDU.cjs +73 -0
- package/dist/chunk-CWETOWRM.mjs +456 -0
- package/dist/chunk-ECIGDEAH.cjs +140 -0
- package/dist/chunk-EO4WROWH.mjs +432 -0
- package/dist/chunk-EZ2L3XPS.mjs +83 -0
- package/dist/chunk-I74E52C5.mjs +271 -0
- package/dist/chunk-ITBG42M5.mjs +133 -0
- package/dist/chunk-IWJ5VMZ7.mjs +323 -0
- package/dist/chunk-KHON2AEM.cjs +342 -0
- package/dist/chunk-LSNKPQP7.cjs +58 -0
- package/dist/chunk-M2LNQWOB.mjs +63 -0
- package/dist/chunk-NMPHV6ZD.mjs +27 -0
- package/dist/chunk-QXR4VY7Q.cjs +268 -0
- package/dist/chunk-SSGN5QDC.mjs +248 -0
- package/dist/chunk-X2WCY4VB.mjs +5836 -0
- package/dist/chunk-XCKK6P46.cjs +91 -0
- package/dist/chunk-ZBN26FLO.mjs +46 -0
- package/dist/chunk-ZPIPKY2J.cjs +478 -0
- package/dist/components.cjs +477 -0
- package/dist/components.d.cts +3077 -0
- package/dist/components.d.ts +3077 -0
- package/dist/components.mjs +4 -0
- package/dist/index.cjs +1027 -0
- package/dist/index.d.cts +30 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.mjs +17 -0
- package/dist/motion-D9wQbcKL.d.cts +80 -0
- package/dist/motion-D9wQbcKL.d.ts +80 -0
- package/dist/motion.cjs +216 -0
- package/dist/motion.d.cts +104 -0
- package/dist/motion.d.ts +104 -0
- package/dist/motion.mjs +3 -0
- package/dist/primitives.cjs +57 -0
- package/dist/primitives.d.cts +390 -0
- package/dist/primitives.d.ts +390 -0
- package/dist/primitives.mjs +4 -0
- package/dist/theme.cjs +38 -0
- package/dist/theme.d.cts +117 -0
- package/dist/theme.d.ts +117 -0
- package/dist/theme.mjs +5 -0
- package/dist/tokens.cjs +137 -0
- package/dist/tokens.d.cts +30 -0
- package/dist/tokens.d.ts +30 -0
- package/dist/tokens.mjs +4 -0
- package/dist/typography-DlvVjEdE.d.cts +146 -0
- package/dist/typography-DlvVjEdE.d.ts +146 -0
- package/dist/utils.cjs +164 -0
- package/dist/utils.d.cts +521 -0
- package/dist/utils.d.ts +521 -0
- package/dist/utils.mjs +3 -0
- package/dist/z-index-B_nTQ3qo.d.cts +422 -0
- package/dist/z-index-B_nTQ3qo.d.ts +422 -0
- package/package.json +183 -0
- package/styles.css +500 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkKHON2AEM_cjs = require('./chunk-KHON2AEM.cjs');
|
|
4
|
+
var chunkECIGDEAH_cjs = require('./chunk-ECIGDEAH.cjs');
|
|
5
|
+
var chunkXCKK6P46_cjs = require('./chunk-XCKK6P46.cjs');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
|
|
9
|
+
// src/theme/contract.ts
|
|
10
|
+
var PREFIX = "--ds";
|
|
11
|
+
var colorVarNames = {
|
|
12
|
+
background: `${PREFIX}-color-background`,
|
|
13
|
+
foreground: `${PREFIX}-color-foreground`,
|
|
14
|
+
surface: `${PREFIX}-color-surface`,
|
|
15
|
+
surfaceRaised: `${PREFIX}-color-surface-raised`,
|
|
16
|
+
surfaceOverlay: `${PREFIX}-color-surface-overlay`,
|
|
17
|
+
muted: `${PREFIX}-color-muted`,
|
|
18
|
+
mutedForeground: `${PREFIX}-color-muted-foreground`,
|
|
19
|
+
primary: `${PREFIX}-color-primary`,
|
|
20
|
+
primaryForeground: `${PREFIX}-color-primary-foreground`,
|
|
21
|
+
primaryHover: `${PREFIX}-color-primary-hover`,
|
|
22
|
+
primaryActive: `${PREFIX}-color-primary-active`,
|
|
23
|
+
primaryMuted: `${PREFIX}-color-primary-muted`,
|
|
24
|
+
primaryMutedForeground: `${PREFIX}-color-primary-muted-foreground`,
|
|
25
|
+
secondary: `${PREFIX}-color-secondary`,
|
|
26
|
+
secondaryForeground: `${PREFIX}-color-secondary-foreground`,
|
|
27
|
+
secondaryHover: `${PREFIX}-color-secondary-hover`,
|
|
28
|
+
secondaryActive: `${PREFIX}-color-secondary-active`,
|
|
29
|
+
success: `${PREFIX}-color-success`,
|
|
30
|
+
successForeground: `${PREFIX}-color-success-foreground`,
|
|
31
|
+
successMuted: `${PREFIX}-color-success-muted`,
|
|
32
|
+
successMutedForeground: `${PREFIX}-color-success-muted-foreground`,
|
|
33
|
+
warning: `${PREFIX}-color-warning`,
|
|
34
|
+
warningForeground: `${PREFIX}-color-warning-foreground`,
|
|
35
|
+
warningMuted: `${PREFIX}-color-warning-muted`,
|
|
36
|
+
warningMutedForeground: `${PREFIX}-color-warning-muted-foreground`,
|
|
37
|
+
danger: `${PREFIX}-color-danger`,
|
|
38
|
+
dangerForeground: `${PREFIX}-color-danger-foreground`,
|
|
39
|
+
dangerHover: `${PREFIX}-color-danger-hover`,
|
|
40
|
+
dangerActive: `${PREFIX}-color-danger-active`,
|
|
41
|
+
dangerMuted: `${PREFIX}-color-danger-muted`,
|
|
42
|
+
dangerMutedForeground: `${PREFIX}-color-danger-muted-foreground`,
|
|
43
|
+
info: `${PREFIX}-color-info`,
|
|
44
|
+
infoForeground: `${PREFIX}-color-info-foreground`,
|
|
45
|
+
infoMuted: `${PREFIX}-color-info-muted`,
|
|
46
|
+
infoMutedForeground: `${PREFIX}-color-info-muted-foreground`,
|
|
47
|
+
border: `${PREFIX}-color-border`,
|
|
48
|
+
borderMuted: `${PREFIX}-color-border-muted`,
|
|
49
|
+
borderStrong: `${PREFIX}-color-border-strong`,
|
|
50
|
+
focusRing: `${PREFIX}-color-focus-ring`,
|
|
51
|
+
input: `${PREFIX}-color-input`,
|
|
52
|
+
inputForeground: `${PREFIX}-color-input-foreground`,
|
|
53
|
+
inputPlaceholder: `${PREFIX}-color-input-placeholder`,
|
|
54
|
+
disabled: `${PREFIX}-color-disabled`,
|
|
55
|
+
disabledForeground: `${PREFIX}-color-disabled-foreground`
|
|
56
|
+
};
|
|
57
|
+
var radiusVarNames = {
|
|
58
|
+
none: `${PREFIX}-radius-none`,
|
|
59
|
+
sm: `${PREFIX}-radius-sm`,
|
|
60
|
+
md: `${PREFIX}-radius-md`,
|
|
61
|
+
lg: `${PREFIX}-radius-lg`,
|
|
62
|
+
xl: `${PREFIX}-radius-xl`,
|
|
63
|
+
full: `${PREFIX}-radius-full`
|
|
64
|
+
};
|
|
65
|
+
var shadowVarNames = {
|
|
66
|
+
none: `${PREFIX}-shadow-none`,
|
|
67
|
+
xs: `${PREFIX}-shadow-xs`,
|
|
68
|
+
sm: `${PREFIX}-shadow-sm`,
|
|
69
|
+
md: `${PREFIX}-shadow-md`,
|
|
70
|
+
lg: `${PREFIX}-shadow-lg`,
|
|
71
|
+
xl: `${PREFIX}-shadow-xl`,
|
|
72
|
+
"2xl": `${PREFIX}-shadow-2xl`,
|
|
73
|
+
focusRing: `${PREFIX}-shadow-focus-ring`
|
|
74
|
+
};
|
|
75
|
+
var zIndexVarNames = {
|
|
76
|
+
base: `${PREFIX}-z-base`,
|
|
77
|
+
dropdown: `${PREFIX}-z-dropdown`,
|
|
78
|
+
sticky: `${PREFIX}-z-sticky`,
|
|
79
|
+
overlay: `${PREFIX}-z-overlay`,
|
|
80
|
+
modal: `${PREFIX}-z-modal`,
|
|
81
|
+
popover: `${PREFIX}-z-popover`,
|
|
82
|
+
toast: `${PREFIX}-z-toast`,
|
|
83
|
+
tooltip: `${PREFIX}-z-tooltip`,
|
|
84
|
+
max: `${PREFIX}-z-max`
|
|
85
|
+
};
|
|
86
|
+
var durationVarNames = {
|
|
87
|
+
instant: `${PREFIX}-duration-instant`,
|
|
88
|
+
fast: `${PREFIX}-duration-fast`,
|
|
89
|
+
moderate: `${PREFIX}-duration-moderate`,
|
|
90
|
+
normal: `${PREFIX}-duration-normal`,
|
|
91
|
+
slow: `${PREFIX}-duration-slow`,
|
|
92
|
+
slower: `${PREFIX}-duration-slower`,
|
|
93
|
+
slowest: `${PREFIX}-duration-slowest`
|
|
94
|
+
};
|
|
95
|
+
var easingVarNames = {
|
|
96
|
+
standard: `${PREFIX}-easing-standard`,
|
|
97
|
+
decelerate: `${PREFIX}-easing-decelerate`,
|
|
98
|
+
accelerate: `${PREFIX}-easing-accelerate`,
|
|
99
|
+
emphasize: `${PREFIX}-easing-emphasize`,
|
|
100
|
+
linear: `${PREFIX}-easing-linear`,
|
|
101
|
+
snap: `${PREFIX}-easing-snap`
|
|
102
|
+
};
|
|
103
|
+
var fontFamilyVarNames = {
|
|
104
|
+
display: `${PREFIX}-font-display`,
|
|
105
|
+
sans: `${PREFIX}-font-sans`,
|
|
106
|
+
serif: `${PREFIX}-font-serif`,
|
|
107
|
+
mono: `${PREFIX}-font-mono`,
|
|
108
|
+
inherit: `${PREFIX}-font-inherit`
|
|
109
|
+
};
|
|
110
|
+
function mapRecord(varNames, values) {
|
|
111
|
+
const result = {};
|
|
112
|
+
for (const key of Object.keys(varNames)) {
|
|
113
|
+
result[varNames[key]] = values[key];
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
function buildLightThemeVars() {
|
|
118
|
+
return {
|
|
119
|
+
...mapRecord(colorVarNames, chunkKHON2AEM_cjs.semanticLight),
|
|
120
|
+
...mapRecord(radiusVarNames, chunkKHON2AEM_cjs.radius),
|
|
121
|
+
...mapRecord(shadowVarNames, chunkKHON2AEM_cjs.shadow),
|
|
122
|
+
...mapRecord(zIndexVarNames, chunkKHON2AEM_cjs.zIndex),
|
|
123
|
+
...mapRecord(durationVarNames, chunkXCKK6P46_cjs.durationCSS),
|
|
124
|
+
...mapRecord(easingVarNames, chunkXCKK6P46_cjs.easingCSS),
|
|
125
|
+
...mapRecord(fontFamilyVarNames, chunkECIGDEAH_cjs.fontFamily)
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function buildDarkThemeVars() {
|
|
129
|
+
return {
|
|
130
|
+
...mapRecord(colorVarNames, chunkKHON2AEM_cjs.semanticDark),
|
|
131
|
+
...mapRecord(radiusVarNames, chunkKHON2AEM_cjs.radius),
|
|
132
|
+
...mapRecord(shadowVarNames, chunkKHON2AEM_cjs.shadowDark),
|
|
133
|
+
...mapRecord(zIndexVarNames, chunkKHON2AEM_cjs.zIndex),
|
|
134
|
+
...mapRecord(durationVarNames, chunkXCKK6P46_cjs.durationCSS),
|
|
135
|
+
...mapRecord(easingVarNames, chunkXCKK6P46_cjs.easingCSS),
|
|
136
|
+
...mapRecord(fontFamilyVarNames, chunkECIGDEAH_cjs.fontFamily)
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function varsToCSS(vars) {
|
|
140
|
+
return Object.entries(vars).map(([prop, value]) => ` ${prop}: ${value};`).join("\n");
|
|
141
|
+
}
|
|
142
|
+
function buildThemeCSS() {
|
|
143
|
+
const lightVars = buildLightThemeVars();
|
|
144
|
+
const darkVars = buildDarkThemeVars();
|
|
145
|
+
return `:root {
|
|
146
|
+
${varsToCSS(lightVars)}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.dark {
|
|
150
|
+
${varsToCSS(darkVars)}
|
|
151
|
+
}`;
|
|
152
|
+
}
|
|
153
|
+
var contract = {
|
|
154
|
+
color: colorVarNames,
|
|
155
|
+
radius: radiusVarNames,
|
|
156
|
+
shadow: shadowVarNames,
|
|
157
|
+
zIndex: zIndexVarNames,
|
|
158
|
+
duration: durationVarNames,
|
|
159
|
+
easing: easingVarNames,
|
|
160
|
+
fontFamily: fontFamilyVarNames
|
|
161
|
+
};
|
|
162
|
+
var cssVar = {
|
|
163
|
+
/** Returns `rgb(var(--ds-color-<key>))` for use in style props */
|
|
164
|
+
color: (key) => `rgb(var(${colorVarNames[key]}))`,
|
|
165
|
+
/** Returns `rgb(var(--ds-color-<key>) / <alpha>)` for colors with opacity */
|
|
166
|
+
colorAlpha: (key, alpha) => `rgb(var(${colorVarNames[key]}) / ${alpha})`,
|
|
167
|
+
/** Returns `var(--ds-radius-<key>)` */
|
|
168
|
+
radius: (key) => `var(${radiusVarNames[key]})`,
|
|
169
|
+
/** Returns `var(--ds-shadow-<key>)` */
|
|
170
|
+
shadow: (key) => `var(${shadowVarNames[key]})`,
|
|
171
|
+
/** Returns `var(--ds-z-<key>)` */
|
|
172
|
+
zIndex: (key) => `var(${zIndexVarNames[key]})`,
|
|
173
|
+
/** Returns `var(--ds-duration-<key>)` */
|
|
174
|
+
duration: (key) => `var(${durationVarNames[key]})`,
|
|
175
|
+
/** Returns `var(--ds-easing-<key>)` */
|
|
176
|
+
easing: (key) => `var(${easingVarNames[key]})`,
|
|
177
|
+
/** Returns `var(--ds-font-<key>)` */
|
|
178
|
+
fontFamily: (key) => `var(${fontFamilyVarNames[key]})`,
|
|
179
|
+
/** Returns the raw `var(--ds-color-<key>)` channels without rgb() wrapping */
|
|
180
|
+
colorChannels: (key) => `var(${colorVarNames[key]})`
|
|
181
|
+
};
|
|
182
|
+
var DSThemeContext = react.createContext(null);
|
|
183
|
+
function useDSTheme() {
|
|
184
|
+
const ctx = react.useContext(DSThemeContext);
|
|
185
|
+
if (!ctx) {
|
|
186
|
+
throw new Error(
|
|
187
|
+
"useDSTheme must be used within a <DSThemeProvider>. Wrap your application (or layout) with <DSThemeProvider>."
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
return ctx;
|
|
191
|
+
}
|
|
192
|
+
function getSystemPreference() {
|
|
193
|
+
if (typeof window === "undefined") return "light";
|
|
194
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
195
|
+
}
|
|
196
|
+
function resolveTheme(theme) {
|
|
197
|
+
if (theme === "system") return getSystemPreference();
|
|
198
|
+
return theme;
|
|
199
|
+
}
|
|
200
|
+
var STORAGE_KEY = "ds-theme-preference";
|
|
201
|
+
function getStoredTheme() {
|
|
202
|
+
if (typeof window === "undefined") return "system";
|
|
203
|
+
try {
|
|
204
|
+
const stored = localStorage.getItem(STORAGE_KEY);
|
|
205
|
+
if (stored === "light" || stored === "dark" || stored === "system") {
|
|
206
|
+
return stored;
|
|
207
|
+
}
|
|
208
|
+
} catch {
|
|
209
|
+
}
|
|
210
|
+
return "system";
|
|
211
|
+
}
|
|
212
|
+
function storeTheme(theme) {
|
|
213
|
+
try {
|
|
214
|
+
localStorage.setItem(STORAGE_KEY, theme);
|
|
215
|
+
} catch {
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function DSThemeProvider({
|
|
219
|
+
children,
|
|
220
|
+
defaultTheme,
|
|
221
|
+
manageHtmlClass = false
|
|
222
|
+
}) {
|
|
223
|
+
const [theme, setThemeState] = react.useState(
|
|
224
|
+
() => defaultTheme ?? getStoredTheme()
|
|
225
|
+
);
|
|
226
|
+
const [systemPreference, setSystemPreference] = react.useState("light");
|
|
227
|
+
react.useEffect(() => {
|
|
228
|
+
setSystemPreference(getSystemPreference());
|
|
229
|
+
const mql = window.matchMedia("(prefers-color-scheme: dark)");
|
|
230
|
+
const handler = (e) => {
|
|
231
|
+
setSystemPreference(e.matches ? "dark" : "light");
|
|
232
|
+
};
|
|
233
|
+
mql.addEventListener("change", handler);
|
|
234
|
+
return () => mql.removeEventListener("change", handler);
|
|
235
|
+
}, []);
|
|
236
|
+
const resolvedTheme = react.useMemo(
|
|
237
|
+
() => theme === "system" ? systemPreference : theme,
|
|
238
|
+
[theme, systemPreference]
|
|
239
|
+
);
|
|
240
|
+
react.useEffect(() => {
|
|
241
|
+
if (!manageHtmlClass) return;
|
|
242
|
+
const root = document.documentElement;
|
|
243
|
+
if (resolvedTheme === "dark") {
|
|
244
|
+
root.classList.add("dark");
|
|
245
|
+
} else {
|
|
246
|
+
root.classList.remove("dark");
|
|
247
|
+
}
|
|
248
|
+
}, [resolvedTheme, manageHtmlClass]);
|
|
249
|
+
const setTheme = react.useCallback((newTheme) => {
|
|
250
|
+
setThemeState(newTheme);
|
|
251
|
+
storeTheme(newTheme);
|
|
252
|
+
}, []);
|
|
253
|
+
const toggleTheme = react.useCallback(() => {
|
|
254
|
+
setThemeState((current) => {
|
|
255
|
+
const resolved = resolveTheme(current);
|
|
256
|
+
const next = resolved === "dark" ? "light" : "dark";
|
|
257
|
+
storeTheme(next);
|
|
258
|
+
return next;
|
|
259
|
+
});
|
|
260
|
+
}, []);
|
|
261
|
+
const value = react.useMemo(
|
|
262
|
+
() => ({
|
|
263
|
+
theme,
|
|
264
|
+
resolvedTheme,
|
|
265
|
+
setTheme,
|
|
266
|
+
toggleTheme
|
|
267
|
+
}),
|
|
268
|
+
[theme, resolvedTheme, setTheme, toggleTheme]
|
|
269
|
+
);
|
|
270
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DSThemeContext.Provider, { value, children });
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
exports.DSThemeProvider = DSThemeProvider;
|
|
274
|
+
exports.buildDarkThemeVars = buildDarkThemeVars;
|
|
275
|
+
exports.buildLightThemeVars = buildLightThemeVars;
|
|
276
|
+
exports.buildThemeCSS = buildThemeCSS;
|
|
277
|
+
exports.contract = contract;
|
|
278
|
+
exports.cssVar = cssVar;
|
|
279
|
+
exports.useDSTheme = useDSTheme;
|