@qwickapps/react-framework 1.4.0 → 1.4.2
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/QUICK_START_GUIDE.md +82 -0
- package/README.md +231 -21
- package/dist/components/Html.d.ts.map +1 -1
- package/dist/components/Markdown.d.ts +1 -2
- package/dist/components/Markdown.d.ts.map +1 -1
- package/dist/components/SafeSpan.d.ts +1 -2
- package/dist/components/SafeSpan.d.ts.map +1 -1
- package/dist/components/base/Container.d.ts +32 -0
- package/dist/components/base/Container.d.ts.map +1 -0
- package/dist/components/base/ContainerView.d.ts +65 -0
- package/dist/components/base/ContainerView.d.ts.map +1 -0
- package/dist/components/base/ModelView.d.ts +37 -46
- package/dist/components/base/ModelView.d.ts.map +1 -1
- package/dist/components/base/index.d.ts +3 -2
- package/dist/components/base/index.d.ts.map +1 -1
- package/dist/components/blocks/Article.d.ts +1 -2
- package/dist/components/blocks/Article.d.ts.map +1 -1
- package/dist/components/blocks/Code-factory.d.ts +22 -0
- package/dist/components/blocks/Code-factory.d.ts.map +1 -0
- package/dist/components/blocks/Code-old.d.ts +31 -0
- package/dist/components/blocks/Code-old.d.ts.map +1 -0
- package/dist/components/blocks/Code.d.ts +30 -18
- package/dist/components/blocks/Code.d.ts.map +1 -1
- package/dist/components/blocks/HeroBlock.d.ts +1 -2
- package/dist/components/blocks/HeroBlock.d.ts.map +1 -1
- package/dist/components/blocks/Image.d.ts +1 -2
- package/dist/components/blocks/Image.d.ts.map +1 -1
- package/dist/components/blocks/Section.d.ts +1 -2
- package/dist/components/blocks/Section.d.ts.map +1 -1
- package/dist/components/blocks/Text.d.ts +35 -27
- package/dist/components/blocks/Text.d.ts.map +1 -1
- package/dist/components/buttons/Button.d.ts +1 -2
- package/dist/components/buttons/Button.d.ts.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/input/ChoiceInputField.d.ts +1 -2
- package/dist/components/input/ChoiceInputField.d.ts.map +1 -1
- package/dist/components/input/HtmlInputField.d.ts +1 -2
- package/dist/components/input/HtmlInputField.d.ts.map +1 -1
- package/dist/components/input/SelectInputField.d.ts +1 -2
- package/dist/components/input/SelectInputField.d.ts.map +1 -1
- package/dist/components/pages/Page.d.ts +29 -47
- package/dist/components/pages/Page.d.ts.map +1 -1
- package/dist/components/pages/index.d.ts +2 -3
- package/dist/components/pages/index.d.ts.map +1 -1
- package/dist/components/shared/createSerializableView.d.ts +68 -0
- package/dist/components/shared/createSerializableView.d.ts.map +1 -0
- package/dist/components/shared/viewProps.d.ts +37 -0
- package/dist/components/shared/viewProps.d.ts.map +1 -0
- package/dist/index.esm.js +21782 -22580
- package/dist/index.js +21782 -22579
- package/dist/qa/ConsoleWarningTest.d.ts +5 -0
- package/dist/qa/ConsoleWarningTest.d.ts.map +1 -0
- package/dist/qa/StorageKeyTest.d.ts +6 -0
- package/dist/qa/StorageKeyTest.d.ts.map +1 -0
- package/dist/qa/ThemeStorageKeyTest.d.ts +6 -0
- package/dist/qa/ThemeStorageKeyTest.d.ts.map +1 -0
- package/dist/schemas/CodeSchema.d.ts +2 -2
- package/dist/schemas/CodeSchema.d.ts.map +1 -1
- package/dist/schemas/ContainerSchema.d.ts +12 -0
- package/dist/schemas/ContainerSchema.d.ts.map +1 -0
- package/dist/schemas/PageTemplateSchema.d.ts +3 -3
- package/dist/schemas/PageTemplateSchema.d.ts.map +1 -1
- package/dist/schemas/ViewModelSchema.d.ts +46 -6
- package/dist/schemas/ViewModelSchema.d.ts.map +1 -1
- package/dist/schemas/ViewSchema.d.ts +65 -0
- package/dist/schemas/ViewSchema.d.ts.map +1 -0
- package/dist/schemas/index.d.ts +1 -1
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/transformers/ComponentTransformer.d.ts +27 -15
- package/dist/schemas/transformers/ComponentTransformer.d.ts.map +1 -1
- package/dist/schemas/transformers/ReactNodeTransformer.d.ts.map +1 -1
- package/dist/schemas/transformers/registry.d.ts +3 -0
- package/dist/schemas/transformers/registry.d.ts.map +1 -1
- package/dist/src/__tests__/schemas/transformers/MockSerializableComponent.d.ts +66 -0
- package/dist/src/__tests__/schemas/transformers/MockSerializableComponent.d.ts.map +1 -0
- package/dist/src/components/AccessibilityChecker.d.ts +12 -0
- package/dist/src/components/AccessibilityChecker.d.ts.map +1 -0
- package/dist/src/components/AccessibilityProvider.d.ts +64 -0
- package/dist/src/components/AccessibilityProvider.d.ts.map +1 -0
- package/dist/src/components/Breadcrumbs.d.ts +39 -0
- package/dist/src/components/Breadcrumbs.d.ts.map +1 -0
- package/dist/src/components/ErrorBoundary.d.ts +46 -0
- package/dist/src/components/ErrorBoundary.d.ts.map +1 -0
- package/dist/src/components/Html.d.ts +58 -0
- package/dist/src/components/Html.d.ts.map +1 -0
- package/dist/src/components/Logo.d.ts +56 -0
- package/dist/src/components/Logo.d.ts.map +1 -0
- package/dist/src/components/Markdown.d.ts +51 -0
- package/dist/src/components/Markdown.d.ts.map +1 -0
- package/dist/src/components/QwickApp.d.ts +69 -0
- package/dist/src/components/QwickApp.d.ts.map +1 -0
- package/dist/src/components/QwickAppsLogo.d.ts +25 -0
- package/dist/src/components/QwickAppsLogo.d.ts.map +1 -0
- package/dist/src/components/QwickIcon.d.ts +23 -0
- package/dist/src/components/QwickIcon.d.ts.map +1 -0
- package/dist/src/components/ResponsiveMenu.d.ts +38 -0
- package/dist/src/components/ResponsiveMenu.d.ts.map +1 -0
- package/dist/src/components/SafeSpan.d.ts +29 -0
- package/dist/src/components/SafeSpan.d.ts.map +1 -0
- package/dist/src/components/Scaffold.d.ts +57 -0
- package/dist/src/components/Scaffold.d.ts.map +1 -0
- package/dist/src/components/base/Container.d.ts +33 -0
- package/dist/src/components/base/Container.d.ts.map +1 -0
- package/dist/src/components/base/ModelView.d.ts +92 -0
- package/dist/src/components/base/ModelView.d.ts.map +1 -0
- package/dist/src/components/base/index.d.ts +12 -0
- package/dist/src/components/base/index.d.ts.map +1 -0
- package/dist/src/components/blocks/Article.d.ts +32 -0
- package/dist/src/components/blocks/Article.d.ts.map +1 -0
- package/dist/src/components/blocks/CardListGrid.d.ts +23 -0
- package/dist/src/components/blocks/CardListGrid.d.ts.map +1 -0
- package/dist/src/components/blocks/Code.d.ts +37 -0
- package/dist/src/components/blocks/Code.d.ts.map +1 -0
- package/dist/src/components/blocks/Content.d.ts +24 -0
- package/dist/src/components/blocks/Content.d.ts.map +1 -0
- package/dist/src/components/blocks/CoverImageHeader.d.ts +44 -0
- package/dist/src/components/blocks/CoverImageHeader.d.ts.map +1 -0
- package/dist/src/components/blocks/FeatureCard.d.ts +66 -0
- package/dist/src/components/blocks/FeatureCard.d.ts.map +1 -0
- package/dist/src/components/blocks/FeatureGrid.d.ts +48 -0
- package/dist/src/components/blocks/FeatureGrid.d.ts.map +1 -0
- package/dist/src/components/blocks/Footer.d.ts +56 -0
- package/dist/src/components/blocks/Footer.d.ts.map +1 -0
- package/dist/src/components/blocks/HeroBlock.d.ts +55 -0
- package/dist/src/components/blocks/HeroBlock.d.ts.map +1 -0
- package/dist/src/components/blocks/Image.d.ts +40 -0
- package/dist/src/components/blocks/Image.d.ts.map +1 -0
- package/dist/src/components/blocks/PageBannerHeader.d.ts +30 -0
- package/dist/src/components/blocks/PageBannerHeader.d.ts.map +1 -0
- package/dist/src/components/blocks/ProductCard.d.ts +57 -0
- package/dist/src/components/blocks/ProductCard.d.ts.map +1 -0
- package/dist/src/components/blocks/Section.d.ts +45 -0
- package/dist/src/components/blocks/Section.d.ts.map +1 -0
- package/dist/src/components/blocks/Text.d.ts +34 -0
- package/dist/src/components/blocks/Text.d.ts.map +1 -0
- package/dist/src/components/blocks/index.d.ts +41 -0
- package/dist/src/components/blocks/index.d.ts.map +1 -0
- package/dist/src/components/buttons/Button.d.ts +41 -0
- package/dist/src/components/buttons/Button.d.ts.map +1 -0
- package/dist/src/components/buttons/PaletteSwitcher.d.ts +24 -0
- package/dist/src/components/buttons/PaletteSwitcher.d.ts.map +1 -0
- package/dist/src/components/buttons/ThemeSwitcher.d.ts +24 -0
- package/dist/src/components/buttons/ThemeSwitcher.d.ts.map +1 -0
- package/dist/src/components/buttons/index.d.ts +11 -0
- package/dist/src/components/buttons/index.d.ts.map +1 -0
- package/dist/src/components/forms/FormBlock.d.ts +51 -0
- package/dist/src/components/forms/FormBlock.d.ts.map +1 -0
- package/dist/src/components/forms/index.d.ts +8 -0
- package/dist/src/components/forms/index.d.ts.map +1 -0
- package/dist/src/components/index.d.ts +41 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/input/ChoiceInputField.d.ts +29 -0
- package/dist/src/components/input/ChoiceInputField.d.ts.map +1 -0
- package/dist/src/components/input/HtmlInputField.d.ts +33 -0
- package/dist/src/components/input/HtmlInputField.d.ts.map +1 -0
- package/dist/src/components/input/SelectInputField.d.ts +31 -0
- package/dist/src/components/input/SelectInputField.d.ts.map +1 -0
- package/dist/src/components/input/SwitchInputField.d.ts +27 -0
- package/dist/src/components/input/SwitchInputField.d.ts.map +1 -0
- package/dist/src/components/input/TextField.d.ts +18 -0
- package/dist/src/components/input/TextField.d.ts.map +1 -0
- package/dist/src/components/input/TextInputField.d.ts +34 -0
- package/dist/src/components/input/TextInputField.d.ts.map +1 -0
- package/dist/src/components/input/index.d.ts +19 -0
- package/dist/src/components/input/index.d.ts.map +1 -0
- package/dist/src/components/layout/CollapsibleLayout/CollapsibleLayout.d.ts +34 -0
- package/dist/src/components/layout/CollapsibleLayout/CollapsibleLayout.d.ts.map +1 -0
- package/dist/src/components/layout/CollapsibleLayout/index.d.ts +9 -0
- package/dist/src/components/layout/CollapsibleLayout/index.d.ts.map +1 -0
- package/dist/src/components/layout/GridCell.d.ts +32 -0
- package/dist/src/components/layout/GridCell.d.ts.map +1 -0
- package/dist/src/components/layout/GridCellWrapper.d.ts +46 -0
- package/dist/src/components/layout/GridCellWrapper.d.ts.map +1 -0
- package/dist/src/components/layout/GridLayout.d.ts +50 -0
- package/dist/src/components/layout/GridLayout.d.ts.map +1 -0
- package/dist/src/components/layout/index.d.ts +14 -0
- package/dist/src/components/layout/index.d.ts.map +1 -0
- package/dist/src/components/menu/Menu.d.ts +1 -0
- package/dist/src/components/menu/Menu.d.ts.map +1 -0
- package/dist/src/components/menu/MenuItem.d.ts +31 -0
- package/dist/src/components/menu/MenuItem.d.ts.map +1 -0
- package/dist/src/components/menu/index.d.ts +7 -0
- package/dist/src/components/menu/index.d.ts.map +1 -0
- package/dist/src/components/pages/FormPage.d.ts +66 -0
- package/dist/src/components/pages/FormPage.d.ts.map +1 -0
- package/dist/src/components/pages/Page.d.ts +68 -0
- package/dist/src/components/pages/Page.d.ts.map +1 -0
- package/dist/src/components/pages/index.d.ts +10 -0
- package/dist/src/components/pages/index.d.ts.map +1 -0
- package/dist/src/components/shared/createSerializableView.d.ts +81 -0
- package/dist/src/components/shared/createSerializableView.d.ts.map +1 -0
- package/dist/src/components/shared/viewProps.d.ts +37 -0
- package/dist/src/components/shared/viewProps.d.ts.map +1 -0
- package/dist/src/config/AppConfig.d.ts +49 -0
- package/dist/src/config/AppConfig.d.ts.map +1 -0
- package/dist/src/config/AppConfigBuilder.d.ts +75 -0
- package/dist/src/config/AppConfigBuilder.d.ts.map +1 -0
- package/dist/src/config/index.d.ts +13 -0
- package/dist/src/config/index.d.ts.map +1 -0
- package/dist/src/config/types.d.ts +130 -0
- package/dist/src/config/types.d.ts.map +1 -0
- package/dist/src/config.d.ts +15 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/contexts/DataContext.d.ts +139 -0
- package/dist/src/contexts/DataContext.d.ts.map +1 -0
- package/dist/src/contexts/DimensionsContext.d.ts +42 -0
- package/dist/src/contexts/DimensionsContext.d.ts.map +1 -0
- package/dist/src/contexts/PaletteContext.d.ts +53 -0
- package/dist/src/contexts/PaletteContext.d.ts.map +1 -0
- package/dist/src/contexts/PrintModeContext.d.ts +27 -0
- package/dist/src/contexts/PrintModeContext.d.ts.map +1 -0
- package/dist/src/contexts/QwickAppContext.d.ts +71 -0
- package/dist/src/contexts/QwickAppContext.d.ts.map +1 -0
- package/dist/src/contexts/ThemeContext.d.ts +65 -0
- package/dist/src/contexts/ThemeContext.d.ts.map +1 -0
- package/dist/src/contexts/index.d.ts +11 -0
- package/dist/src/contexts/index.d.ts.map +1 -0
- package/dist/src/hooks/index.d.ts +12 -0
- package/dist/src/hooks/index.d.ts.map +1 -0
- package/dist/src/hooks/useBaseProps.d.ts +101 -0
- package/dist/src/hooks/useBaseProps.d.ts.map +1 -0
- package/dist/src/hooks/useDataBinding.d.ts +22 -0
- package/dist/src/hooks/useDataBinding.d.ts.map +1 -0
- package/dist/src/hooks/usePrintMode.d.ts +39 -0
- package/dist/src/hooks/usePrintMode.d.ts.map +1 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/palettes/PaletteAutumn.d.ts +10 -0
- package/dist/src/palettes/PaletteAutumn.d.ts.map +1 -0
- package/dist/src/palettes/PaletteCosmic.d.ts +10 -0
- package/dist/src/palettes/PaletteCosmic.d.ts.map +1 -0
- package/dist/src/palettes/PaletteDefault.d.ts +10 -0
- package/dist/src/palettes/PaletteDefault.d.ts.map +1 -0
- package/dist/src/palettes/PaletteOcean.d.ts +10 -0
- package/dist/src/palettes/PaletteOcean.d.ts.map +1 -0
- package/dist/src/palettes/PaletteSpring.d.ts +10 -0
- package/dist/src/palettes/PaletteSpring.d.ts.map +1 -0
- package/dist/src/palettes/PaletteWinter.d.ts +10 -0
- package/dist/src/palettes/PaletteWinter.d.ts.map +1 -0
- package/dist/src/palettes/index.d.ts +13 -0
- package/dist/src/palettes/index.d.ts.map +1 -0
- package/dist/src/schemas/ActionSchema.d.ts +21 -0
- package/dist/src/schemas/ActionSchema.d.ts.map +1 -0
- package/dist/src/schemas/ArticleSchema.d.ts +13 -0
- package/dist/src/schemas/ArticleSchema.d.ts.map +1 -0
- package/dist/src/schemas/ButtonSchema.d.ts +19 -0
- package/dist/src/schemas/ButtonSchema.d.ts.map +1 -0
- package/dist/src/schemas/CardListGridSchema.d.ts +17 -0
- package/dist/src/schemas/CardListGridSchema.d.ts.map +1 -0
- package/dist/src/schemas/ChoiceInputFieldSchema.d.ts +18 -0
- package/dist/src/schemas/ChoiceInputFieldSchema.d.ts.map +1 -0
- package/dist/src/schemas/CodeSchema.d.ts +18 -0
- package/dist/src/schemas/CodeSchema.d.ts.map +1 -0
- package/dist/src/schemas/CollapsibleLayoutSchema.d.ts +32 -0
- package/dist/src/schemas/CollapsibleLayoutSchema.d.ts.map +1 -0
- package/dist/src/schemas/ContainerSchema.d.ts +12 -0
- package/dist/src/schemas/ContainerSchema.d.ts.map +1 -0
- package/dist/src/schemas/ContentSchema.d.ts +21 -0
- package/dist/src/schemas/ContentSchema.d.ts.map +1 -0
- package/dist/src/schemas/CoverImageHeaderSchema.d.ts +28 -0
- package/dist/src/schemas/CoverImageHeaderSchema.d.ts.map +1 -0
- package/dist/src/schemas/FeatureCardSchema.d.ts +28 -0
- package/dist/src/schemas/FeatureCardSchema.d.ts.map +1 -0
- package/dist/src/schemas/FeatureGridSchema.d.ts +17 -0
- package/dist/src/schemas/FeatureGridSchema.d.ts.map +1 -0
- package/dist/src/schemas/FeatureItemSchema.d.ts +16 -0
- package/dist/src/schemas/FeatureItemSchema.d.ts.map +1 -0
- package/dist/src/schemas/FooterItemSchema.d.ts +15 -0
- package/dist/src/schemas/FooterItemSchema.d.ts.map +1 -0
- package/dist/src/schemas/FooterSchema.d.ts +20 -0
- package/dist/src/schemas/FooterSchema.d.ts.map +1 -0
- package/dist/src/schemas/FooterSectionSchema.d.ts +15 -0
- package/dist/src/schemas/FooterSectionSchema.d.ts.map +1 -0
- package/dist/src/schemas/FormBlockSchema.d.ts +19 -0
- package/dist/src/schemas/FormBlockSchema.d.ts.map +1 -0
- package/dist/src/schemas/GridCellSchema.d.ts +23 -0
- package/dist/src/schemas/GridCellSchema.d.ts.map +1 -0
- package/dist/src/schemas/GridLayoutSchema.d.ts +21 -0
- package/dist/src/schemas/GridLayoutSchema.d.ts.map +1 -0
- package/dist/src/schemas/HeaderActionSchema.d.ts +17 -0
- package/dist/src/schemas/HeaderActionSchema.d.ts.map +1 -0
- package/dist/src/schemas/HeroBlockSchema.d.ts +22 -0
- package/dist/src/schemas/HeroBlockSchema.d.ts.map +1 -0
- package/dist/src/schemas/HtmlInputFieldSchema.d.ts +18 -0
- package/dist/src/schemas/HtmlInputFieldSchema.d.ts.map +1 -0
- package/dist/src/schemas/HtmlSchema.d.ts +14 -0
- package/dist/src/schemas/HtmlSchema.d.ts.map +1 -0
- package/dist/src/schemas/ImageSchema.d.ts +32 -0
- package/dist/src/schemas/ImageSchema.d.ts.map +1 -0
- package/dist/src/schemas/LogoSchema.d.ts +35 -0
- package/dist/src/schemas/LogoSchema.d.ts.map +1 -0
- package/dist/src/schemas/MarkdownSchema.d.ts +14 -0
- package/dist/src/schemas/MarkdownSchema.d.ts.map +1 -0
- package/dist/src/schemas/MetadataItemSchema.d.ts +13 -0
- package/dist/src/schemas/MetadataItemSchema.d.ts.map +1 -0
- package/dist/src/schemas/PageBannerHeaderSchema.d.ts +28 -0
- package/dist/src/schemas/PageBannerHeaderSchema.d.ts.map +1 -0
- package/dist/src/schemas/PageTemplateSchema.d.ts +31 -0
- package/dist/src/schemas/PageTemplateSchema.d.ts.map +1 -0
- package/dist/src/schemas/PaletteSwitcherSchema.d.ts +16 -0
- package/dist/src/schemas/PaletteSwitcherSchema.d.ts.map +1 -0
- package/dist/src/schemas/PrintConfigSchema.d.ts +31 -0
- package/dist/src/schemas/PrintConfigSchema.d.ts.map +1 -0
- package/dist/src/schemas/ProductCardSchema.d.ts +39 -0
- package/dist/src/schemas/ProductCardSchema.d.ts.map +1 -0
- package/dist/src/schemas/SafeSpanSchema.d.ts +13 -0
- package/dist/src/schemas/SafeSpanSchema.d.ts.map +1 -0
- package/dist/src/schemas/SectionSchema.d.ts +16 -0
- package/dist/src/schemas/SectionSchema.d.ts.map +1 -0
- package/dist/src/schemas/SelectInputFieldSchema.d.ts +27 -0
- package/dist/src/schemas/SelectInputFieldSchema.d.ts.map +1 -0
- package/dist/src/schemas/SwitchInputFieldSchema.d.ts +18 -0
- package/dist/src/schemas/SwitchInputFieldSchema.d.ts.map +1 -0
- package/dist/src/schemas/TextInputFieldSchema.d.ts +22 -0
- package/dist/src/schemas/TextInputFieldSchema.d.ts.map +1 -0
- package/dist/src/schemas/TextSchema.d.ts +37 -0
- package/dist/src/schemas/TextSchema.d.ts.map +1 -0
- package/dist/src/schemas/ThemeSwitcherSchema.d.ts +19 -0
- package/dist/src/schemas/ThemeSwitcherSchema.d.ts.map +1 -0
- package/dist/src/schemas/ViewSchema.d.ts +66 -0
- package/dist/src/schemas/ViewSchema.d.ts.map +1 -0
- package/dist/src/schemas/index.d.ts +47 -0
- package/dist/src/schemas/index.d.ts.map +1 -0
- package/dist/src/schemas/transformers/ComponentTransformer.d.ts +128 -0
- package/dist/src/schemas/transformers/ComponentTransformer.d.ts.map +1 -0
- package/dist/src/schemas/transformers/ReactNodeTransformer.d.ts +53 -0
- package/dist/src/schemas/transformers/ReactNodeTransformer.d.ts.map +1 -0
- package/dist/src/schemas/transformers/registry.d.ts +18 -0
- package/dist/src/schemas/transformers/registry.d.ts.map +1 -0
- package/dist/src/schemas/types/Serializable.d.ts +46 -0
- package/dist/src/schemas/types/Serializable.d.ts.map +1 -0
- package/dist/src/stories/_templates/SerializationTemplate.d.ts +44 -0
- package/dist/src/stories/_templates/SerializationTemplate.d.ts.map +1 -0
- package/dist/src/templates/TemplateResolver.d.ts +52 -0
- package/dist/src/templates/TemplateResolver.d.ts.map +1 -0
- package/dist/src/templates/index.d.ts +7 -0
- package/dist/src/templates/index.d.ts.map +1 -0
- package/dist/src/types/CacheProvider.d.ts +18 -0
- package/dist/src/types/CacheProvider.d.ts.map +1 -0
- package/dist/src/types/CollapsibleLayout.d.ts +142 -0
- package/dist/src/types/CollapsibleLayout.d.ts.map +1 -0
- package/dist/src/types/ContentProxy.d.ts +47 -0
- package/dist/src/types/ContentProxy.d.ts.map +1 -0
- package/dist/src/types/DataTypes.d.ts +185 -0
- package/dist/src/types/DataTypes.d.ts.map +1 -0
- package/dist/src/types/TemplateProvider.d.ts +10 -0
- package/dist/src/types/TemplateProvider.d.ts.map +1 -0
- package/dist/src/types/TemplateResolver.d.ts +23 -0
- package/dist/src/types/TemplateResolver.d.ts.map +1 -0
- package/dist/src/types/index.d.ts +82 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/utils/breakpoints.d.ts +35 -0
- package/dist/src/utils/breakpoints.d.ts.map +1 -0
- package/dist/src/utils/cssUtils.d.ts +17 -0
- package/dist/src/utils/cssUtils.d.ts.map +1 -0
- package/dist/src/utils/customPaletteManager.d.ts +8 -0
- package/dist/src/utils/customPaletteManager.d.ts.map +1 -0
- package/dist/src/utils/dimensions.d.ts +34 -0
- package/dist/src/utils/dimensions.d.ts.map +1 -0
- package/dist/src/utils/htmlTransform.d.ts +44 -0
- package/dist/src/utils/htmlTransform.d.ts.map +1 -0
- package/dist/src/utils/index.d.ts +16 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/logger.d.ts +26 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/src/utils/paletteUtils.d.ts +38 -0
- package/dist/src/utils/paletteUtils.d.ts.map +1 -0
- package/dist/src/utils/persistenceUtils.d.ts +31 -0
- package/dist/src/utils/persistenceUtils.d.ts.map +1 -0
- package/dist/src/utils/reactUtils.d.ts +33 -0
- package/dist/src/utils/reactUtils.d.ts.map +1 -0
- package/dist/src/utils/spacing.d.ts +34 -0
- package/dist/src/utils/spacing.d.ts.map +1 -0
- package/dist/src/utils/themePerformanceMonitor.d.ts +32 -0
- package/dist/src/utils/themePerformanceMonitor.d.ts.map +1 -0
- package/dist/src/utils/themeUtils.d.ts +27 -0
- package/dist/src/utils/themeUtils.d.ts.map +1 -0
- package/dist/utils/cssUtils.d.ts +17 -0
- package/dist/utils/cssUtils.d.ts.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +5 -2
- package/scripts/bundle-css.cjs +27 -0
- package/scripts/create-project.sh +28 -0
- package/scripts/create-qwickapps-project.js +284 -0
- package/src/__tests__/components/base/Container.test.tsx +966 -0
- package/src/__tests__/schemas/PageTemplateSchema.test.ts +1 -1
- package/src/__tests__/schemas/ViewSchema.test.ts +805 -0
- package/src/__tests__/schemas/builders.test.ts +2 -2
- package/src/__tests__/schemas/transformers/ComponentTransformer.test.ts +19 -19
- package/src/__tests__/schemas/transformers/CrossBrowserCompatibility.test.ts +13 -13
- package/src/__tests__/schemas/transformers/SerializationErrorHandling.test.ts +39 -39
- package/src/__tests__/schemas/transformers/SerializationPerformance.test.ts +14 -14
- package/src/__tests__/schemas/transformers/TestAutomation.test.ts +8 -8
- package/src/__tests__/schemas/transformers/nested-serialization.test.tsx +181 -0
- package/src/__tests__/schemas/transformers/round-trip-component-serialization.test.tsx +458 -0
- package/src/__tests__/test_image_accessibility.test.tsx +226 -0
- package/src/__tests__/utils/optional-logging.test.ts +3 -3
- package/src/components/Html.tsx +24 -15
- package/src/components/Logo.tsx +2 -2
- package/src/components/Markdown.tsx +2 -7
- package/src/components/SafeSpan.tsx +2 -7
- package/src/components/base/Container.tsx +61 -0
- package/src/components/base/ModelView.tsx +225 -91
- package/src/components/base/index.ts +3 -2
- package/src/components/blocks/Article.tsx +2 -7
- package/src/components/blocks/CardListGrid.tsx +2 -2
- package/src/components/blocks/Code.tsx +91 -179
- package/src/components/blocks/Content.tsx +2 -2
- package/src/components/blocks/CoverImageHeader.tsx +2 -2
- package/src/components/blocks/HeroBlock.tsx +54 -146
- package/src/components/blocks/Image.tsx +82 -196
- package/src/components/blocks/PageBannerHeader.tsx +2 -2
- package/src/components/blocks/Section.tsx +79 -181
- package/src/components/blocks/Text.tsx +100 -198
- package/src/components/buttons/Button.tsx +85 -183
- package/src/components/buttons/PaletteSwitcher.tsx +2 -2
- package/src/components/buttons/ThemeSwitcher.tsx +2 -2
- package/src/components/forms/FormBlock.tsx +2 -2
- package/src/components/index.ts +5 -0
- package/src/components/input/ChoiceInputField.tsx +76 -160
- package/src/components/input/HtmlInputField.tsx +141 -264
- package/src/components/input/SelectInputField.tsx +48 -153
- package/src/components/input/SwitchInputField.tsx +41 -139
- package/src/components/input/TextInputField.tsx +39 -116
- package/src/components/layout/GridCell.tsx +36 -122
- package/src/components/layout/GridLayout.tsx +55 -127
- package/src/components/pages/Page.tsx +268 -276
- package/src/components/pages/index.ts +2 -3
- package/src/components/shared/createSerializableView.tsx +280 -0
- package/src/components/shared/viewProps.ts +207 -0
- package/src/config/__tests__/AppConfigBuilder.test.ts +2 -2
- package/src/contexts/DataContext.tsx +1 -1
- package/src/schemas/ButtonSchema.ts +3 -2
- package/src/schemas/CardListGridSchema.ts +3 -2
- package/src/schemas/ChoiceInputFieldSchema.ts +3 -2
- package/src/schemas/CodeSchema.ts +8 -6
- package/src/schemas/ContainerSchema.ts +25 -0
- package/src/schemas/FeatureCardSchema.ts +1 -1
- package/src/schemas/FormBlockSchema.ts +3 -2
- package/src/schemas/GridCellSchema.ts +4 -10
- package/src/schemas/GridLayoutSchema.ts +8 -14
- package/src/schemas/HeroBlockSchema.ts +3 -2
- package/src/schemas/HtmlInputFieldSchema.ts +3 -2
- package/src/schemas/ImageSchema.ts +3 -2
- package/src/schemas/PageTemplateSchema.ts +5 -5
- package/src/schemas/SectionSchema.ts +4 -12
- package/src/schemas/SelectInputFieldSchema.ts +3 -2
- package/src/schemas/SwitchInputFieldSchema.ts +2 -2
- package/src/schemas/TextInputFieldSchema.ts +3 -2
- package/src/schemas/ViewSchema.ts +570 -0
- package/src/schemas/index.ts +1 -1
- package/src/schemas/transformers/ComponentTransformer.ts +185 -163
- package/src/schemas/transformers/ReactNodeTransformer.ts +31 -28
- package/src/schemas/transformers/registry.ts +17 -10
- package/src/stories/Button.stories.tsx +24 -0
- package/src/stories/ChoiceInputField.stories.tsx +28 -1
- package/src/stories/Code.stories.tsx +61 -1
- package/src/stories/Container.stories.tsx +954 -0
- package/src/stories/FormBlock.stories.tsx +54 -0
- package/src/stories/FormComponents.stories.tsx +8 -13
- package/src/stories/GridCell.stories.tsx +23 -64
- package/src/stories/GridLayout.stories.tsx +22 -47
- package/src/stories/HeroBlock.stories.tsx +28 -0
- package/src/stories/HtmlInputField.stories.tsx +23 -1
- package/src/stories/Image.stories.tsx +45 -233
- package/src/stories/Markdown.stories.tsx +1 -1
- package/src/stories/Section.stories.tsx +38 -4
- package/src/stories/SelectInputField.stories.tsx +26 -1
- package/src/stories/Text.stories.tsx +22 -54
- package/src/stories/TextInputField.stories.tsx +24 -1
- package/src/stories/_templates/SerializationTemplate.tsx +165 -0
- package/src/templates/TemplateResolver.ts +2 -2
- package/src/types/CollapsibleLayout.ts +2 -2
- package/src/utils/cssUtils.ts +49 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/logger.ts +13 -13
- package/src/__tests__/components/base/ModelView.test.tsx +0 -220
- package/src/__tests__/schemas/ViewModelSchema.test.ts +0 -80
- package/src/components/blocks/Code.md +0 -529
- package/src/schemas/README.md +0 -661
- package/src/schemas/ViewModelSchema.ts +0 -115
- package/src/tests/ConsoleWarningTest.tsx +0 -30
- package/src/tests/StorageKeyTest.tsx +0 -110
- package/src/tests/ThemeStorageKeyTest.tsx +0 -114
|
@@ -0,0 +1,966 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Container Component Tests
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive unit tests for the new Container component
|
|
5
|
+
* covering all functionality including props conversion, rendering,
|
|
6
|
+
* serialization, and error handling.
|
|
7
|
+
*
|
|
8
|
+
* Copyright (c) 2025 QwickApps.com. All rights reserved.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
13
|
+
import '@testing-library/jest-dom';
|
|
14
|
+
import { ThemeProvider, PaletteProvider } from '../../../contexts';
|
|
15
|
+
import { Container, type ContainerProps } from '../../../components/base/Container';
|
|
16
|
+
import { useBaseProps } from '../../../hooks/useBaseProps';
|
|
17
|
+
import { resolveDimensions } from '../../../utils/dimensions';
|
|
18
|
+
import { resolveSpacingProps } from '../../../utils/spacing';
|
|
19
|
+
|
|
20
|
+
// Mock the utility functions
|
|
21
|
+
jest.mock('../../../utils/dimensions', () => ({
|
|
22
|
+
resolveDimensions: jest.fn()
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
jest.mock('../../../utils/spacing', () => ({
|
|
26
|
+
resolveSpacingProps: jest.fn()
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
jest.mock('../../../hooks/useBaseProps', () => ({
|
|
30
|
+
useBaseProps: jest.fn(),
|
|
31
|
+
QWICKAPP_COMPONENT: Symbol('QwickAppComponent')
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
const mockResolveDimensions = resolveDimensions as jest.MockedFunction<typeof resolveDimensions>;
|
|
35
|
+
const mockResolveSpacingProps = resolveSpacingProps as jest.MockedFunction<typeof resolveSpacingProps>;
|
|
36
|
+
const mockUseBaseProps = useBaseProps as jest.MockedFunction<typeof useBaseProps>;
|
|
37
|
+
|
|
38
|
+
// Test wrapper component
|
|
39
|
+
const TestWrapper: React.FC<{ children: React.ReactNode }> = ({ children }) => (
|
|
40
|
+
<ThemeProvider>
|
|
41
|
+
<PaletteProvider>
|
|
42
|
+
{children}
|
|
43
|
+
</PaletteProvider>
|
|
44
|
+
</ThemeProvider>
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
describe('Container', () => {
|
|
48
|
+
beforeEach(() => {
|
|
49
|
+
// Reset all mocks
|
|
50
|
+
jest.clearAllMocks();
|
|
51
|
+
|
|
52
|
+
// Default mock implementations
|
|
53
|
+
mockResolveDimensions.mockReturnValue({
|
|
54
|
+
width: undefined,
|
|
55
|
+
height: undefined,
|
|
56
|
+
minWidth: undefined,
|
|
57
|
+
minHeight: undefined,
|
|
58
|
+
maxWidth: undefined,
|
|
59
|
+
maxHeight: undefined
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
mockResolveSpacingProps.mockReturnValue({});
|
|
63
|
+
|
|
64
|
+
mockUseBaseProps.mockReturnValue({
|
|
65
|
+
gridProps: null,
|
|
66
|
+
styleProps: {
|
|
67
|
+
className: undefined,
|
|
68
|
+
sx: {},
|
|
69
|
+
style: undefined
|
|
70
|
+
},
|
|
71
|
+
htmlProps: {},
|
|
72
|
+
restProps: {}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe('Basic Rendering', () => {
|
|
77
|
+
it('renders without props', () => {
|
|
78
|
+
render(
|
|
79
|
+
<TestWrapper>
|
|
80
|
+
<Container />
|
|
81
|
+
</TestWrapper>
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
expect(document.querySelector('div')).toBeInTheDocument();
|
|
85
|
+
expect(mockUseBaseProps).toHaveBeenCalledWith({});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('renders children correctly', () => {
|
|
89
|
+
render(
|
|
90
|
+
<TestWrapper>
|
|
91
|
+
<Container>
|
|
92
|
+
<span>Test Content</span>
|
|
93
|
+
</Container>
|
|
94
|
+
</TestWrapper>
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
expect(screen.getByText('Test Content')).toBeInTheDocument();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('renders multiple children correctly', () => {
|
|
101
|
+
render(
|
|
102
|
+
<TestWrapper>
|
|
103
|
+
<Container>
|
|
104
|
+
<h1>Title</h1>
|
|
105
|
+
<p>Paragraph</p>
|
|
106
|
+
<span>Span</span>
|
|
107
|
+
</Container>
|
|
108
|
+
</TestWrapper>
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
expect(screen.getByText('Title')).toBeInTheDocument();
|
|
112
|
+
expect(screen.getByText('Paragraph')).toBeInTheDocument();
|
|
113
|
+
expect(screen.getByText('Span')).toBeInTheDocument();
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe('Grid Props Conversion', () => {
|
|
118
|
+
it('converts span prop from string to proper type', () => {
|
|
119
|
+
render(
|
|
120
|
+
<TestWrapper>
|
|
121
|
+
<Container span="6" />
|
|
122
|
+
</TestWrapper>
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const expectedProps = expect.objectContaining({
|
|
126
|
+
span: 6
|
|
127
|
+
});
|
|
128
|
+
expect(mockUseBaseProps).toHaveBeenCalledWith(expectedProps);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('handles span "auto" value', () => {
|
|
132
|
+
render(
|
|
133
|
+
<TestWrapper>
|
|
134
|
+
<Container span="auto" />
|
|
135
|
+
</TestWrapper>
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
const expectedProps = expect.objectContaining({
|
|
139
|
+
span: 'auto'
|
|
140
|
+
});
|
|
141
|
+
expect(mockUseBaseProps).toHaveBeenCalledWith(expectedProps);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('handles span "grow" value', () => {
|
|
145
|
+
render(
|
|
146
|
+
<TestWrapper>
|
|
147
|
+
<Container span="grow" />
|
|
148
|
+
</TestWrapper>
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
const expectedProps = expect.objectContaining({
|
|
152
|
+
span: 'grow'
|
|
153
|
+
});
|
|
154
|
+
expect(mockUseBaseProps).toHaveBeenCalledWith(expectedProps);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('converts all breakpoint props correctly', () => {
|
|
158
|
+
render(
|
|
159
|
+
<TestWrapper>
|
|
160
|
+
<Container
|
|
161
|
+
xs="12"
|
|
162
|
+
sm="6"
|
|
163
|
+
md="4"
|
|
164
|
+
lg="3"
|
|
165
|
+
xl="2"
|
|
166
|
+
/>
|
|
167
|
+
</TestWrapper>
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
const expectedProps = expect.objectContaining({
|
|
171
|
+
xs: 12,
|
|
172
|
+
sm: 6,
|
|
173
|
+
md: 4,
|
|
174
|
+
lg: 3,
|
|
175
|
+
xl: 2
|
|
176
|
+
});
|
|
177
|
+
expect(mockUseBaseProps).toHaveBeenCalledWith(expectedProps);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('handles invalid grid values by returning undefined', () => {
|
|
181
|
+
render(
|
|
182
|
+
<TestWrapper>
|
|
183
|
+
<Container
|
|
184
|
+
span="invalid"
|
|
185
|
+
xs="not-a-number"
|
|
186
|
+
/>
|
|
187
|
+
</TestWrapper>
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
const expectedProps = expect.objectContaining({
|
|
191
|
+
span: undefined,
|
|
192
|
+
xs: undefined
|
|
193
|
+
});
|
|
194
|
+
expect(mockUseBaseProps).toHaveBeenCalledWith(expectedProps);
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
describe('Dimension Props', () => {
|
|
199
|
+
it('passes dimension props through correctly', () => {
|
|
200
|
+
render(
|
|
201
|
+
<TestWrapper>
|
|
202
|
+
<Container
|
|
203
|
+
width="medium"
|
|
204
|
+
height="200px"
|
|
205
|
+
minWidth="100px"
|
|
206
|
+
minHeight="50px"
|
|
207
|
+
maxWidth="large"
|
|
208
|
+
maxHeight="80vh"
|
|
209
|
+
/>
|
|
210
|
+
</TestWrapper>
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
const expectedProps = expect.objectContaining({
|
|
214
|
+
width: 'medium',
|
|
215
|
+
height: '200px',
|
|
216
|
+
minWidth: '100px',
|
|
217
|
+
minHeight: '50px',
|
|
218
|
+
maxWidth: 'large',
|
|
219
|
+
maxHeight: '80vh'
|
|
220
|
+
});
|
|
221
|
+
expect(mockUseBaseProps).toHaveBeenCalledWith(expectedProps);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('handles undefined dimension props', () => {
|
|
225
|
+
render(
|
|
226
|
+
<TestWrapper>
|
|
227
|
+
<Container />
|
|
228
|
+
</TestWrapper>
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
const call = mockUseBaseProps.mock.calls[0][0];
|
|
232
|
+
expect(call.width).toBeUndefined();
|
|
233
|
+
expect(call.height).toBeUndefined();
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
describe('Spacing Props', () => {
|
|
238
|
+
it('passes all spacing props correctly', () => {
|
|
239
|
+
render(
|
|
240
|
+
<TestWrapper>
|
|
241
|
+
<Container
|
|
242
|
+
padding="medium"
|
|
243
|
+
paddingTop="small"
|
|
244
|
+
paddingRight="large"
|
|
245
|
+
paddingBottom="tiny"
|
|
246
|
+
paddingLeft="huge"
|
|
247
|
+
paddingX="medium"
|
|
248
|
+
paddingY="small"
|
|
249
|
+
margin="large"
|
|
250
|
+
marginTop="medium"
|
|
251
|
+
marginRight="small"
|
|
252
|
+
marginBottom="large"
|
|
253
|
+
marginLeft="tiny"
|
|
254
|
+
marginX="medium"
|
|
255
|
+
marginY="large"
|
|
256
|
+
/>
|
|
257
|
+
</TestWrapper>
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
const expectedProps = expect.objectContaining({
|
|
261
|
+
padding: 'medium',
|
|
262
|
+
paddingTop: 'small',
|
|
263
|
+
paddingRight: 'large',
|
|
264
|
+
paddingBottom: 'tiny',
|
|
265
|
+
paddingLeft: 'huge',
|
|
266
|
+
paddingX: 'medium',
|
|
267
|
+
paddingY: 'small',
|
|
268
|
+
margin: 'large',
|
|
269
|
+
marginTop: 'medium',
|
|
270
|
+
marginRight: 'small',
|
|
271
|
+
marginBottom: 'large',
|
|
272
|
+
marginLeft: 'tiny',
|
|
273
|
+
marginX: 'medium',
|
|
274
|
+
marginY: 'large'
|
|
275
|
+
});
|
|
276
|
+
expect(mockUseBaseProps).toHaveBeenCalledWith(expectedProps);
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
describe('Background Props', () => {
|
|
281
|
+
it('passes background props correctly', () => {
|
|
282
|
+
render(
|
|
283
|
+
<TestWrapper>
|
|
284
|
+
<Container
|
|
285
|
+
background="#ffffff"
|
|
286
|
+
backgroundImage="/test-image.jpg"
|
|
287
|
+
backgroundGradient="linear-gradient(45deg, red, blue)"
|
|
288
|
+
/>
|
|
289
|
+
</TestWrapper>
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
const expectedProps = expect.objectContaining({
|
|
293
|
+
background: '#ffffff',
|
|
294
|
+
backgroundImage: '/test-image.jpg',
|
|
295
|
+
backgroundGradient: 'linear-gradient(45deg, red, blue)'
|
|
296
|
+
});
|
|
297
|
+
expect(mockUseBaseProps).toHaveBeenCalledWith(expectedProps);
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
describe('Style Props', () => {
|
|
302
|
+
it('passes className through directly', () => {
|
|
303
|
+
render(
|
|
304
|
+
<TestWrapper>
|
|
305
|
+
<Container className="test-class" />
|
|
306
|
+
</TestWrapper>
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
const expectedProps = expect.objectContaining({
|
|
310
|
+
className: 'test-class'
|
|
311
|
+
});
|
|
312
|
+
expect(mockUseBaseProps).toHaveBeenCalledWith(expectedProps);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it('parses valid JSON sx prop', () => {
|
|
316
|
+
render(
|
|
317
|
+
<TestWrapper>
|
|
318
|
+
<Container sx='{"color": "primary.main", "fontWeight": "bold"}' />
|
|
319
|
+
</TestWrapper>
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
const expectedProps = expect.objectContaining({
|
|
323
|
+
sx: { color: 'primary.main', fontWeight: 'bold' }
|
|
324
|
+
});
|
|
325
|
+
expect(mockUseBaseProps).toHaveBeenCalledWith(expectedProps);
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it('handles invalid JSON sx prop gracefully', () => {
|
|
329
|
+
render(
|
|
330
|
+
<TestWrapper>
|
|
331
|
+
<Container sx='invalid-json' />
|
|
332
|
+
</TestWrapper>
|
|
333
|
+
);
|
|
334
|
+
|
|
335
|
+
const expectedProps = expect.objectContaining({
|
|
336
|
+
sx: undefined
|
|
337
|
+
});
|
|
338
|
+
expect(mockUseBaseProps).toHaveBeenCalledWith(expectedProps);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it('parses valid JSON style prop', () => {
|
|
342
|
+
render(
|
|
343
|
+
<TestWrapper>
|
|
344
|
+
<Container style='{"margin": "10px", "color": "red"}' />
|
|
345
|
+
</TestWrapper>
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
const expectedProps = expect.objectContaining({
|
|
349
|
+
style: { margin: '10px', color: 'red' }
|
|
350
|
+
});
|
|
351
|
+
expect(mockUseBaseProps).toHaveBeenCalledWith(expectedProps);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
it('handles non-string style props', () => {
|
|
355
|
+
const styleObj = { margin: '5px' };
|
|
356
|
+
render(
|
|
357
|
+
<TestWrapper>
|
|
358
|
+
<Container style={styleObj as any} />
|
|
359
|
+
</TestWrapper>
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
const expectedProps = expect.objectContaining({
|
|
363
|
+
style: styleObj
|
|
364
|
+
});
|
|
365
|
+
expect(mockUseBaseProps).toHaveBeenCalledWith(expectedProps);
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
describe('HTML Attributes', () => {
|
|
370
|
+
it('passes HTML attributes correctly', () => {
|
|
371
|
+
render(
|
|
372
|
+
<TestWrapper>
|
|
373
|
+
<Container
|
|
374
|
+
id="test-id"
|
|
375
|
+
role="button"
|
|
376
|
+
aria-label="Test Label"
|
|
377
|
+
aria-labelledby="label-id"
|
|
378
|
+
aria-describedby="desc-id"
|
|
379
|
+
data-testid="test-element"
|
|
380
|
+
/>
|
|
381
|
+
</TestWrapper>
|
|
382
|
+
);
|
|
383
|
+
|
|
384
|
+
const expectedProps = expect.objectContaining({
|
|
385
|
+
id: 'test-id',
|
|
386
|
+
role: 'button',
|
|
387
|
+
'aria-label': 'Test Label',
|
|
388
|
+
'aria-labelledby': 'label-id',
|
|
389
|
+
'aria-describedby': 'desc-id',
|
|
390
|
+
'data-testid': 'test-element'
|
|
391
|
+
});
|
|
392
|
+
expect(mockUseBaseProps).toHaveBeenCalledWith(expectedProps);
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
describe('Event Handler Conversion', () => {
|
|
397
|
+
beforeEach(() => {
|
|
398
|
+
// Mock console methods to avoid noise in test output
|
|
399
|
+
jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
afterEach(() => {
|
|
403
|
+
jest.restoreAllMocks();
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
it('converts valid function string to executable function', () => {
|
|
407
|
+
const mockFunc = jest.fn();
|
|
408
|
+
global.testHandler = mockFunc;
|
|
409
|
+
|
|
410
|
+
render(
|
|
411
|
+
<TestWrapper>
|
|
412
|
+
<Container onClick="testHandler(event)" />
|
|
413
|
+
</TestWrapper>
|
|
414
|
+
);
|
|
415
|
+
|
|
416
|
+
const call = mockUseBaseProps.mock.calls[0][0];
|
|
417
|
+
expect(typeof call.onClick).toBe('function');
|
|
418
|
+
|
|
419
|
+
// Test the converted function
|
|
420
|
+
if (call.onClick) {
|
|
421
|
+
call.onClick({ type: 'click' });
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
it('converts function declaration string', () => {
|
|
426
|
+
render(
|
|
427
|
+
<TestWrapper>
|
|
428
|
+
<Container onClick="function handleClick(event) { console.log(event); }" />
|
|
429
|
+
</TestWrapper>
|
|
430
|
+
);
|
|
431
|
+
|
|
432
|
+
const call = mockUseBaseProps.mock.calls[0][0];
|
|
433
|
+
expect(typeof call.onClick).toBe('function');
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
it('handles invalid event handler string gracefully', () => {
|
|
437
|
+
const consoleSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
438
|
+
|
|
439
|
+
render(
|
|
440
|
+
<TestWrapper>
|
|
441
|
+
<Container onClick="invalid syntax {" />
|
|
442
|
+
</TestWrapper>
|
|
443
|
+
);
|
|
444
|
+
|
|
445
|
+
const call = mockUseBaseProps.mock.calls[0][0];
|
|
446
|
+
expect(call.onClick).toBeUndefined();
|
|
447
|
+
expect(consoleSpy).toHaveBeenCalledWith(
|
|
448
|
+
expect.stringContaining('Invalid event handler string for onClick:'),
|
|
449
|
+
'invalid syntax {',
|
|
450
|
+
expect.any(Error)
|
|
451
|
+
);
|
|
452
|
+
|
|
453
|
+
consoleSpy.mockRestore();
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
it('converts all event handler types', () => {
|
|
457
|
+
render(
|
|
458
|
+
<TestWrapper>
|
|
459
|
+
<Container
|
|
460
|
+
onClick="console.log('click')"
|
|
461
|
+
onMouseEnter="console.log('enter')"
|
|
462
|
+
onMouseLeave="console.log('leave')"
|
|
463
|
+
onFocus="console.log('focus')"
|
|
464
|
+
onBlur="console.log('blur')"
|
|
465
|
+
/>
|
|
466
|
+
</TestWrapper>
|
|
467
|
+
);
|
|
468
|
+
|
|
469
|
+
const call = mockUseBaseProps.mock.calls[0][0];
|
|
470
|
+
expect(typeof call.onClick).toBe('function');
|
|
471
|
+
expect(typeof call.onMouseEnter).toBe('function');
|
|
472
|
+
expect(typeof call.onMouseLeave).toBe('function');
|
|
473
|
+
expect(typeof call.onFocus).toBe('function');
|
|
474
|
+
expect(typeof call.onBlur).toBe('function');
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
it('handles undefined event handlers', () => {
|
|
478
|
+
render(
|
|
479
|
+
<TestWrapper>
|
|
480
|
+
<Container />
|
|
481
|
+
</TestWrapper>
|
|
482
|
+
);
|
|
483
|
+
|
|
484
|
+
const call = mockUseBaseProps.mock.calls[0][0];
|
|
485
|
+
expect(call.onClick).toBeUndefined();
|
|
486
|
+
expect(call.onMouseEnter).toBeUndefined();
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
it('handles non-string event handlers', () => {
|
|
490
|
+
const clickHandler = jest.fn();
|
|
491
|
+
render(
|
|
492
|
+
<TestWrapper>
|
|
493
|
+
<Container onClick={clickHandler as any} />
|
|
494
|
+
</TestWrapper>
|
|
495
|
+
);
|
|
496
|
+
|
|
497
|
+
const call = mockUseBaseProps.mock.calls[0][0];
|
|
498
|
+
expect(call.onClick).toBe(clickHandler);
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
describe('useBaseProps Integration', () => {
|
|
503
|
+
it('applies processed props to rendered Box component', () => {
|
|
504
|
+
const mockGridProps = { span: 6, xs: 12 };
|
|
505
|
+
const mockStyleProps = {
|
|
506
|
+
className: 'processed-class',
|
|
507
|
+
sx: { color: 'blue' },
|
|
508
|
+
style: { margin: '10px' }
|
|
509
|
+
};
|
|
510
|
+
const mockHtmlProps = { id: 'processed-id' };
|
|
511
|
+
const mockRestProps = { customProp: 'value' };
|
|
512
|
+
|
|
513
|
+
mockUseBaseProps.mockReturnValue({
|
|
514
|
+
gridProps: mockGridProps,
|
|
515
|
+
styleProps: mockStyleProps,
|
|
516
|
+
htmlProps: mockHtmlProps,
|
|
517
|
+
restProps: mockRestProps
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
const { container } = render(
|
|
521
|
+
<TestWrapper>
|
|
522
|
+
<Container id="test-id" />
|
|
523
|
+
</TestWrapper>
|
|
524
|
+
);
|
|
525
|
+
|
|
526
|
+
const boxElement = container.querySelector('div');
|
|
527
|
+
expect(boxElement).toHaveAttribute('id', 'processed-id');
|
|
528
|
+
expect(boxElement).toHaveAttribute('data-grid', JSON.stringify(mockGridProps));
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
it('handles null gridProps correctly', () => {
|
|
532
|
+
mockUseBaseProps.mockReturnValue({
|
|
533
|
+
gridProps: null,
|
|
534
|
+
styleProps: { className: undefined, sx: {}, style: undefined },
|
|
535
|
+
htmlProps: {},
|
|
536
|
+
restProps: {}
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
const { container } = render(
|
|
540
|
+
<TestWrapper>
|
|
541
|
+
<Container />
|
|
542
|
+
</TestWrapper>
|
|
543
|
+
);
|
|
544
|
+
|
|
545
|
+
const boxElement = container.querySelector('div');
|
|
546
|
+
expect(boxElement).not.toHaveAttribute('data-grid');
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
describe('Data Binding', () => {
|
|
551
|
+
it('renders normally when dataSource is provided', () => {
|
|
552
|
+
render(
|
|
553
|
+
<TestWrapper>
|
|
554
|
+
<Container dataSource="test.data">
|
|
555
|
+
<span>Content</span>
|
|
556
|
+
</Container>
|
|
557
|
+
</TestWrapper>
|
|
558
|
+
);
|
|
559
|
+
|
|
560
|
+
expect(screen.getByText('Content')).toBeInTheDocument();
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
it('handles bindingOptions prop', () => {
|
|
564
|
+
render(
|
|
565
|
+
<TestWrapper>
|
|
566
|
+
<Container
|
|
567
|
+
dataSource="test.data"
|
|
568
|
+
bindingOptions={{ cache: true }}
|
|
569
|
+
>
|
|
570
|
+
<span>Content</span>
|
|
571
|
+
</Container>
|
|
572
|
+
</TestWrapper>
|
|
573
|
+
);
|
|
574
|
+
|
|
575
|
+
expect(screen.getByText('Content')).toBeInTheDocument();
|
|
576
|
+
});
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
describe('Serialization', () => {
|
|
580
|
+
describe('toJson method', () => {
|
|
581
|
+
it('serializes basic props correctly', () => {
|
|
582
|
+
const props: ContainerProps = {
|
|
583
|
+
span: '6',
|
|
584
|
+
className: 'test-class',
|
|
585
|
+
id: 'test-id',
|
|
586
|
+
children: 'Test content'
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
const result = Container.toJson(props);
|
|
590
|
+
|
|
591
|
+
expect(result).toEqual({
|
|
592
|
+
tagName: 'Container',
|
|
593
|
+
version: '1.0.0',
|
|
594
|
+
data: {
|
|
595
|
+
span: '6',
|
|
596
|
+
className: 'test-class',
|
|
597
|
+
id: 'test-id',
|
|
598
|
+
children: 'Test content'
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
it('handles all prop types in serialization', () => {
|
|
604
|
+
const props: ContainerProps = {
|
|
605
|
+
span: '12',
|
|
606
|
+
xs: '6',
|
|
607
|
+
width: 'medium',
|
|
608
|
+
padding: 'large',
|
|
609
|
+
background: '#ffffff',
|
|
610
|
+
className: 'complex-component',
|
|
611
|
+
sx: '{"color": "red"}',
|
|
612
|
+
id: 'complex-id',
|
|
613
|
+
role: 'button',
|
|
614
|
+
'aria-label': 'Complex button',
|
|
615
|
+
onClick: 'handleClick(event)',
|
|
616
|
+
dataSource: 'api.data',
|
|
617
|
+
bindingOptions: { cache: true },
|
|
618
|
+
children: 'Complex content'
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
const result = Container.toJson(props);
|
|
622
|
+
|
|
623
|
+
expect(result.data).toMatchObject({
|
|
624
|
+
span: '12',
|
|
625
|
+
xs: '6',
|
|
626
|
+
width: 'medium',
|
|
627
|
+
padding: 'large',
|
|
628
|
+
background: '#ffffff',
|
|
629
|
+
className: 'complex-component',
|
|
630
|
+
sx: '{"color": "red"}',
|
|
631
|
+
id: 'complex-id',
|
|
632
|
+
role: 'button',
|
|
633
|
+
'aria-label': 'Complex button',
|
|
634
|
+
onClick: 'handleClick(event)',
|
|
635
|
+
dataSource: 'api.data',
|
|
636
|
+
bindingOptions: { cache: true },
|
|
637
|
+
children: 'Complex content'
|
|
638
|
+
});
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
it('includes React element children in serialization', () => {
|
|
642
|
+
const props: ContainerProps = {
|
|
643
|
+
children: <div>React element</div>
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
const result = Container.toJson(props);
|
|
647
|
+
|
|
648
|
+
expect(result.data.children).toBeDefined();
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
it('handles undefined children', () => {
|
|
652
|
+
const props: ContainerProps = {};
|
|
653
|
+
|
|
654
|
+
const result = Container.toJson(props);
|
|
655
|
+
|
|
656
|
+
expect(result.data.children).toBeUndefined();
|
|
657
|
+
});
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
describe('fromJson method', () => {
|
|
661
|
+
it('creates component from JSON data', () => {
|
|
662
|
+
const jsonData = {
|
|
663
|
+
tagName: 'Container',
|
|
664
|
+
version: '1.0.0',
|
|
665
|
+
data: {
|
|
666
|
+
span: '6',
|
|
667
|
+
className: 'test-class',
|
|
668
|
+
id: 'test-id',
|
|
669
|
+
children: 'Test content'
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
const element = Container.fromJson(jsonData);
|
|
674
|
+
|
|
675
|
+
expect(React.isValidElement(element)).toBe(true);
|
|
676
|
+
expect(element.type).toBe(Container);
|
|
677
|
+
expect(element.props).toEqual(jsonData.data);
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
it('handles empty JSON data', () => {
|
|
681
|
+
const jsonData = {
|
|
682
|
+
tagName: 'Container',
|
|
683
|
+
version: '1.0.0',
|
|
684
|
+
data: {}
|
|
685
|
+
};
|
|
686
|
+
const element = Container.fromJson(jsonData);
|
|
687
|
+
|
|
688
|
+
expect(React.isValidElement(element)).toBe(true);
|
|
689
|
+
expect(element.type).toBe(Container);
|
|
690
|
+
});
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
describe('static properties', () => {
|
|
694
|
+
it('has correct static properties', () => {
|
|
695
|
+
expect(Container.tagName).toBe('Container');
|
|
696
|
+
expect(Container.version).toBe('1.0.0');
|
|
697
|
+
expect(typeof Container.fromJson).toBe('function');
|
|
698
|
+
expect(typeof Container.toJson).toBe('function');
|
|
699
|
+
});
|
|
700
|
+
});
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
describe('Edge Cases and Error Handling', () => {
|
|
704
|
+
it('handles extremely long prop values', () => {
|
|
705
|
+
const longValue = 'a'.repeat(10000);
|
|
706
|
+
|
|
707
|
+
render(
|
|
708
|
+
<TestWrapper>
|
|
709
|
+
<Container className={longValue} />
|
|
710
|
+
</TestWrapper>
|
|
711
|
+
);
|
|
712
|
+
|
|
713
|
+
const expectedProps = expect.objectContaining({
|
|
714
|
+
className: longValue
|
|
715
|
+
});
|
|
716
|
+
expect(mockUseBaseProps).toHaveBeenCalledWith(expectedProps);
|
|
717
|
+
});
|
|
718
|
+
|
|
719
|
+
it('handles special characters in props', () => {
|
|
720
|
+
render(
|
|
721
|
+
<TestWrapper>
|
|
722
|
+
<Container
|
|
723
|
+
className="class-with-special-chars-@#$%"
|
|
724
|
+
id="id-with-spaces and symbols !@#"
|
|
725
|
+
aria-label={'Label with quotes \'single\' and "double"'}
|
|
726
|
+
/>
|
|
727
|
+
</TestWrapper>
|
|
728
|
+
);
|
|
729
|
+
|
|
730
|
+
const call = mockUseBaseProps.mock.calls[0][0];
|
|
731
|
+
expect(call.className).toBe('class-with-special-chars-@#$%');
|
|
732
|
+
expect(call.id).toBe('id-with-spaces and symbols !@#');
|
|
733
|
+
expect(call['aria-label']).toBe('Label with quotes \'single\' and "double"');
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
it('handles deeply nested JSON in props', () => {
|
|
737
|
+
const complexJson = JSON.stringify({
|
|
738
|
+
nested: {
|
|
739
|
+
deep: {
|
|
740
|
+
object: {
|
|
741
|
+
array: [1, 2, { inner: 'value' }]
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
|
|
747
|
+
render(
|
|
748
|
+
<TestWrapper>
|
|
749
|
+
<Container sx={complexJson} />
|
|
750
|
+
</TestWrapper>
|
|
751
|
+
);
|
|
752
|
+
|
|
753
|
+
const call = mockUseBaseProps.mock.calls[0][0];
|
|
754
|
+
expect(call.sx).toEqual({
|
|
755
|
+
nested: {
|
|
756
|
+
deep: {
|
|
757
|
+
object: {
|
|
758
|
+
array: [1, 2, { inner: 'value' }]
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
});
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
it('handles malformed JSON gracefully', () => {
|
|
766
|
+
render(
|
|
767
|
+
<TestWrapper>
|
|
768
|
+
<Container
|
|
769
|
+
sx='{malformed: json, missing quotes}'
|
|
770
|
+
style='{"incomplete": }'
|
|
771
|
+
/>
|
|
772
|
+
</TestWrapper>
|
|
773
|
+
);
|
|
774
|
+
|
|
775
|
+
const call = mockUseBaseProps.mock.calls[0][0];
|
|
776
|
+
expect(call.sx).toBeUndefined();
|
|
777
|
+
expect(call.style).toBeUndefined();
|
|
778
|
+
});
|
|
779
|
+
|
|
780
|
+
it('handles null and undefined prop values', () => {
|
|
781
|
+
render(
|
|
782
|
+
<TestWrapper>
|
|
783
|
+
<Container
|
|
784
|
+
className={undefined}
|
|
785
|
+
id={null as any}
|
|
786
|
+
span=""
|
|
787
|
+
/>
|
|
788
|
+
</TestWrapper>
|
|
789
|
+
);
|
|
790
|
+
|
|
791
|
+
const call = mockUseBaseProps.mock.calls[0][0];
|
|
792
|
+
expect(call.className).toBeUndefined();
|
|
793
|
+
expect(call.id).toBeNull();
|
|
794
|
+
expect(call.span).toBeUndefined(); // Empty string converts to undefined
|
|
795
|
+
});
|
|
796
|
+
});
|
|
797
|
+
|
|
798
|
+
describe('Component Performance', () => {
|
|
799
|
+
it('memoizes converted props correctly', () => {
|
|
800
|
+
const { rerender } = render(
|
|
801
|
+
<TestWrapper>
|
|
802
|
+
<Container span="6" />
|
|
803
|
+
</TestWrapper>
|
|
804
|
+
);
|
|
805
|
+
|
|
806
|
+
expect(mockUseBaseProps).toHaveBeenCalledTimes(1);
|
|
807
|
+
|
|
808
|
+
// Rerender with same props
|
|
809
|
+
rerender(
|
|
810
|
+
<TestWrapper>
|
|
811
|
+
<Container span="6" />
|
|
812
|
+
</TestWrapper>
|
|
813
|
+
);
|
|
814
|
+
|
|
815
|
+
// Should be called again (React component re-render)
|
|
816
|
+
expect(mockUseBaseProps).toHaveBeenCalledTimes(2);
|
|
817
|
+
});
|
|
818
|
+
|
|
819
|
+
it('handles rapid prop changes', () => {
|
|
820
|
+
const { rerender } = render(
|
|
821
|
+
<TestWrapper>
|
|
822
|
+
<Container span="6" />
|
|
823
|
+
</TestWrapper>
|
|
824
|
+
);
|
|
825
|
+
|
|
826
|
+
for (let i = 1; i <= 10; i++) {
|
|
827
|
+
rerender(
|
|
828
|
+
<TestWrapper>
|
|
829
|
+
<Container span={i.toString()} />
|
|
830
|
+
</TestWrapper>
|
|
831
|
+
);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
expect(mockUseBaseProps).toHaveBeenCalledTimes(11); // Initial + 10 updates
|
|
835
|
+
});
|
|
836
|
+
});
|
|
837
|
+
|
|
838
|
+
describe('Text Alignment', () => {
|
|
839
|
+
it('passes textAlign prop correctly', () => {
|
|
840
|
+
render(
|
|
841
|
+
<TestWrapper>
|
|
842
|
+
<Container textAlign="center" />
|
|
843
|
+
</TestWrapper>
|
|
844
|
+
);
|
|
845
|
+
|
|
846
|
+
const expectedProps = expect.objectContaining({
|
|
847
|
+
textAlign: 'center'
|
|
848
|
+
});
|
|
849
|
+
expect(mockUseBaseProps).toHaveBeenCalledWith(expectedProps);
|
|
850
|
+
});
|
|
851
|
+
|
|
852
|
+
it('handles all textAlign values', () => {
|
|
853
|
+
const alignments = ['left', 'center', 'right', 'justify'] as const;
|
|
854
|
+
|
|
855
|
+
alignments.forEach(alignment => {
|
|
856
|
+
mockUseBaseProps.mockClear();
|
|
857
|
+
|
|
858
|
+
render(
|
|
859
|
+
<TestWrapper>
|
|
860
|
+
<Container textAlign={alignment} />
|
|
861
|
+
</TestWrapper>
|
|
862
|
+
);
|
|
863
|
+
|
|
864
|
+
const expectedProps = expect.objectContaining({
|
|
865
|
+
textAlign: alignment
|
|
866
|
+
});
|
|
867
|
+
expect(mockUseBaseProps).toHaveBeenCalledWith(expectedProps);
|
|
868
|
+
});
|
|
869
|
+
});
|
|
870
|
+
});
|
|
871
|
+
|
|
872
|
+
describe('Serialization with Event Handlers', () => {
|
|
873
|
+
it('should serialize Container with onClick handler without circular reference error', () => {
|
|
874
|
+
// Import ComponentTransformer and registry for testing
|
|
875
|
+
const { ComponentTransformer } = require('../../../schemas/transformers/ComponentTransformer');
|
|
876
|
+
// Ensure components are registered
|
|
877
|
+
require('../../../schemas/transformers/registry');
|
|
878
|
+
|
|
879
|
+
// Create a Container with onClick handler
|
|
880
|
+
const containerWithHandler = (
|
|
881
|
+
<Container
|
|
882
|
+
span={12}
|
|
883
|
+
padding="large"
|
|
884
|
+
background="linear-gradient(135deg, #667eea 0%, #764ba2 100%)"
|
|
885
|
+
onClick={(event) => { console.log("Container clicked!"); }}
|
|
886
|
+
role="button"
|
|
887
|
+
aria-label="Clickable container"
|
|
888
|
+
>
|
|
889
|
+
Test content
|
|
890
|
+
</Container>
|
|
891
|
+
);
|
|
892
|
+
|
|
893
|
+
// This should NOT throw "Converting circular structure to JSON"
|
|
894
|
+
expect(() => {
|
|
895
|
+
const serializedData = ComponentTransformer.serialize(containerWithHandler);
|
|
896
|
+
const parsedData = JSON.parse(serializedData);
|
|
897
|
+
|
|
898
|
+
// Verify the onClick handler was converted to a string
|
|
899
|
+
expect(typeof parsedData.data.onClick).toBe('string');
|
|
900
|
+
expect(parsedData.data.onClick).toContain('console.log');
|
|
901
|
+
|
|
902
|
+
// Verify other props are preserved
|
|
903
|
+
expect(parsedData.tagName).toBe('Container');
|
|
904
|
+
expect(parsedData.data.span).toBe(12);
|
|
905
|
+
expect(parsedData.data.padding).toBe('large');
|
|
906
|
+
expect(parsedData.data.background).toContain('linear-gradient');
|
|
907
|
+
|
|
908
|
+
}).not.toThrow();
|
|
909
|
+
});
|
|
910
|
+
|
|
911
|
+
it('should handle multiple event handlers in serialization', () => {
|
|
912
|
+
const { ComponentTransformer } = require('../../../schemas/transformers/ComponentTransformer');
|
|
913
|
+
// Ensure components are registered
|
|
914
|
+
require('../../../schemas/transformers/registry');
|
|
915
|
+
|
|
916
|
+
const containerWithMultipleHandlers = (
|
|
917
|
+
<Container
|
|
918
|
+
onClick={(event) => { console.log("clicked"); }}
|
|
919
|
+
onMouseEnter={(event) => { console.log("mouse enter"); }}
|
|
920
|
+
onMouseLeave={(event) => { console.log("mouse leave"); }}
|
|
921
|
+
onFocus={(event) => { console.log("focused"); }}
|
|
922
|
+
onBlur={(event) => { console.log("blurred"); }}
|
|
923
|
+
>
|
|
924
|
+
Multi-handler container
|
|
925
|
+
</Container>
|
|
926
|
+
);
|
|
927
|
+
|
|
928
|
+
expect(() => {
|
|
929
|
+
const serializedData = ComponentTransformer.serialize(containerWithMultipleHandlers);
|
|
930
|
+
const parsedData = JSON.parse(serializedData);
|
|
931
|
+
|
|
932
|
+
// All handlers should be converted to strings
|
|
933
|
+
expect(typeof parsedData.data.onClick).toBe('string');
|
|
934
|
+
expect(typeof parsedData.data.onMouseEnter).toBe('string');
|
|
935
|
+
expect(typeof parsedData.data.onMouseLeave).toBe('string');
|
|
936
|
+
expect(typeof parsedData.data.onFocus).toBe('string');
|
|
937
|
+
expect(typeof parsedData.data.onBlur).toBe('string');
|
|
938
|
+
|
|
939
|
+
}).not.toThrow();
|
|
940
|
+
});
|
|
941
|
+
|
|
942
|
+
it('should round-trip serialize and deserialize Container with event handlers', () => {
|
|
943
|
+
const { ComponentTransformer } = require('../../../schemas/transformers/ComponentTransformer');
|
|
944
|
+
// Ensure components are registered
|
|
945
|
+
require('../../../schemas/transformers/registry');
|
|
946
|
+
|
|
947
|
+
const originalContainer = (
|
|
948
|
+
<Container
|
|
949
|
+
span={6}
|
|
950
|
+
padding="medium"
|
|
951
|
+
onClick={(event) => { console.log("original handler"); }}
|
|
952
|
+
>
|
|
953
|
+
Round-trip test
|
|
954
|
+
</Container>
|
|
955
|
+
);
|
|
956
|
+
|
|
957
|
+
// Serialize and deserialize
|
|
958
|
+
const serializedData = ComponentTransformer.serialize(originalContainer);
|
|
959
|
+
const deserializedContainer = ComponentTransformer.deserialize(serializedData);
|
|
960
|
+
|
|
961
|
+
// Should not throw and should return a valid React element
|
|
962
|
+
expect(deserializedContainer).toBeDefined();
|
|
963
|
+
expect(React.isValidElement(deserializedContainer)).toBe(true);
|
|
964
|
+
});
|
|
965
|
+
});
|
|
966
|
+
});
|