66} from '@vojtechportes/react-query-builder' ;
77import { components as antdComponents } from '@vojtechportes/react-query-builder/antd/v6' ;
88import { components as fluentUiComponents } from '@vojtechportes/react-query-builder/fluentui/v8' ;
9+ import mantineStyles from '@mantine/core/styles.css?inline' ;
10+ import { MantineProvider } from '@mantine/core' ;
11+ import { components as mantineComponents } from '@vojtechportes/react-query-builder/mantine/v9' ;
912import { createMonacoComponents } from '@vojtechportes/react-query-builder/monaco' ;
1013import { components as muiComponents } from '@vojtechportes/react-query-builder/mui/v9' ;
1114import type { IColors } from '../../../src/constants/colors' ;
@@ -180,13 +183,71 @@ const SourceButton = styled.button`
180183 }
181184` ;
182185
186+ const mantineScopeClassName = 'mantine-demo-scope' ;
187+
188+ const scopedMantineStyles = mantineStyles
189+ . replace (
190+ / : r o o t , \s * : h o s t / g,
191+ `.${ mantineScopeClassName } `
192+ )
193+ . replace (
194+ / b o d y , \s * : h o s t / g,
195+ `.${ mantineScopeClassName } `
196+ )
197+ . replace (
198+ / : r o o t \[ d a t a - m a n t i n e - c o l o r - s c h e m e = ' d a r k ' \] , \s * : h o s t \( \[ d a t a - m a n t i n e - c o l o r - s c h e m e = ' d a r k ' \] \) / g,
199+ `.${ mantineScopeClassName } [data-mantine-color-scheme='dark']`
200+ )
201+ . replace (
202+ / : r o o t \[ d a t a - m a n t i n e - c o l o r - s c h e m e = ' l i g h t ' \] , \s * : h o s t \( \[ d a t a - m a n t i n e - c o l o r - s c h e m e = ' l i g h t ' \] \) / g,
203+ `.${ mantineScopeClassName } [data-mantine-color-scheme='light']`
204+ )
205+ . replace (
206+ / \* , \s * \* : : b e f o r e , \s * \* : : a f t e r / g,
207+ `.${ mantineScopeClassName } , .${ mantineScopeClassName } *, .${ mantineScopeClassName } *::before, .${ mantineScopeClassName } *::after`
208+ )
209+ . replace (
210+ / i n p u t , \s * b u t t o n , \s * t e x t a r e a , \s * s e l e c t / g,
211+ `.${ mantineScopeClassName } input, .${ mantineScopeClassName } button, .${ mantineScopeClassName } textarea, .${ mantineScopeClassName } select`
212+ )
213+ . replace (
214+ / b u t t o n , \s * s e l e c t / g,
215+ `.${ mantineScopeClassName } button, .${ mantineScopeClassName } select`
216+ )
217+ . replace (
218+ / f i e l d s e t : d i s a b l e d \. m a n t i n e - a c t i v e : a c t i v e / g,
219+ `.${ mantineScopeClassName } fieldset:disabled .mantine-active:active`
220+ ) ;
221+
222+ const scopedMantineDemoOverrides = `
223+ .${ mantineScopeClassName } .mantine-Button-root,
224+ .${ mantineScopeClassName } .mantine-UnstyledButton-root,
225+ .${ mantineScopeClassName } .mantine-ActionIcon-root {
226+ font-size: 14px !important;
227+ }
228+
229+ .${ mantineScopeClassName } .mantine-Button-root,
230+ .${ mantineScopeClassName } .mantine-UnstyledButton-root {
231+ min-height: 34px;
232+ }
233+
234+ .${ mantineScopeClassName } .mantine-Input-input,
235+ .${ mantineScopeClassName } .mantine-Select-input,
236+ .${ mantineScopeClassName } .mantine-MultiSelect-input,
237+ .${ mantineScopeClassName } .mantine-Combobox-option,
238+ .${ mantineScopeClassName } .mantine-PillsInput-input {
239+ font-size: 14px !important;
240+ }
241+ ` ;
242+
183243export interface IDemoPlaygroundProps {
184244 initialData ?: DenormalizedQuery ;
185245}
186246
187247export const DemoPlayground : React . FC < IDemoPlaygroundProps > = ( {
188248 initialData = initialQueryTree ,
189249} ) => {
250+ const mantineRootRef = React . useRef < HTMLDivElement > ( null ) ;
190251 const [ data , setData ] = React . useState < DenormalizedQuery > ( initialData ) ;
191252 const [ outputFormat , setOutputFormat ] = React . useState < OutputFormat > ( 'Native' ) ;
192253 const [ readOnly , setReadOnly ] = React . useState ( false ) ;
@@ -212,8 +273,10 @@ export const DemoPlayground: React.FC<IDemoPlaygroundProps> = ({
212273 const [ showSourceCode , setShowSourceCode ] = React . useState ( false ) ;
213274 const isMuiMode = customizationMode === 'mui' ;
214275 const isAntdMode = customizationMode === 'antd' ;
276+ const isMantineMode = customizationMode === 'mantine' ;
215277 const isFluentUiMode = customizationMode === 'fluentui' ;
216- const usesAdapterMode = isMuiMode || isAntdMode || isFluentUiMode ;
278+ const usesAdapterMode =
279+ isMuiMode || isAntdMode || isMantineMode || isFluentUiMode ;
217280
218281 React . useEffect ( ( ) => {
219282 if ( ! singleRootGroup && textMode ) {
@@ -227,6 +290,8 @@ export const DemoPlayground: React.FC<IDemoPlaygroundProps> = ({
227290 ? muiComponents
228291 : customizationMode === 'antd'
229292 ? antdComponents
293+ : customizationMode === 'mantine'
294+ ? mantineComponents
230295 : customizationMode === 'fluentui'
231296 ? fluentUiComponents
232297 : undefined ;
@@ -483,6 +548,16 @@ export const DemoPlayground: React.FC<IDemoPlaygroundProps> = ({
483548 />
484549 < span > Fluent UI adapter</ span >
485550 </ ToggleRow >
551+
552+ < ToggleRow >
553+ < Toggle
554+ type = "radio"
555+ name = "customization-mode"
556+ checked = { customizationMode === 'mantine' }
557+ onChange = { ( ) => setCustomizationMode ( 'mantine' ) }
558+ />
559+ < span > Mantine adapter</ span >
560+ </ ToggleRow >
486561 </ ChoiceGroup >
487562 </ Panel >
488563
@@ -495,6 +570,8 @@ export const DemoPlayground: React.FC<IDemoPlaygroundProps> = ({
495570 usesAdapterMode
496571 ? isMuiMode
497572 ? 'ThemeProvider colors style the default builder components only. The MUI adapter uses Material UI styling instead.'
573+ : isMantineMode
574+ ? 'ThemeProvider colors style the default builder components only. The Mantine adapter uses Mantine styling instead.'
498575 : isFluentUiMode
499576 ? 'ThemeProvider colors style the default builder components only. The Fluent UI adapter uses Fluent UI styling instead.'
500577 : 'ThemeProvider colors style the default builder components only. The ANTD adapter uses Ant Design styling instead.'
@@ -522,19 +599,49 @@ export const DemoPlayground: React.FC<IDemoPlaygroundProps> = ({
522599 </ OutputCard >
523600
524601 < BuilderCard >
525- < BuilderSurface >
526- { isMuiMode ? (
527- < Builder { ...builderProps } />
528- ) : isFluentUiMode ? (
529- < Builder { ...builderProps } />
530- ) : isAntdMode ? (
531- < Builder { ...builderProps } />
532- ) : (
533- < ThemeProvider colors = { themeColors } >
602+ { isMantineMode ? (
603+ < >
604+ < style > { scopedMantineStyles } </ style >
605+ < style > { scopedMantineDemoOverrides } </ style >
606+ < BuilderSurface
607+ ref = { mantineRootRef }
608+ className = { mantineScopeClassName }
609+ style = {
610+ {
611+ fontSize : '14px' ,
612+ lineHeight : 1.5 ,
613+ '--mantine-font-size-xs' : '0.75rem' ,
614+ '--mantine-font-size-sm' : '0.8125rem' ,
615+ '--mantine-font-size-md' : '0.875rem' ,
616+ '--mantine-font-size-lg' : '1rem' ,
617+ '--mantine-font-size-xl' : '1.125rem' ,
618+ } as React . CSSProperties
619+ }
620+ >
621+ < MantineProvider
622+ cssVariablesSelector = { `.${ mantineScopeClassName } ` }
623+ getRootElement = { ( ) => mantineRootRef . current ?? undefined }
624+ withGlobalClasses = { false }
625+ >
626+ < Builder { ...builderProps } />
627+ </ MantineProvider >
628+ </ BuilderSurface >
629+ </ >
630+ ) : (
631+ < BuilderSurface >
632+ { isMuiMode ? (
633+ < Builder { ...builderProps } />
634+ ) : isFluentUiMode ? (
635+ < Builder { ...builderProps } />
636+ ) : isAntdMode ? (
534637 < Builder { ...builderProps } />
535- </ ThemeProvider >
536- ) }
537- </ BuilderSurface >
638+ ) : (
639+ < ThemeProvider colors = { themeColors } >
640+ < Builder { ...builderProps } />
641+ </ ThemeProvider >
642+ ) }
643+ </ BuilderSurface >
644+ ) }
538645 </ BuilderCard >
539646
540647 < OutputCard >
0 commit comments