@omniviewdev/ui 0.1.10 → 0.1.11

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 @@
1
+ "use strict";const o=require("react/jsx-runtime"),p=require("@mui/material"),d=require("react"),b=require("@mui/material/styles"),r=b.createTheme(),s={50:"hsl(210, 100%, 95%)",100:"hsl(210, 100%, 92%)",200:"hsl(210, 100%, 80%)",300:"hsl(210, 100%, 65%)",400:"hsl(210, 98%, 48%)",500:"hsl(210, 98%, 42%)",600:"hsl(210, 98%, 55%)",700:"hsl(210, 100%, 35%)",800:"hsl(210, 100%, 16%)",900:"hsl(210, 100%, 21%)"},u={50:"#ECF0F6",100:"#CBD5E1",200:"#ABB8CC",300:"#8B9BB5",400:"#6B7D96",500:"#3E4F66",600:"#2D3D52",700:"#1F2937",800:"#151B23",900:"#0D1117"},n={50:"hsl(120, 80%, 98%)",100:"hsl(120, 75%, 94%)",200:"hsl(120, 75%, 87%)",300:"hsl(120, 61%, 77%)",400:"hsl(120, 44%, 53%)",500:"hsl(120, 59%, 30%)",600:"hsl(120, 70%, 25%)",700:"hsl(120, 75%, 16%)",800:"hsl(120, 84%, 10%)",900:"hsl(120, 87%, 6%)"},i={50:"hsl(45, 100%, 97%)",100:"hsl(45, 92%, 90%)",200:"hsl(45, 94%, 80%)",300:"hsl(45, 90%, 65%)",400:"hsl(45, 90%, 40%)",500:"hsl(45, 90%, 35%)",600:"hsl(45, 91%, 25%)",700:"hsl(45, 94%, 20%)",800:"hsl(45, 95%, 16%)",900:"hsl(45, 93%, 12%)"},l={50:"hsl(0, 100%, 97%)",100:"hsl(0, 92%, 90%)",200:"hsl(0, 94%, 80%)",300:"hsl(0, 90%, 65%)",400:"hsl(0, 90%, 40%)",500:"hsl(0, 90%, 30%)",600:"hsl(0, 91%, 25%)",700:"hsl(0, 94%, 18%)",800:"hsl(0, 95%, 12%)",900:"hsl(0, 93%, 6%)"},h={50:"hsl(270, 100%, 97%)",100:"hsl(270, 92%, 90%)",200:"hsl(270, 80%, 80%)",300:"hsl(270, 70%, 65%)",400:"hsl(270, 70%, 50%)",500:"hsl(270, 70%, 42%)",600:"hsl(270, 70%, 35%)",700:"hsl(270, 75%, 25%)",800:"hsl(270, 80%, 16%)",900:"hsl(270, 85%, 10%)"},S=e=>({palette:{mode:e,primary:{light:s[200],main:s[400],dark:s[700],contrastText:s[50],...e==="dark"&&{contrastText:s[50],light:s[300],main:s[400],dark:s[700]}},info:{light:s[100],main:s[300],dark:s[600],contrastText:u[50],...e==="dark"&&{contrastText:s[300],light:s[500],main:s[700],dark:s[900]}},warning:{light:i[300],main:i[400],dark:i[800],...e==="dark"&&{light:i[400],main:i[500],dark:i[700]}},error:{light:l[300],main:l[400],dark:l[800],...e==="dark"&&{light:l[400],main:l[500],dark:l[700]}},success:{light:n[300],main:n[400],dark:n[800],...e==="dark"&&{light:n[400],main:n[500],dark:n[700]}},secondary:{light:h[300],main:h[400],dark:h[700],contrastText:h[50],...e==="dark"&&{light:h[300],main:h[400],dark:h[800]}},grey:u,divider:e==="dark"?"rgba(62, 79, 102, 0.6)":"rgba(208, 215, 222, 0.6)",background:{default:e==="dark"?"#0D1117":"#FFFFFF",paper:e==="dark"?"#151B23":"#F6F8FA"},text:{primary:e==="dark"?"rgba(236, 240, 246, 0.92)":"rgba(31, 35, 40, 0.92)",secondary:e==="dark"?"rgba(236, 240, 246, 0.64)":"rgba(31, 35, 40, 0.64)"},action:{hover:e==="dark"?"rgba(255, 255, 255, 0.04)":"rgba(31, 35, 40, 0.04)",selected:e==="dark"?"rgba(88, 166, 255, 0.10)":"rgba(9, 105, 218, 0.10)"},baseShadow:e==="dark"?"0 4px 12px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.25)":"0 4px 12px rgba(31, 35, 40, 0.12), 0 2px 4px rgba(31, 35, 40, 0.08)"}}),x={fontFamily:["-apple-system","BlinkMacSystemFont",'"Segoe UI"','"Noto Sans"',"Helvetica","Arial","sans-serif"].join(","),h1:{fontSize:r.typography.pxToRem(48),fontWeight:600,lineHeight:1.2,letterSpacing:-.5},h2:{fontSize:r.typography.pxToRem(36),fontWeight:600,lineHeight:1.2},h3:{fontSize:r.typography.pxToRem(30),fontWeight:600,lineHeight:1.2},h4:{fontSize:r.typography.pxToRem(24),fontWeight:600,lineHeight:1.5},h5:{fontSize:r.typography.pxToRem(20),fontWeight:600},h6:{fontSize:r.typography.pxToRem(18),fontWeight:600},subtitle1:{fontSize:r.typography.pxToRem(18)},subtitle2:{fontSize:r.typography.pxToRem(14),fontWeight:500},body1:{fontSize:r.typography.pxToRem(14)},body2:{fontSize:r.typography.pxToRem(14),fontWeight:400},caption:{fontSize:r.typography.pxToRem(12),fontWeight:400},button:{textTransform:"none",fontWeight:600},overline:{fontSize:r.typography.pxToRem(12),fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em"}},f={borderRadius:8},R=e=>{const t=e==="dark"?"0 4px 12px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.25)":"0 4px 12px rgba(31, 35, 40, 0.12), 0 2px 4px rgba(31, 35, 40, 0.08)",a=[...r.shadows];return a[1]=t,a};class F{themes=new Map;register(t,a){this.themes.set(t,a)}get(t){return this.themes.get(t)??this.themes.get("default")}getVariants(){return Array.from(this.themes.keys())}}const k=new F,y=d.createContext({variant:"default",colorMode:"dark"});function z(){return d.useContext(y)}function C({mode:e}){const{setMode:t}=p.useColorScheme();return d.useEffect(()=>{t&&t(e)},[e,t]),null}function B({variant:e}){const{mode:t,systemMode:a}=p.useColorScheme();return d.useEffect(()=>{const c=t==="system"?a??"dark":t??"dark",g=e==="default"?c:`${e}-${c}`;document.documentElement.setAttribute("data-ov-theme",g)},[e,t,a]),null}function w({children:e,disableCustomTheme:t,themeComponents:a,defaultMode:c="dark",variant:g="default"}){const T=d.useMemo(()=>{if(t)return p.createTheme();const m=k.get(g);return p.createTheme({cssVariables:{colorSchemeSelector:"data-mui-color-scheme",cssVarPrefix:"ov-mui"},colorSchemes:{light:{palette:m.getDesignTokens("light").palette},dark:{palette:m.getDesignTokens("dark").palette}},typography:x,shape:f,shadows:m.getShadows("light"),components:{MuiCssBaseline:{styleOverrides:{html:{height:"100%"},body:{height:"100%"}}},...m.getCustomizations(),...a}})},[t,a,g]);return t?o.jsx(o.Fragment,{children:e}):o.jsx(y.Provider,{value:{variant:g,colorMode:c},children:o.jsxs(p.ThemeProvider,{theme:T,children:[o.jsx(p.CssBaseline,{enableColorScheme:!0}),o.jsx(C,{mode:c}),o.jsx(B,{variant:g}),e]})})}exports.AppTheme=w;exports.ThemeRegistry=k;exports.ThemeVariantContext=y;exports.brand=s;exports.customShadows=R;exports.getDesignTokens=S;exports.gray=u;exports.green=n;exports.orange=i;exports.purple=h;exports.red=l;exports.shape=f;exports.typography=x;exports.useThemeVariant=z;
@@ -0,0 +1,291 @@
1
+ import { jsx as p, Fragment as k, jsxs as T } from "react/jsx-runtime";
2
+ import { createTheme as d, ThemeProvider as b, CssBaseline as S, useColorScheme as f } from "@mui/material";
3
+ import { useMemo as F, createContext as R, useEffect as y, useContext as z } from "react";
4
+ import { createTheme as B } from "@mui/material/styles";
5
+ const r = B(), s = {
6
+ 50: "hsl(210, 100%, 95%)",
7
+ 100: "hsl(210, 100%, 92%)",
8
+ 200: "hsl(210, 100%, 80%)",
9
+ 300: "hsl(210, 100%, 65%)",
10
+ 400: "hsl(210, 98%, 48%)",
11
+ 500: "hsl(210, 98%, 42%)",
12
+ 600: "hsl(210, 98%, 55%)",
13
+ 700: "hsl(210, 100%, 35%)",
14
+ 800: "hsl(210, 100%, 16%)",
15
+ 900: "hsl(210, 100%, 21%)"
16
+ }, m = {
17
+ 50: "#ECF0F6",
18
+ // --ov-scale-gray-13
19
+ 100: "#CBD5E1",
20
+ // --ov-scale-gray-12
21
+ 200: "#ABB8CC",
22
+ // --ov-scale-gray-11
23
+ 300: "#8B9BB5",
24
+ // --ov-scale-gray-10
25
+ 400: "#6B7D96",
26
+ // --ov-scale-gray-9
27
+ 500: "#3E4F66",
28
+ // --ov-scale-gray-8
29
+ 600: "#2D3D52",
30
+ // --ov-scale-gray-6
31
+ 700: "#1F2937",
32
+ // --ov-scale-gray-4
33
+ 800: "#151B23",
34
+ // --ov-scale-gray-2
35
+ 900: "#0D1117"
36
+ // --ov-scale-gray-0
37
+ }, n = {
38
+ 50: "hsl(120, 80%, 98%)",
39
+ 100: "hsl(120, 75%, 94%)",
40
+ 200: "hsl(120, 75%, 87%)",
41
+ 300: "hsl(120, 61%, 77%)",
42
+ 400: "hsl(120, 44%, 53%)",
43
+ 500: "hsl(120, 59%, 30%)",
44
+ 600: "hsl(120, 70%, 25%)",
45
+ 700: "hsl(120, 75%, 16%)",
46
+ 800: "hsl(120, 84%, 10%)",
47
+ 900: "hsl(120, 87%, 6%)"
48
+ }, l = {
49
+ 50: "hsl(45, 100%, 97%)",
50
+ 100: "hsl(45, 92%, 90%)",
51
+ 200: "hsl(45, 94%, 80%)",
52
+ 300: "hsl(45, 90%, 65%)",
53
+ 400: "hsl(45, 90%, 40%)",
54
+ 500: "hsl(45, 90%, 35%)",
55
+ 600: "hsl(45, 91%, 25%)",
56
+ 700: "hsl(45, 94%, 20%)",
57
+ 800: "hsl(45, 95%, 16%)",
58
+ 900: "hsl(45, 93%, 12%)"
59
+ }, i = {
60
+ 50: "hsl(0, 100%, 97%)",
61
+ 100: "hsl(0, 92%, 90%)",
62
+ 200: "hsl(0, 94%, 80%)",
63
+ 300: "hsl(0, 90%, 65%)",
64
+ 400: "hsl(0, 90%, 40%)",
65
+ 500: "hsl(0, 90%, 30%)",
66
+ 600: "hsl(0, 91%, 25%)",
67
+ 700: "hsl(0, 94%, 18%)",
68
+ 800: "hsl(0, 95%, 12%)",
69
+ 900: "hsl(0, 93%, 6%)"
70
+ }, o = {
71
+ 50: "hsl(270, 100%, 97%)",
72
+ 100: "hsl(270, 92%, 90%)",
73
+ 200: "hsl(270, 80%, 80%)",
74
+ 300: "hsl(270, 70%, 65%)",
75
+ 400: "hsl(270, 70%, 50%)",
76
+ 500: "hsl(270, 70%, 42%)",
77
+ 600: "hsl(270, 70%, 35%)",
78
+ 700: "hsl(270, 75%, 25%)",
79
+ 800: "hsl(270, 80%, 16%)",
80
+ 900: "hsl(270, 85%, 10%)"
81
+ }, j = (e) => ({
82
+ palette: {
83
+ mode: e,
84
+ primary: {
85
+ light: s[200],
86
+ main: s[400],
87
+ dark: s[700],
88
+ contrastText: s[50],
89
+ ...e === "dark" && {
90
+ contrastText: s[50],
91
+ light: s[300],
92
+ main: s[400],
93
+ dark: s[700]
94
+ }
95
+ },
96
+ info: {
97
+ light: s[100],
98
+ main: s[300],
99
+ dark: s[600],
100
+ contrastText: m[50],
101
+ ...e === "dark" && {
102
+ contrastText: s[300],
103
+ light: s[500],
104
+ main: s[700],
105
+ dark: s[900]
106
+ }
107
+ },
108
+ warning: {
109
+ light: l[300],
110
+ main: l[400],
111
+ dark: l[800],
112
+ ...e === "dark" && {
113
+ light: l[400],
114
+ main: l[500],
115
+ dark: l[700]
116
+ }
117
+ },
118
+ error: {
119
+ light: i[300],
120
+ main: i[400],
121
+ dark: i[800],
122
+ ...e === "dark" && {
123
+ light: i[400],
124
+ main: i[500],
125
+ dark: i[700]
126
+ }
127
+ },
128
+ success: {
129
+ light: n[300],
130
+ main: n[400],
131
+ dark: n[800],
132
+ ...e === "dark" && {
133
+ light: n[400],
134
+ main: n[500],
135
+ dark: n[700]
136
+ }
137
+ },
138
+ secondary: {
139
+ light: o[300],
140
+ main: o[400],
141
+ dark: o[700],
142
+ contrastText: o[50],
143
+ ...e === "dark" && {
144
+ light: o[300],
145
+ main: o[400],
146
+ dark: o[800]
147
+ }
148
+ },
149
+ grey: m,
150
+ // Matches --ov-border-default / --ov-border-muted
151
+ divider: e === "dark" ? "rgba(62, 79, 102, 0.6)" : "rgba(208, 215, 222, 0.6)",
152
+ // alpha(--ov-border-default light, 0.6)
153
+ background: {
154
+ // Matches --ov-bg-base / --ov-bg-surface
155
+ default: e === "dark" ? "#0D1117" : "#FFFFFF",
156
+ paper: e === "dark" ? "#151B23" : "#F6F8FA"
157
+ },
158
+ text: {
159
+ // Matches --ov-fg-default / --ov-fg-muted
160
+ primary: e === "dark" ? "rgba(236, 240, 246, 0.92)" : "rgba(31, 35, 40, 0.92)",
161
+ secondary: e === "dark" ? "rgba(236, 240, 246, 0.64)" : "rgba(31, 35, 40, 0.64)"
162
+ },
163
+ action: {
164
+ // Matches --ov-state-hover / --ov-state-selected
165
+ hover: e === "dark" ? "rgba(255, 255, 255, 0.04)" : "rgba(31, 35, 40, 0.04)",
166
+ selected: e === "dark" ? "rgba(88, 166, 255, 0.10)" : "rgba(9, 105, 218, 0.10)"
167
+ },
168
+ baseShadow: e === "dark" ? "0 4px 12px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.25)" : "0 4px 12px rgba(31, 35, 40, 0.12), 0 2px 4px rgba(31, 35, 40, 0.08)"
169
+ }
170
+ }), C = {
171
+ fontFamily: [
172
+ "-apple-system",
173
+ "BlinkMacSystemFont",
174
+ '"Segoe UI"',
175
+ '"Noto Sans"',
176
+ "Helvetica",
177
+ "Arial",
178
+ "sans-serif"
179
+ ].join(","),
180
+ h1: { fontSize: r.typography.pxToRem(48), fontWeight: 600, lineHeight: 1.2, letterSpacing: -0.5 },
181
+ h2: { fontSize: r.typography.pxToRem(36), fontWeight: 600, lineHeight: 1.2 },
182
+ h3: { fontSize: r.typography.pxToRem(30), fontWeight: 600, lineHeight: 1.2 },
183
+ h4: { fontSize: r.typography.pxToRem(24), fontWeight: 600, lineHeight: 1.5 },
184
+ h5: { fontSize: r.typography.pxToRem(20), fontWeight: 600 },
185
+ h6: { fontSize: r.typography.pxToRem(18), fontWeight: 600 },
186
+ subtitle1: { fontSize: r.typography.pxToRem(18) },
187
+ subtitle2: { fontSize: r.typography.pxToRem(14), fontWeight: 500 },
188
+ body1: { fontSize: r.typography.pxToRem(14) },
189
+ body2: { fontSize: r.typography.pxToRem(14), fontWeight: 400 },
190
+ caption: { fontSize: r.typography.pxToRem(12), fontWeight: 400 },
191
+ button: { textTransform: "none", fontWeight: 600 },
192
+ overline: {
193
+ fontSize: r.typography.pxToRem(12),
194
+ fontWeight: 600,
195
+ textTransform: "uppercase",
196
+ letterSpacing: "0.08em"
197
+ }
198
+ }, W = { borderRadius: 8 }, P = (e) => {
199
+ const t = e === "dark" ? "0 4px 12px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.25)" : "0 4px 12px rgba(31, 35, 40, 0.12), 0 2px 4px rgba(31, 35, 40, 0.08)", a = [...r.shadows];
200
+ return a[1] = t, a;
201
+ };
202
+ class w {
203
+ themes = /* @__PURE__ */ new Map();
204
+ register(t, a) {
205
+ this.themes.set(t, a);
206
+ }
207
+ get(t) {
208
+ return this.themes.get(t) ?? this.themes.get("default");
209
+ }
210
+ getVariants() {
211
+ return Array.from(this.themes.keys());
212
+ }
213
+ }
214
+ const D = new w(), u = R({
215
+ variant: "default",
216
+ colorMode: "dark"
217
+ });
218
+ function $() {
219
+ return z(u);
220
+ }
221
+ function M({ mode: e }) {
222
+ const { setMode: t } = f();
223
+ return y(() => {
224
+ t && t(e);
225
+ }, [e, t]), null;
226
+ }
227
+ function v({ variant: e }) {
228
+ const { mode: t, systemMode: a } = f();
229
+ return y(() => {
230
+ const g = t === "system" ? a ?? "dark" : t ?? "dark", h = e === "default" ? g : `${e}-${g}`;
231
+ document.documentElement.setAttribute("data-ov-theme", h);
232
+ }, [e, t, a]), null;
233
+ }
234
+ function O({
235
+ children: e,
236
+ disableCustomTheme: t,
237
+ themeComponents: a,
238
+ defaultMode: g = "dark",
239
+ variant: h = "default"
240
+ }) {
241
+ const x = F(() => {
242
+ if (t)
243
+ return d();
244
+ const c = D.get(h);
245
+ return d({
246
+ cssVariables: {
247
+ colorSchemeSelector: "data-mui-color-scheme",
248
+ cssVarPrefix: "ov-mui"
249
+ },
250
+ colorSchemes: {
251
+ light: { palette: c.getDesignTokens("light").palette },
252
+ dark: { palette: c.getDesignTokens("dark").palette }
253
+ },
254
+ typography: C,
255
+ shape: W,
256
+ shadows: c.getShadows("light"),
257
+ components: {
258
+ MuiCssBaseline: {
259
+ styleOverrides: {
260
+ html: { height: "100%" },
261
+ body: { height: "100%" }
262
+ }
263
+ },
264
+ ...c.getCustomizations(),
265
+ ...a
266
+ }
267
+ });
268
+ }, [t, a, h]);
269
+ return t ? /* @__PURE__ */ p(k, { children: e }) : /* @__PURE__ */ p(u.Provider, { value: { variant: h, colorMode: g }, children: /* @__PURE__ */ T(b, { theme: x, children: [
270
+ /* @__PURE__ */ p(S, { enableColorScheme: !0 }),
271
+ /* @__PURE__ */ p(M, { mode: g }),
272
+ /* @__PURE__ */ p(v, { variant: h }),
273
+ e
274
+ ] }) });
275
+ }
276
+ export {
277
+ O as A,
278
+ D as T,
279
+ n as a,
280
+ s as b,
281
+ P as c,
282
+ j as d,
283
+ u as e,
284
+ m as g,
285
+ l as o,
286
+ o as p,
287
+ i as r,
288
+ W as s,
289
+ C as t,
290
+ $ as u
291
+ };
@@ -0,0 +1 @@
1
+ "use strict";const r=require("react/jsx-runtime"),y=require("react"),B=require("@mui/material/Select"),q=require("@mui/material/MenuItem"),K=require("@mui/material/FormControl"),U=require("@mui/material/InputLabel"),V=require("@mui/material/FormHelperText"),G=require("@mui/material/ListItemIcon"),_=require("@mui/material/ListItemText"),J=require("@mui/material/CircularProgress"),Q=require("@mui/material/OutlinedInput"),X=require("@mui/material/InputBase"),Y=require("@mui/material/Chip"),f=require("@mui/material/Box"),Z=require("@mui/icons-material/Search"),$=require("@mui/icons-material/Clear"),b=require("./types.cjs");function D({options:x,value:g,onChange:c,size:h="md",color:z="neutral",label:l,helperText:w,placeholder:o,searchable:d=!1,multiple:v=!1,loading:M=!1,error:p,fullWidth:E,disabled:H,clearable:P=!1,sx:T}){const[m,C]=y.useState(""),[A,L]=y.useState(!1),[a,u]=y.useState(-1),O=b.toMuiInputSize(h),I=b.toMuiColor(z),F=typeof p=="string"?!!p:p,k=typeof p=="string"?p:void 0,j=()=>{L(!1),u(-1),d&&C("")},s=y.useMemo(()=>{if(!d||!m)return x;const e=m.toLowerCase();return x.filter(t=>t.label.toLowerCase().includes(e))},[x,m,d]),R=e=>{c(e.target.value)},W=e=>{if(e.key==="Escape"){j();return}if(e.key==="ArrowDown"){if(e.preventDefault(),e.stopPropagation(),s.length===0)return;const t=a+1;u(t>=s.length?0:t);return}if(e.key==="ArrowUp"){e.preventDefault(),e.stopPropagation();const t=a-1;u(t<0?s.length-1:t);return}if(e.key==="Enter"&&a>=0&&a<s.length){e.preventDefault(),e.stopPropagation();const t=s[a];if(!t.disabled)if(v){const n=Array.isArray(g)?g:[],S=n.includes(t.value)?n.filter(i=>i!==t.value):[...n,t.value];c(S)}else c(t.value),j();return}e.stopPropagation()};return r.jsxs(K,{size:O,fullWidth:E,error:F,disabled:H,style:{"--ov-input-height":b.INPUT_HEIGHTS[h]},sx:T,children:[l&&r.jsx(U,{color:I==="default"||I==="inherit"?void 0:I,shrink:!!o||void 0,children:l}),r.jsxs(B,{value:g,onChange:R,multiple:v,displayEmpty:!!o,label:l,notched:l&&!!o||void 0,input:v?r.jsx(Q,{label:l}):void 0,open:A,onOpen:()=>{L(!0),u(-1)},onClose:j,renderValue:v?e=>{const t=e;return t.length===0&&o?r.jsx(f,{sx:{color:"var(--ov-fg-faint)"},children:o}):r.jsxs(f,{sx:{display:"flex",flexWrap:"nowrap",gap:.5,overflow:"hidden",alignItems:"center"},children:[t.map(n=>{const S=x.find(i=>i.value===n);return r.jsx(Y,{label:S?.label??n,size:"small",...P?{onDelete:i=>{i.stopPropagation(),c(t.filter(N=>N!==n))},onMouseDown:i=>{i.stopPropagation()}}:{}},n)}),P&&t.length>1&&r.jsx("button",{type:"button","aria-label":"Clear all",onClick:n=>{n.stopPropagation(),c([])},style:{display:"inline-flex",alignItems:"center",flexShrink:0,marginLeft:2,cursor:"pointer",color:"var(--ov-fg-faint)",lineHeight:0,background:"none",border:"none",padding:0},children:r.jsx($,{sx:{fontSize:16}})})]})}:o&&!g?()=>r.jsx(f,{sx:{color:"var(--ov-fg-faint)"},children:o}):void 0,MenuProps:{PaperProps:{sx:{maxHeight:300,...h==="xs"||h==="sm"?{"& .MuiMenuItem-root":{fontSize:"0.8rem",minHeight:28,padding:"3px 8px"},"& .MuiListItemText-root":{margin:0},"& .MuiListItemText-primary":{fontSize:"0.8rem"},"& .MuiListItemIcon-root":{minWidth:22}}:{}}}},children:[d&&r.jsx(f,{sx:{px:1,pb:.5,pt:.5},onClickCapture:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:r.jsxs(f,{sx:{display:"flex",alignItems:"center",height:28,border:"1px solid var(--ov-border-default)",borderRadius:"4px",bgcolor:"var(--ov-bg-base)",px:.75,"&:focus-within":{borderColor:"var(--ov-accent)"}},children:[r.jsx(Z,{sx:{fontSize:14,color:"var(--ov-fg-faint)",mr:.5}}),r.jsx(X,{autoFocus:!0,fullWidth:!0,placeholder:"Search...",value:m,onChange:e=>{C(e.target.value),u(-1)},onKeyDown:W,sx:{flex:1,fontSize:"0.75rem",color:"var(--ov-fg-default)","& input":{py:0,px:0},"& input::placeholder":{color:"var(--ov-fg-faint)",opacity:1}}})]})}),M&&r.jsxs(q,{disabled:!0,children:[r.jsx(J,{size:16,sx:{mr:1}})," Loading..."]}),s.map((e,t)=>r.jsxs(q,{value:e.value,disabled:e.disabled,...d?{onMouseEnter:()=>u(t),sx:t===a?{bgcolor:"action.focus"}:void 0}:{},children:[e.icon&&r.jsx(G,{sx:{minWidth:28},children:e.icon}),r.jsx(_,{children:e.label})]},e.value)),s.length===0&&!M&&r.jsx(q,{disabled:!0,children:"No options"})]}),(k||w)&&r.jsx(V,{children:k??w})]})}D.displayName="Select";exports.Select=D;
@@ -0,0 +1,276 @@
1
+ import { jsxs as p, jsx as t } from "react/jsx-runtime";
2
+ import { useState as w, useMemo as K } from "react";
3
+ import R from "@mui/material/Select";
4
+ import M from "@mui/material/MenuItem";
5
+ import U from "@mui/material/FormControl";
6
+ import V from "@mui/material/InputLabel";
7
+ import G from "@mui/material/FormHelperText";
8
+ import _ from "@mui/material/ListItemIcon";
9
+ import q from "@mui/material/ListItemText";
10
+ import J from "@mui/material/CircularProgress";
11
+ import Q from "@mui/material/OutlinedInput";
12
+ import X from "@mui/material/InputBase";
13
+ import Y from "@mui/material/Chip";
14
+ import m from "@mui/material/Box";
15
+ import Z from "@mui/icons-material/Search";
16
+ import $ from "@mui/icons-material/Clear";
17
+ import { INPUT_HEIGHTS as oo, toMuiInputSize as eo, toMuiColor as to } from "./types.js";
18
+ function ro({
19
+ options: g,
20
+ value: h,
21
+ onChange: f,
22
+ size: v = "md",
23
+ color: E = "neutral",
24
+ label: u,
25
+ helperText: P,
26
+ placeholder: n,
27
+ searchable: c = !1,
28
+ multiple: x = !1,
29
+ loading: C = !1,
30
+ error: d,
31
+ fullWidth: H,
32
+ disabled: T,
33
+ clearable: L = !1,
34
+ sx: A
35
+ }) {
36
+ const [I, k] = w(""), [O, D] = w(!1), [a, l] = w(-1), F = eo(v), y = to(E), W = typeof d == "string" ? !!d : d, z = typeof d == "string" ? d : void 0, S = () => {
37
+ D(!1), l(-1), c && k("");
38
+ }, i = K(() => {
39
+ if (!c || !I) return g;
40
+ const o = I.toLowerCase();
41
+ return g.filter((e) => e.label.toLowerCase().includes(o));
42
+ }, [g, I, c]), N = (o) => {
43
+ f(o.target.value);
44
+ }, j = (o) => {
45
+ if (o.key === "Escape") {
46
+ S();
47
+ return;
48
+ }
49
+ if (o.key === "ArrowDown") {
50
+ if (o.preventDefault(), o.stopPropagation(), i.length === 0) return;
51
+ const e = a + 1;
52
+ l(e >= i.length ? 0 : e);
53
+ return;
54
+ }
55
+ if (o.key === "ArrowUp") {
56
+ o.preventDefault(), o.stopPropagation();
57
+ const e = a - 1;
58
+ l(e < 0 ? i.length - 1 : e);
59
+ return;
60
+ }
61
+ if (o.key === "Enter" && a >= 0 && a < i.length) {
62
+ o.preventDefault(), o.stopPropagation();
63
+ const e = i[a];
64
+ if (!e.disabled)
65
+ if (x) {
66
+ const r = Array.isArray(h) ? h : [], b = r.includes(e.value) ? r.filter((s) => s !== e.value) : [...r, e.value];
67
+ f(b);
68
+ } else
69
+ f(e.value), S();
70
+ return;
71
+ }
72
+ o.stopPropagation();
73
+ };
74
+ return /* @__PURE__ */ p(
75
+ U,
76
+ {
77
+ size: F,
78
+ fullWidth: H,
79
+ error: W,
80
+ disabled: T,
81
+ style: { "--ov-input-height": oo[v] },
82
+ sx: A,
83
+ children: [
84
+ u && /* @__PURE__ */ t(
85
+ V,
86
+ {
87
+ color: y === "default" || y === "inherit" ? void 0 : y,
88
+ shrink: !!n || void 0,
89
+ children: u
90
+ }
91
+ ),
92
+ /* @__PURE__ */ p(
93
+ R,
94
+ {
95
+ value: h,
96
+ onChange: N,
97
+ multiple: x,
98
+ displayEmpty: !!n,
99
+ label: u,
100
+ notched: u && !!n || void 0,
101
+ input: x ? /* @__PURE__ */ t(Q, { label: u }) : void 0,
102
+ open: O,
103
+ onOpen: () => {
104
+ D(!0), l(-1);
105
+ },
106
+ onClose: S,
107
+ renderValue: x ? (o) => {
108
+ const e = o;
109
+ return e.length === 0 && n ? /* @__PURE__ */ t(m, { sx: { color: "var(--ov-fg-faint)" }, children: n }) : /* @__PURE__ */ p(
110
+ m,
111
+ {
112
+ sx: {
113
+ display: "flex",
114
+ flexWrap: "nowrap",
115
+ gap: 0.5,
116
+ overflow: "hidden",
117
+ alignItems: "center"
118
+ },
119
+ children: [
120
+ e.map((r) => {
121
+ const b = g.find((s) => s.value === r);
122
+ return /* @__PURE__ */ t(
123
+ Y,
124
+ {
125
+ label: b?.label ?? r,
126
+ size: "small",
127
+ ...L ? {
128
+ onDelete: (s) => {
129
+ s.stopPropagation(), f(e.filter((B) => B !== r));
130
+ },
131
+ onMouseDown: (s) => {
132
+ s.stopPropagation();
133
+ }
134
+ } : {}
135
+ },
136
+ r
137
+ );
138
+ }),
139
+ L && e.length > 1 && /* @__PURE__ */ t(
140
+ "button",
141
+ {
142
+ type: "button",
143
+ "aria-label": "Clear all",
144
+ onClick: (r) => {
145
+ r.stopPropagation(), f([]);
146
+ },
147
+ style: {
148
+ display: "inline-flex",
149
+ alignItems: "center",
150
+ flexShrink: 0,
151
+ marginLeft: 2,
152
+ cursor: "pointer",
153
+ color: "var(--ov-fg-faint)",
154
+ lineHeight: 0,
155
+ background: "none",
156
+ border: "none",
157
+ padding: 0
158
+ },
159
+ children: /* @__PURE__ */ t($, { sx: { fontSize: 16 } })
160
+ }
161
+ )
162
+ ]
163
+ }
164
+ );
165
+ } : n && !h ? () => /* @__PURE__ */ t(m, { sx: { color: "var(--ov-fg-faint)" }, children: n }) : void 0,
166
+ MenuProps: {
167
+ PaperProps: {
168
+ sx: {
169
+ maxHeight: 300,
170
+ ...v === "xs" || v === "sm" ? {
171
+ "& .MuiMenuItem-root": {
172
+ fontSize: "0.8rem",
173
+ minHeight: 28,
174
+ padding: "3px 8px"
175
+ },
176
+ "& .MuiListItemText-root": {
177
+ margin: 0
178
+ },
179
+ "& .MuiListItemText-primary": {
180
+ fontSize: "0.8rem"
181
+ },
182
+ "& .MuiListItemIcon-root": {
183
+ minWidth: 22
184
+ }
185
+ } : {}
186
+ }
187
+ }
188
+ },
189
+ children: [
190
+ c && /* @__PURE__ */ t(
191
+ m,
192
+ {
193
+ sx: { px: 1, pb: 0.5, pt: 0.5 },
194
+ onClickCapture: (o) => o.stopPropagation(),
195
+ onMouseDown: (o) => o.stopPropagation(),
196
+ children: /* @__PURE__ */ p(
197
+ m,
198
+ {
199
+ sx: {
200
+ display: "flex",
201
+ alignItems: "center",
202
+ height: 28,
203
+ border: "1px solid var(--ov-border-default)",
204
+ borderRadius: "4px",
205
+ bgcolor: "var(--ov-bg-base)",
206
+ px: 0.75,
207
+ "&:focus-within": { borderColor: "var(--ov-accent)" }
208
+ },
209
+ children: [
210
+ /* @__PURE__ */ t(
211
+ Z,
212
+ {
213
+ sx: { fontSize: 14, color: "var(--ov-fg-faint)", mr: 0.5 }
214
+ }
215
+ ),
216
+ /* @__PURE__ */ t(
217
+ X,
218
+ {
219
+ autoFocus: !0,
220
+ fullWidth: !0,
221
+ placeholder: "Search...",
222
+ value: I,
223
+ onChange: (o) => {
224
+ k(o.target.value), l(-1);
225
+ },
226
+ onKeyDown: j,
227
+ sx: {
228
+ flex: 1,
229
+ fontSize: "0.75rem",
230
+ color: "var(--ov-fg-default)",
231
+ "& input": { py: 0, px: 0 },
232
+ "& input::placeholder": {
233
+ color: "var(--ov-fg-faint)",
234
+ opacity: 1
235
+ }
236
+ }
237
+ }
238
+ )
239
+ ]
240
+ }
241
+ )
242
+ }
243
+ ),
244
+ C && /* @__PURE__ */ p(M, { disabled: !0, children: [
245
+ /* @__PURE__ */ t(J, { size: 16, sx: { mr: 1 } }),
246
+ " Loading..."
247
+ ] }),
248
+ i.map((o, e) => /* @__PURE__ */ p(
249
+ M,
250
+ {
251
+ value: o.value,
252
+ disabled: o.disabled,
253
+ ...c ? {
254
+ onMouseEnter: () => l(e),
255
+ sx: e === a ? { bgcolor: "action.focus" } : void 0
256
+ } : {},
257
+ children: [
258
+ o.icon && /* @__PURE__ */ t(_, { sx: { minWidth: 28 }, children: o.icon }),
259
+ /* @__PURE__ */ t(q, { children: o.label })
260
+ ]
261
+ },
262
+ o.value
263
+ )),
264
+ i.length === 0 && !C && /* @__PURE__ */ t(M, { disabled: !0, children: "No options" })
265
+ ]
266
+ }
267
+ ),
268
+ (z || P) && /* @__PURE__ */ t(G, { children: z ?? P })
269
+ ]
270
+ }
271
+ );
272
+ }
273
+ ro.displayName = "Select";
274
+ export {
275
+ ro as S
276
+ };