@mrigx/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/package.json +73 -0
- package/src/blocks/ContactPanel.tsx +99 -0
- package/src/blocks/FeatureGrid.tsx +38 -0
- package/src/blocks/OpticalCTA.tsx +33 -0
- package/src/blocks/OpticalHero.tsx +51 -0
- package/src/blocks/styles.ts +175 -0
- package/src/components/accordion/optical-accordion.tsx +199 -0
- package/src/components/alert/optical-alert.tsx +59 -0
- package/src/components/alert-dialog/optical-alert-dialog.tsx +143 -0
- package/src/components/ambient-light.tsx +27 -0
- package/src/components/aspect-ratio/optical-aspect-ratio.tsx +7 -0
- package/src/components/attachment/optical-attachment.tsx +25 -0
- package/src/components/avatar/optical-avatar.tsx +50 -0
- package/src/components/badge/optical-badge.tsx +36 -0
- package/src/components/breadcrumb/optical-breadcrumb.tsx +115 -0
- package/src/components/bubble/optical-bubble.tsx +25 -0
- package/src/components/button/optical-button.tsx +67 -0
- package/src/components/button-group/optical-button-group.tsx +83 -0
- package/src/components/calendar/optical-calendar.tsx +214 -0
- package/src/components/card/optical-card.tsx +44 -0
- package/src/components/carousel/optical-carousel.tsx +262 -0
- package/src/components/chart/optical-chart.tsx +369 -0
- package/src/components/checkbox/optical-checkbox.tsx +42 -0
- package/src/components/collapsible/optical-collapsible.tsx +11 -0
- package/src/components/combobox/optical-combobox.tsx +25 -0
- package/src/components/command/optical-command.tsx +153 -0
- package/src/components/context-menu/optical-context-menu.tsx +201 -0
- package/src/components/cursor/optical-cursor.tsx +10 -0
- package/src/components/data-table/optical-data-table.tsx +25 -0
- package/src/components/date-picker/optical-date-picker.tsx +25 -0
- package/src/components/dialog/optical-dialog.tsx +110 -0
- package/src/components/direction/optical-direction.tsx +25 -0
- package/src/components/drawer/optical-drawer.tsx +120 -0
- package/src/components/dropdown-menu/optical-dropdown-menu.tsx +194 -0
- package/src/components/empty/optical-empty.tsx +104 -0
- package/src/components/field/optical-field.tsx +244 -0
- package/src/components/glass-card.tsx +13 -0
- package/src/components/hover-card/optical-hover-card.tsx +30 -0
- package/src/components/icon-button/optical-icon-button.tsx +22 -0
- package/src/components/input/optical-input.tsx +29 -0
- package/src/components/input-group/optical-input-group.tsx +170 -0
- package/src/components/input-otp/optical-input-otp.tsx +71 -0
- package/src/components/item/optical-item.tsx +193 -0
- package/src/components/kbd/optical-kbd.tsx +28 -0
- package/src/components/label/optical-label.tsx +25 -0
- package/src/components/marker/optical-marker.tsx +25 -0
- package/src/components/menubar/optical-menubar.tsx +257 -0
- package/src/components/message/optical-message.tsx +25 -0
- package/src/components/message-scroller/optical-message-scroller.tsx +25 -0
- package/src/components/native-select/optical-native-select.tsx +25 -0
- package/src/components/navigation-menu/optical-navigation-menu.tsx +68 -0
- package/src/components/pagination/optical-pagination.tsx +118 -0
- package/src/components/panel/optical-panel.tsx +26 -0
- package/src/components/popover/optical-popover.tsx +32 -0
- package/src/components/prism-button.tsx +17 -0
- package/src/components/progress/optical-progress.tsx +28 -0
- package/src/components/questionnaire/optical-questionnaire.tsx +25 -0
- package/src/components/radio-group/optical-radio-group.tsx +25 -0
- package/src/components/resizable/optical-resizable.tsx +45 -0
- package/src/components/scroll-area/optical-scroll-area.tsx +48 -0
- package/src/components/select/optical-select.tsx +110 -0
- package/src/components/separator/optical-separator.tsx +31 -0
- package/src/components/sheet/optical-sheet.tsx +143 -0
- package/src/components/sidebar/optical-sidebar.tsx +762 -0
- package/src/components/skeleton/optical-skeleton.tsx +15 -0
- package/src/components/slider/optical-slider.tsx +34 -0
- package/src/components/sonner/optical-toast.tsx +45 -0
- package/src/components/spinner/optical-spinner.tsx +16 -0
- package/src/components/stained-glass-card.tsx +93 -0
- package/src/components/switch/optical-switch.tsx +31 -0
- package/src/components/table/optical-table.tsx +83 -0
- package/src/components/tabs/optical-tabs.tsx +56 -0
- package/src/components/text/liquid-tension-text.tsx +65 -0
- package/src/components/text/optical-tension-text.tsx +65 -0
- package/src/components/text/optical-text.tsx +20 -0
- package/src/components/text/prismatic-selection.tsx +5 -0
- package/src/components/textarea/optical-textarea.tsx +22 -0
- package/src/components/theme-toggle/optical-theme-toggle.tsx +45 -0
- package/src/components/toast/optical-toast.tsx +25 -0
- package/src/components/toggle/optical-toggle.tsx +45 -0
- package/src/components/toggle-group/optical-toggle-group.tsx +61 -0
- package/src/components/tooltip/optical-tooltip.tsx +33 -0
- package/src/components/typography/optical-typography.tsx +49 -0
- package/src/hooks/use-mobile.ts +19 -0
- package/src/index.ts +88 -0
- package/src/templates/ContactPageTemplate.tsx +42 -0
- package/src/templates/LandingPageTemplate.tsx +29 -0
- package/src/templates/ProductPageTemplate.tsx +46 -0
- package/src/templates/styles.ts +23 -0
- package/src/utils/button-variants.ts +26 -0
- package/src/utils/cn.ts +6 -0
- package/tsconfig.json +27 -0
- package/vite.config.ts +42 -0
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as RechartsPrimitive from "recharts"
|
|
5
|
+
|
|
6
|
+
import { cn } from '../../utils/cn';
|
|
7
|
+
|
|
8
|
+
// Format: { THEME_NAME: CSS_SELECTOR }
|
|
9
|
+
const THEMES = { light: "", dark: ".dark" } as const
|
|
10
|
+
|
|
11
|
+
export type ChartConfig = {
|
|
12
|
+
[k in string]: {
|
|
13
|
+
label?: React.ReactNode
|
|
14
|
+
icon?: React.ComponentType
|
|
15
|
+
} & (
|
|
16
|
+
| { color?: string; theme?: never }
|
|
17
|
+
| { color?: never; theme: Record<keyof typeof THEMES, string> }
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type ChartContextProps = {
|
|
22
|
+
config: ChartConfig
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const ChartContext = React.createContext<ChartContextProps | null>(null)
|
|
26
|
+
|
|
27
|
+
function useChart() {
|
|
28
|
+
const context = React.useContext(ChartContext)
|
|
29
|
+
|
|
30
|
+
if (!context) {
|
|
31
|
+
throw new Error("useChart must be used within a <ChartContainer />")
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return context
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const ChartContainer = React.forwardRef<
|
|
38
|
+
HTMLDivElement,
|
|
39
|
+
React.ComponentProps<"div"> & {
|
|
40
|
+
config: ChartConfig
|
|
41
|
+
children: React.ComponentProps<
|
|
42
|
+
typeof RechartsPrimitive.ResponsiveContainer
|
|
43
|
+
>["children"]
|
|
44
|
+
}
|
|
45
|
+
>(({ id, className, children, config, ...props }, ref) => {
|
|
46
|
+
const uniqueId = React.useId()
|
|
47
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<ChartContext.Provider value={{ config }}>
|
|
51
|
+
<div
|
|
52
|
+
data-chart={chartId}
|
|
53
|
+
ref={ref}
|
|
54
|
+
className={cn(
|
|
55
|
+
"flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",
|
|
56
|
+
className
|
|
57
|
+
)}
|
|
58
|
+
{...props}
|
|
59
|
+
>
|
|
60
|
+
<ChartStyle id={chartId} config={config} />
|
|
61
|
+
<RechartsPrimitive.ResponsiveContainer>
|
|
62
|
+
{children}
|
|
63
|
+
</RechartsPrimitive.ResponsiveContainer>
|
|
64
|
+
</div>
|
|
65
|
+
</ChartContext.Provider>
|
|
66
|
+
)
|
|
67
|
+
})
|
|
68
|
+
ChartContainer.displayName = "Chart"
|
|
69
|
+
|
|
70
|
+
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
|
71
|
+
const colorConfig = Object.entries(config).filter(
|
|
72
|
+
([, config]) => config.theme || config.color
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
if (!colorConfig.length) {
|
|
76
|
+
return null
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<style
|
|
81
|
+
dangerouslySetInnerHTML={{
|
|
82
|
+
__html: Object.entries(THEMES)
|
|
83
|
+
.map(
|
|
84
|
+
([theme, prefix]) => `
|
|
85
|
+
${prefix} [data-chart=${id}] {
|
|
86
|
+
${colorConfig
|
|
87
|
+
.map(([key, itemConfig]) => {
|
|
88
|
+
const color =
|
|
89
|
+
itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||
|
|
90
|
+
itemConfig.color
|
|
91
|
+
return color ? ` --color-${key}: ${color};` : null
|
|
92
|
+
})
|
|
93
|
+
.join("\n")}
|
|
94
|
+
}
|
|
95
|
+
`
|
|
96
|
+
)
|
|
97
|
+
.join("\n"),
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const ChartTooltip = RechartsPrimitive.Tooltip
|
|
104
|
+
|
|
105
|
+
const ChartTooltipContent = React.forwardRef<
|
|
106
|
+
HTMLDivElement,
|
|
107
|
+
React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
|
108
|
+
React.ComponentProps<"div"> & {
|
|
109
|
+
hideLabel?: boolean
|
|
110
|
+
hideIndicator?: boolean
|
|
111
|
+
indicator?: "line" | "dot" | "dashed"
|
|
112
|
+
nameKey?: string
|
|
113
|
+
labelKey?: string
|
|
114
|
+
}
|
|
115
|
+
>(
|
|
116
|
+
(
|
|
117
|
+
{
|
|
118
|
+
active,
|
|
119
|
+
payload,
|
|
120
|
+
className,
|
|
121
|
+
indicator = "dot",
|
|
122
|
+
hideLabel = false,
|
|
123
|
+
hideIndicator = false,
|
|
124
|
+
label,
|
|
125
|
+
labelFormatter,
|
|
126
|
+
labelClassName,
|
|
127
|
+
formatter,
|
|
128
|
+
color,
|
|
129
|
+
nameKey,
|
|
130
|
+
labelKey,
|
|
131
|
+
},
|
|
132
|
+
ref
|
|
133
|
+
) => {
|
|
134
|
+
const { config } = useChart()
|
|
135
|
+
|
|
136
|
+
const tooltipLabel = React.useMemo(() => {
|
|
137
|
+
if (hideLabel || !payload?.length) {
|
|
138
|
+
return null
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const [item] = payload
|
|
142
|
+
const key = `${labelKey || item?.dataKey || item?.name || "value"}`
|
|
143
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
144
|
+
const value =
|
|
145
|
+
!labelKey && typeof label === "string"
|
|
146
|
+
? config[label as keyof typeof config]?.label || label
|
|
147
|
+
: itemConfig?.label
|
|
148
|
+
|
|
149
|
+
if (labelFormatter) {
|
|
150
|
+
return (
|
|
151
|
+
<div className={cn("font-medium", labelClassName)}>
|
|
152
|
+
{labelFormatter(value, payload)}
|
|
153
|
+
</div>
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (!value) {
|
|
158
|
+
return null
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return <div className={cn("font-medium", labelClassName)}>{value}</div>
|
|
162
|
+
}, [
|
|
163
|
+
label,
|
|
164
|
+
labelFormatter,
|
|
165
|
+
payload,
|
|
166
|
+
hideLabel,
|
|
167
|
+
labelClassName,
|
|
168
|
+
config,
|
|
169
|
+
labelKey,
|
|
170
|
+
])
|
|
171
|
+
|
|
172
|
+
if (!active || !payload?.length) {
|
|
173
|
+
return null
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const nestLabel = payload.length === 1 && indicator !== "dot"
|
|
177
|
+
|
|
178
|
+
return (
|
|
179
|
+
<div
|
|
180
|
+
ref={ref}
|
|
181
|
+
className={cn(
|
|
182
|
+
"grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-white/10/50 bg-transparent px-2.5 py-1.5 text-xs shadow-xl",
|
|
183
|
+
className
|
|
184
|
+
)}
|
|
185
|
+
>
|
|
186
|
+
{!nestLabel ? tooltipLabel : null}
|
|
187
|
+
<div className="grid gap-1.5">
|
|
188
|
+
{payload
|
|
189
|
+
.filter((item) => item.type !== "none")
|
|
190
|
+
.map((item, index) => {
|
|
191
|
+
const key = `${nameKey || item.name || item.dataKey || "value"}`
|
|
192
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
193
|
+
const indicatorColor = color || item.payload.fill || item.color
|
|
194
|
+
|
|
195
|
+
return (
|
|
196
|
+
<div
|
|
197
|
+
key={item.dataKey}
|
|
198
|
+
className={cn(
|
|
199
|
+
"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-white/50",
|
|
200
|
+
indicator === "dot" && "items-center"
|
|
201
|
+
)}
|
|
202
|
+
>
|
|
203
|
+
{formatter && item?.value !== undefined && item.name ? (
|
|
204
|
+
formatter(item.value, item.name, item, index, item.payload)
|
|
205
|
+
) : (
|
|
206
|
+
<>
|
|
207
|
+
{itemConfig?.icon ? (
|
|
208
|
+
<itemConfig.icon />
|
|
209
|
+
) : (
|
|
210
|
+
!hideIndicator && (
|
|
211
|
+
<div
|
|
212
|
+
className={cn(
|
|
213
|
+
"shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",
|
|
214
|
+
{
|
|
215
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
216
|
+
"w-1": indicator === "line",
|
|
217
|
+
"w-0 border-[1.5px] border-dashed bg-transparent":
|
|
218
|
+
indicator === "dashed",
|
|
219
|
+
"my-0.5": nestLabel && indicator === "dashed",
|
|
220
|
+
}
|
|
221
|
+
)}
|
|
222
|
+
style={
|
|
223
|
+
{
|
|
224
|
+
"--color-bg": indicatorColor,
|
|
225
|
+
"--color-border": indicatorColor,
|
|
226
|
+
} as React.CSSProperties
|
|
227
|
+
}
|
|
228
|
+
/>
|
|
229
|
+
)
|
|
230
|
+
)}
|
|
231
|
+
<div
|
|
232
|
+
className={cn(
|
|
233
|
+
"flex flex-1 justify-between leading-none",
|
|
234
|
+
nestLabel ? "items-end" : "items-center"
|
|
235
|
+
)}
|
|
236
|
+
>
|
|
237
|
+
<div className="grid gap-1.5">
|
|
238
|
+
{nestLabel ? tooltipLabel : null}
|
|
239
|
+
<span className="text-white/50">
|
|
240
|
+
{itemConfig?.label || item.name}
|
|
241
|
+
</span>
|
|
242
|
+
</div>
|
|
243
|
+
{item.value && (
|
|
244
|
+
<span className="font-mono font-medium tabular-nums text-white">
|
|
245
|
+
{item.value.toLocaleString()}
|
|
246
|
+
</span>
|
|
247
|
+
)}
|
|
248
|
+
</div>
|
|
249
|
+
</>
|
|
250
|
+
)}
|
|
251
|
+
</div>
|
|
252
|
+
)
|
|
253
|
+
})}
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
)
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
ChartTooltipContent.displayName = "ChartTooltip"
|
|
260
|
+
|
|
261
|
+
const ChartLegend = RechartsPrimitive.Legend
|
|
262
|
+
|
|
263
|
+
const ChartLegendContent = React.forwardRef<
|
|
264
|
+
HTMLDivElement,
|
|
265
|
+
React.ComponentProps<"div"> &
|
|
266
|
+
Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {
|
|
267
|
+
hideIcon?: boolean
|
|
268
|
+
nameKey?: string
|
|
269
|
+
}
|
|
270
|
+
>(
|
|
271
|
+
(
|
|
272
|
+
{ className, hideIcon = false, payload, verticalAlign = "bottom", nameKey },
|
|
273
|
+
ref
|
|
274
|
+
) => {
|
|
275
|
+
const { config } = useChart()
|
|
276
|
+
|
|
277
|
+
if (!payload?.length) {
|
|
278
|
+
return null
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return (
|
|
282
|
+
<div
|
|
283
|
+
ref={ref}
|
|
284
|
+
className={cn(
|
|
285
|
+
"flex items-center justify-center gap-4",
|
|
286
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
287
|
+
className
|
|
288
|
+
)}
|
|
289
|
+
>
|
|
290
|
+
{payload
|
|
291
|
+
.filter((item) => item.type !== "none")
|
|
292
|
+
.map((item) => {
|
|
293
|
+
const key = `${nameKey || item.dataKey || "value"}`
|
|
294
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
295
|
+
|
|
296
|
+
return (
|
|
297
|
+
<div
|
|
298
|
+
key={item.value}
|
|
299
|
+
className={cn(
|
|
300
|
+
"flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-white/50"
|
|
301
|
+
)}
|
|
302
|
+
>
|
|
303
|
+
{itemConfig?.icon && !hideIcon ? (
|
|
304
|
+
<itemConfig.icon />
|
|
305
|
+
) : (
|
|
306
|
+
<div
|
|
307
|
+
className="h-2 w-2 shrink-0 rounded-[2px]"
|
|
308
|
+
style={{
|
|
309
|
+
backgroundColor: item.color,
|
|
310
|
+
}}
|
|
311
|
+
/>
|
|
312
|
+
)}
|
|
313
|
+
{itemConfig?.label}
|
|
314
|
+
</div>
|
|
315
|
+
)
|
|
316
|
+
})}
|
|
317
|
+
</div>
|
|
318
|
+
)
|
|
319
|
+
}
|
|
320
|
+
)
|
|
321
|
+
ChartLegendContent.displayName = "ChartLegend"
|
|
322
|
+
|
|
323
|
+
// Helper to extract item config from a payload.
|
|
324
|
+
function getPayloadConfigFromPayload(
|
|
325
|
+
config: ChartConfig,
|
|
326
|
+
payload: unknown,
|
|
327
|
+
key: string
|
|
328
|
+
) {
|
|
329
|
+
if (typeof payload !== "object" || payload === null) {
|
|
330
|
+
return undefined
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const payloadPayload =
|
|
334
|
+
"payload" in payload &&
|
|
335
|
+
typeof payload.payload === "object" &&
|
|
336
|
+
payload.payload !== null
|
|
337
|
+
? payload.payload
|
|
338
|
+
: undefined
|
|
339
|
+
|
|
340
|
+
let configLabelKey: string = key
|
|
341
|
+
|
|
342
|
+
if (
|
|
343
|
+
key in payload &&
|
|
344
|
+
typeof payload[key as keyof typeof payload] === "string"
|
|
345
|
+
) {
|
|
346
|
+
configLabelKey = payload[key as keyof typeof payload] as string
|
|
347
|
+
} else if (
|
|
348
|
+
payloadPayload &&
|
|
349
|
+
key in payloadPayload &&
|
|
350
|
+
typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
|
|
351
|
+
) {
|
|
352
|
+
configLabelKey = payloadPayload[
|
|
353
|
+
key as keyof typeof payloadPayload
|
|
354
|
+
] as string
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
return configLabelKey in config
|
|
358
|
+
? config[configLabelKey]
|
|
359
|
+
: config[key as keyof typeof config]
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export {
|
|
363
|
+
ChartContainer,
|
|
364
|
+
ChartTooltip,
|
|
365
|
+
ChartTooltipContent,
|
|
366
|
+
ChartLegend,
|
|
367
|
+
ChartLegendContent,
|
|
368
|
+
ChartStyle,
|
|
369
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { useMrigSurface, useMrigInteraction } from '@mrigx/react';
|
|
4
|
+
|
|
5
|
+
export interface OpticalCheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange'> {
|
|
6
|
+
checked?: boolean;
|
|
7
|
+
onChange?: (checked: boolean) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const OpticalCheckbox = forwardRef<HTMLInputElement, OpticalCheckboxProps>(({
|
|
11
|
+
checked = false,
|
|
12
|
+
onChange,
|
|
13
|
+
className = "",
|
|
14
|
+
disabled,
|
|
15
|
+
...props
|
|
16
|
+
}, forwardedRef) => {
|
|
17
|
+
const boxRef = useMrigSurface<HTMLDivElement>({ material: 'crystal', materialStrength: 1.2, borderRadius: 4 });
|
|
18
|
+
const { pulseCenter } = useMrigInteraction();
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div
|
|
22
|
+
className={`relative flex items-center justify-center h-5 w-5 rounded-sm border border-white/20 bg-white/5 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/50 ${disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer'} ${checked ? 'bg-white/20' : ''} ${className}`}
|
|
23
|
+
onClick={(e) => {
|
|
24
|
+
if (!disabled) {
|
|
25
|
+
pulseCenter(e.currentTarget, 0.3);
|
|
26
|
+
onChange?.(!checked);
|
|
27
|
+
}
|
|
28
|
+
}}
|
|
29
|
+
ref={boxRef}
|
|
30
|
+
>
|
|
31
|
+
<input type="checkbox" className="sr-only" checked={checked} disabled={disabled} readOnly {...props} />
|
|
32
|
+
{checked && (
|
|
33
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round" className="h-3.5 w-3.5 text-white">
|
|
34
|
+
<polyline points="20 6 9 17 4 12"></polyline>
|
|
35
|
+
</svg>
|
|
36
|
+
)}
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
OpticalCheckbox.displayName = 'OpticalCheckbox';
|
|
41
|
+
|
|
42
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible"
|
|
4
|
+
|
|
5
|
+
const Collapsible = CollapsiblePrimitive.Root
|
|
6
|
+
|
|
7
|
+
const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger
|
|
8
|
+
|
|
9
|
+
const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent
|
|
10
|
+
|
|
11
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent }
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { useMrigSurface } from "@mrigx/react";
|
|
3
|
+
|
|
4
|
+
export interface OpticalComboboxProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
material?: 'glass' | 'crystal' | 'abyss';
|
|
6
|
+
materialStrength?: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function OpticalCombobox({ children, className = "", material = 'glass', materialStrength = 1.0, ...props }: OpticalComboboxProps) {
|
|
10
|
+
const localRef = useRef<HTMLDivElement>(null);
|
|
11
|
+
const ref = useMrigSurface<HTMLDivElement>({ material, materialStrength, borderRadius: 8 }, localRef);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div
|
|
15
|
+
ref={ref as any}
|
|
16
|
+
className={`p-6 border border-white/10 bg-white/5 rounded-xl shadow-lg backdrop-blur-md flex items-center justify-center text-white/80 font-light ${className}`}
|
|
17
|
+
{...props}
|
|
18
|
+
>
|
|
19
|
+
{children || 'Combobox Interface'}
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import type { DialogProps } from "@radix-ui/react-dialog"
|
|
3
|
+
import { Command as CommandPrimitive } from "cmdk"
|
|
4
|
+
import { Search } from "lucide-react"
|
|
5
|
+
|
|
6
|
+
import { cn } from '../../utils/cn';
|
|
7
|
+
import { OpticalDialog, OpticalDialogContent } from "../dialog/optical-dialog"
|
|
8
|
+
import { GlassSurface } from '@mrigx/fx';
|
|
9
|
+
|
|
10
|
+
const OpticalCommand = React.forwardRef<
|
|
11
|
+
React.ElementRef<typeof CommandPrimitive>,
|
|
12
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive> & { material?: string; materialStrength?: number }
|
|
13
|
+
>(({ className, material = "glass", materialStrength = 1.0, ...props }, ref) => (
|
|
14
|
+
<CommandPrimitive
|
|
15
|
+
ref={ref}
|
|
16
|
+
className={cn(
|
|
17
|
+
"flex h-full w-full flex-col overflow-hidden rounded-xl text-white relative",
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
{...props}
|
|
21
|
+
>
|
|
22
|
+
<GlassSurface material={material} materialStrength={materialStrength} borderRadius={12} className="absolute inset-0 -z-10 border border-white/10" />
|
|
23
|
+
{props.children}
|
|
24
|
+
</CommandPrimitive>
|
|
25
|
+
))
|
|
26
|
+
OpticalCommand.displayName = CommandPrimitive.displayName
|
|
27
|
+
|
|
28
|
+
interface OpticalCommandDialogProps extends DialogProps {}
|
|
29
|
+
|
|
30
|
+
const OpticalCommandDialog = ({ children, ...props }: OpticalCommandDialogProps) => {
|
|
31
|
+
return (
|
|
32
|
+
<OpticalDialog {...props}>
|
|
33
|
+
<OpticalDialogContent className="overflow-hidden p-0 shadow-lg">
|
|
34
|
+
<OpticalCommand className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-white/40 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
|
|
35
|
+
{children}
|
|
36
|
+
</OpticalCommand>
|
|
37
|
+
</OpticalDialogContent>
|
|
38
|
+
</OpticalDialog>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const OpticalCommandInput = React.forwardRef<
|
|
43
|
+
React.ElementRef<typeof CommandPrimitive.Input>,
|
|
44
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
|
|
45
|
+
>(({ className, ...props }, ref) => (
|
|
46
|
+
<div className="flex items-center border-b border-white/10 px-3" cmdk-input-wrapper="">
|
|
47
|
+
<Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
|
|
48
|
+
<CommandPrimitive.Input
|
|
49
|
+
ref={ref}
|
|
50
|
+
className={cn(
|
|
51
|
+
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-white/40 disabled:cursor-not-allowed disabled:opacity-50",
|
|
52
|
+
className
|
|
53
|
+
)}
|
|
54
|
+
{...props}
|
|
55
|
+
/>
|
|
56
|
+
</div>
|
|
57
|
+
))
|
|
58
|
+
OpticalCommandInput.displayName = CommandPrimitive.Input.displayName
|
|
59
|
+
|
|
60
|
+
const OpticalCommandList = React.forwardRef<
|
|
61
|
+
React.ElementRef<typeof CommandPrimitive.List>,
|
|
62
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
|
|
63
|
+
>(({ className, ...props }, ref) => (
|
|
64
|
+
<CommandPrimitive.List
|
|
65
|
+
ref={ref}
|
|
66
|
+
className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
|
|
67
|
+
{...props}
|
|
68
|
+
/>
|
|
69
|
+
))
|
|
70
|
+
OpticalCommandList.displayName = CommandPrimitive.List.displayName
|
|
71
|
+
|
|
72
|
+
const OpticalCommandEmpty = React.forwardRef<
|
|
73
|
+
React.ElementRef<typeof CommandPrimitive.Empty>,
|
|
74
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
|
|
75
|
+
>(({ className, ...props }, ref) => (
|
|
76
|
+
<CommandPrimitive.Empty
|
|
77
|
+
ref={ref}
|
|
78
|
+
className={cn("py-6 text-center text-sm", className)}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
))
|
|
82
|
+
OpticalCommandEmpty.displayName = CommandPrimitive.Empty.displayName
|
|
83
|
+
|
|
84
|
+
const OpticalCommandGroup = React.forwardRef<
|
|
85
|
+
React.ElementRef<typeof CommandPrimitive.Group>,
|
|
86
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
|
|
87
|
+
>(({ className, ...props }, ref) => (
|
|
88
|
+
<CommandPrimitive.Group
|
|
89
|
+
ref={ref}
|
|
90
|
+
className={cn(
|
|
91
|
+
"overflow-hidden p-1 text-white [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-white/40",
|
|
92
|
+
className
|
|
93
|
+
)}
|
|
94
|
+
{...props}
|
|
95
|
+
/>
|
|
96
|
+
))
|
|
97
|
+
OpticalCommandGroup.displayName = CommandPrimitive.Group.displayName
|
|
98
|
+
|
|
99
|
+
const OpticalCommandSeparator = React.forwardRef<
|
|
100
|
+
React.ElementRef<typeof CommandPrimitive.Separator>,
|
|
101
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
|
|
102
|
+
>(({ className, ...props }, ref) => (
|
|
103
|
+
<CommandPrimitive.Separator
|
|
104
|
+
ref={ref}
|
|
105
|
+
className={cn("-mx-1 h-px bg-white/10", className)}
|
|
106
|
+
{...props}
|
|
107
|
+
/>
|
|
108
|
+
))
|
|
109
|
+
OpticalCommandSeparator.displayName = CommandPrimitive.Separator.displayName
|
|
110
|
+
|
|
111
|
+
const OpticalCommandItem = React.forwardRef<
|
|
112
|
+
React.ElementRef<typeof CommandPrimitive.Item>,
|
|
113
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
|
|
114
|
+
>(({ className, ...props }, ref) => (
|
|
115
|
+
<CommandPrimitive.Item
|
|
116
|
+
ref={ref}
|
|
117
|
+
className={cn(
|
|
118
|
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-white/10 data-[selected=true]:text-white data-[disabled=true]:opacity-50",
|
|
119
|
+
className
|
|
120
|
+
)}
|
|
121
|
+
{...props}
|
|
122
|
+
/>
|
|
123
|
+
))
|
|
124
|
+
OpticalCommandItem.displayName = CommandPrimitive.Item.displayName
|
|
125
|
+
|
|
126
|
+
const OpticalCommandShortcut = ({
|
|
127
|
+
className,
|
|
128
|
+
...props
|
|
129
|
+
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
130
|
+
return (
|
|
131
|
+
<span
|
|
132
|
+
className={cn(
|
|
133
|
+
"ml-auto text-xs tracking-widest text-white/40",
|
|
134
|
+
className
|
|
135
|
+
)}
|
|
136
|
+
{...props}
|
|
137
|
+
/>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
OpticalCommandShortcut.displayName = "OpticalCommandShortcut"
|
|
141
|
+
|
|
142
|
+
export {
|
|
143
|
+
OpticalCommand,
|
|
144
|
+
OpticalCommandDialog,
|
|
145
|
+
OpticalCommandInput,
|
|
146
|
+
OpticalCommandList,
|
|
147
|
+
OpticalCommandEmpty,
|
|
148
|
+
OpticalCommandGroup,
|
|
149
|
+
OpticalCommandItem,
|
|
150
|
+
OpticalCommandShortcut,
|
|
151
|
+
OpticalCommandSeparator,
|
|
152
|
+
}
|
|
153
|
+
|