@qwickapps/react-framework 1.3.3 → 1.3.4

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.
Files changed (37) hide show
  1. package/README.md +220 -0
  2. package/dist/components/forms/FormBlock.d.ts +1 -1
  3. package/dist/components/forms/FormBlock.d.ts.map +1 -1
  4. package/dist/components/input/SwitchInputField.d.ts +28 -0
  5. package/dist/components/input/SwitchInputField.d.ts.map +1 -0
  6. package/dist/components/input/index.d.ts +2 -0
  7. package/dist/components/input/index.d.ts.map +1 -1
  8. package/dist/components/layout/CollapsibleLayout/CollapsibleLayout.d.ts +34 -0
  9. package/dist/components/layout/CollapsibleLayout/CollapsibleLayout.d.ts.map +1 -0
  10. package/dist/components/layout/CollapsibleLayout/index.d.ts +9 -0
  11. package/dist/components/layout/CollapsibleLayout/index.d.ts.map +1 -0
  12. package/dist/components/layout/index.d.ts +2 -0
  13. package/dist/components/layout/index.d.ts.map +1 -1
  14. package/dist/index.esm.js +876 -6
  15. package/dist/index.js +880 -2
  16. package/dist/schemas/CollapsibleLayoutSchema.d.ts +31 -0
  17. package/dist/schemas/CollapsibleLayoutSchema.d.ts.map +1 -0
  18. package/dist/schemas/SwitchInputFieldSchema.d.ts +18 -0
  19. package/dist/schemas/SwitchInputFieldSchema.d.ts.map +1 -0
  20. package/dist/types/CollapsibleLayout.d.ts +142 -0
  21. package/dist/types/CollapsibleLayout.d.ts.map +1 -0
  22. package/dist/types/index.d.ts +1 -0
  23. package/dist/types/index.d.ts.map +1 -1
  24. package/package.json +1 -1
  25. package/src/components/forms/FormBlock.tsx +2 -2
  26. package/src/components/input/SwitchInputField.tsx +165 -0
  27. package/src/components/input/index.ts +2 -0
  28. package/src/components/layout/CollapsibleLayout/CollapsibleLayout.tsx +554 -0
  29. package/src/components/layout/CollapsibleLayout/__tests__/CollapsibleLayout.test.tsx +1469 -0
  30. package/src/components/layout/CollapsibleLayout/index.tsx +17 -0
  31. package/src/components/layout/index.ts +4 -1
  32. package/src/components/pages/FormPage.tsx +1 -1
  33. package/src/schemas/CollapsibleLayoutSchema.ts +276 -0
  34. package/src/schemas/SwitchInputFieldSchema.ts +99 -0
  35. package/src/stories/CollapsibleLayout.stories.tsx +1566 -0
  36. package/src/types/CollapsibleLayout.ts +231 -0
  37. package/src/types/index.ts +1 -0
@@ -0,0 +1,31 @@
1
+ /**
2
+ * CollapsibleLayout Schema - Data model for collapsible layout component
3
+ *
4
+ * Advanced expandable/collapsible container with header controls, animations,
5
+ * content management, and state persistence capabilities.
6
+ *
7
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
8
+ */
9
+ import { Model } from '@qwickapps/schema';
10
+ export declare class CollapsibleLayoutModel extends Model {
11
+ collapsed?: boolean;
12
+ defaultCollapsed?: boolean;
13
+ title?: string;
14
+ subtitle?: string;
15
+ leadIcon?: string;
16
+ headerActions?: string;
17
+ collapsedView?: string;
18
+ children?: string;
19
+ footerView?: string;
20
+ triggerArea?: 'button' | 'header' | 'both';
21
+ animationStyle?: 'fade' | 'slide' | 'scale';
22
+ persistState?: boolean;
23
+ collapsedIcon?: string;
24
+ expandedIcon?: string;
25
+ showDivider?: boolean;
26
+ variant?: 'default' | 'outlined' | 'elevated' | 'filled';
27
+ headerSpacing?: 'compact' | 'comfortable' | 'spacious';
28
+ contentSpacing?: 'compact' | 'comfortable' | 'spacious';
29
+ }
30
+ export default CollapsibleLayoutModel;
31
+ //# sourceMappingURL=CollapsibleLayoutSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CollapsibleLayoutSchema.d.ts","sourceRoot":"","sources":["../../src/schemas/CollapsibleLayoutSchema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAIL,KAAK,EAEN,MAAM,mBAAmB,CAAC;AAG3B,qBACa,sBAAuB,SAAQ,KAAK;IAc/C,SAAS,CAAC,EAAE,OAAO,CAAC;IAUpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAe3B,KAAK,CAAC,EAAE,MAAM,CAAC;IAWf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAWlB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAWlB,aAAa,CAAC,EAAE,MAAM,CAAC;IAevB,aAAa,CAAC,EAAE,MAAM,CAAC;IAWvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAWlB,UAAU,CAAC,EAAE,MAAM,CAAC;IAqBpB,WAAW,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;IAiB3C,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;IAU5C,YAAY,CAAC,EAAE,OAAO,CAAC;IAevB,aAAa,CAAC,EAAE,MAAM,CAAC;IAWvB,YAAY,CAAC,EAAE,MAAM,CAAC;IActB,WAAW,CAAC,EAAE,OAAO,CAAC;IAsBtB,OAAO,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAC;IAiBzD,aAAa,CAAC,EAAE,SAAS,GAAG,aAAa,GAAG,UAAU,CAAC;IAiBvD,cAAc,CAAC,EAAE,SAAS,GAAG,aAAa,GAAG,UAAU,CAAC;CACzD;AAED,eAAe,sBAAsB,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * SwitchInputField Schema - Data model for switch input field component
3
+ *
4
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
5
+ */
6
+ import { Model } from '@qwickapps/schema';
7
+ export declare class SwitchInputFieldModel extends Model {
8
+ label?: string;
9
+ checked?: boolean;
10
+ required?: boolean;
11
+ disabled?: boolean;
12
+ error?: string;
13
+ helperText?: string;
14
+ size?: 'small' | 'medium';
15
+ color?: 'default' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning';
16
+ }
17
+ export default SwitchInputFieldModel;
18
+ //# sourceMappingURL=SwitchInputFieldSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SwitchInputFieldSchema.d.ts","sourceRoot":"","sources":["../../src/schemas/SwitchInputFieldSchema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,KAAK,EAEN,MAAM,mBAAmB,CAAC;AAG3B,qBACa,qBAAsB,SAAQ,KAAK;IAS9C,KAAK,CAAC,EAAE,MAAM,CAAC;IAUf,OAAO,CAAC,EAAE,OAAO,CAAC;IAUlB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAUnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAUnB,KAAK,CAAC,EAAE,MAAM,CAAC;IAUf,UAAU,CAAC,EAAE,MAAM,CAAC;IAUpB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAU1B,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;CACxF;AAED,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,142 @@
1
+ /**
2
+ * TypeScript type definitions for CollapsibleLayout component
3
+ *
4
+ * Provides TypeScript interfaces that extend the schema model with React-specific types
5
+ * and component-level functionality for the CollapsibleLayout component.
6
+ *
7
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
8
+ */
9
+ import { ReactNode } from 'react';
10
+ import type { WithDataBinding, ModelProps } from '@qwickapps/schema';
11
+ import type { WithBaseProps } from '../hooks/useBaseProps';
12
+ import CollapsibleLayoutModel from '../schemas/CollapsibleLayoutSchema';
13
+ /**
14
+ * Core CollapsibleLayout properties extending the schema model
15
+ *
16
+ * This interface combines the schema-defined properties with React-specific types
17
+ * and additional component functionality not captured in the schema.
18
+ */
19
+ export type CollapsibleLayoutViewProps = ModelProps<CollapsibleLayoutModel> & WithBaseProps & {
20
+ /**
21
+ * Callback fired when the collapsed state changes
22
+ * @param collapsed - The new collapsed state
23
+ */
24
+ onToggle?: (collapsed: boolean) => void;
25
+ /** Lead icon as React node (overrides string-based leadIcon from schema) */
26
+ leadIcon?: ReactNode;
27
+ /** Header actions as React node (overrides string-based headerActions from schema) */
28
+ headerActions?: ReactNode;
29
+ /** Collapsed view content as React node (overrides string-based collapsedView from schema) */
30
+ collapsedView?: ReactNode;
31
+ /** Main content as React node (overrides string-based children from schema) */
32
+ children?: ReactNode;
33
+ /** Footer content as React node (overrides string-based footerView from schema) */
34
+ footerView?: ReactNode;
35
+ /** Collapsed state icon as React node (overrides string-based collapsedIcon from schema) */
36
+ collapsedIcon?: ReactNode;
37
+ /** Expanded state icon as React node (overrides string-based expandedIcon from schema) */
38
+ expandedIcon?: ReactNode;
39
+ /**
40
+ * Unique key for local storage persistence (when persistState is true)
41
+ * Defaults to component id or generates one automatically
42
+ */
43
+ storageKey?: string;
44
+ /**
45
+ * Animation duration in milliseconds
46
+ * @default 300
47
+ */
48
+ animationDuration?: number;
49
+ /**
50
+ * Disable all animations (useful for testing or accessibility)
51
+ * @default false
52
+ */
53
+ disableAnimations?: boolean;
54
+ /**
55
+ * Custom CSS class for the container
56
+ */
57
+ containerClassName?: string;
58
+ /**
59
+ * Custom CSS class for the header
60
+ */
61
+ headerClassName?: string;
62
+ /**
63
+ * Custom CSS class for the content area
64
+ */
65
+ contentClassName?: string;
66
+ /**
67
+ * Custom CSS class for the footer
68
+ */
69
+ footerClassName?: string;
70
+ /**
71
+ * ARIA label for the toggle button
72
+ * @default "Toggle content visibility"
73
+ */
74
+ toggleAriaLabel?: string;
75
+ /**
76
+ * ID of element that describes the collapsible content
77
+ */
78
+ 'aria-describedby'?: string;
79
+ /**
80
+ * Additional ARIA attributes for the content region
81
+ */
82
+ contentAriaProps?: {
83
+ 'aria-label'?: string;
84
+ 'aria-labelledby'?: string;
85
+ role?: string;
86
+ };
87
+ };
88
+ /**
89
+ * Complete CollapsibleLayout component props interface
90
+ *
91
+ * This is the interface that should be used by the CollapsibleLayout component.
92
+ * It combines the view props with data binding capabilities.
93
+ */
94
+ export interface CollapsibleLayoutProps extends CollapsibleLayoutViewProps, WithDataBinding {
95
+ }
96
+ /**
97
+ * Type guard to check if a component has CollapsibleLayout props
98
+ */
99
+ export declare function isCollapsibleLayoutProps(props: any): props is CollapsibleLayoutProps;
100
+ /**
101
+ * Default props for CollapsibleLayout component
102
+ */
103
+ export declare const defaultCollapsibleLayoutProps: Partial<CollapsibleLayoutProps>;
104
+ /**
105
+ * Animation style configurations
106
+ */
107
+ export interface AnimationConfig {
108
+ duration: number;
109
+ easing: string;
110
+ transform?: string;
111
+ opacity?: [number, number];
112
+ }
113
+ export declare const animationConfigs: Record<NonNullable<CollapsibleLayoutProps['animationStyle']>, AnimationConfig>;
114
+ /**
115
+ * Spacing configurations
116
+ */
117
+ export interface SpacingConfig {
118
+ padding: string;
119
+ gap?: string;
120
+ }
121
+ export declare const spacingConfigs: Record<NonNullable<CollapsibleLayoutProps['headerSpacing'] | CollapsibleLayoutProps['contentSpacing']>, SpacingConfig>;
122
+ /**
123
+ * Utility type for extracting controlled vs uncontrolled props
124
+ */
125
+ export type ControlledCollapsibleLayoutProps = CollapsibleLayoutProps & {
126
+ collapsed: boolean;
127
+ onToggle: (collapsed: boolean) => void;
128
+ };
129
+ export type UncontrolledCollapsibleLayoutProps = CollapsibleLayoutProps & {
130
+ defaultCollapsed?: boolean;
131
+ onToggle?: (collapsed: boolean) => void;
132
+ };
133
+ /**
134
+ * Hook return type for managing collapsed state
135
+ */
136
+ export interface UseCollapsibleLayoutState {
137
+ collapsed: boolean;
138
+ toggle: () => void;
139
+ setCollapsed: (collapsed: boolean) => void;
140
+ isControlled: boolean;
141
+ }
142
+ //# sourceMappingURL=CollapsibleLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CollapsibleLayout.d.ts","sourceRoot":"","sources":["../../src/types/CollapsibleLayout.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EA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AAC;IACnB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,YAAY,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,YAAY,EAAE,OAAO,CAAC;CACvB"}
@@ -74,6 +74,7 @@ export type ColorIntensity = 'light' | 'main' | 'dark';
74
74
  */
75
75
  export type LoadingState = 'idle' | 'loading' | 'success' | 'error';
76
76
  export * from './CacheProvider';
77
+ export * from './CollapsibleLayout';
77
78
  export * from './ContentProxy';
78
79
  export * from './DataTypes';
79
80
  export * from './TemplateProvider';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEpF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,aAAa,CAAC;AAE9F;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,kBAAkB,GAAG,KAAK,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;AAE5D;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAExG;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;AAE1F;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GA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M,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAGpE,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qwickapps/react-framework",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "type": "module",
5
5
  "description": "Complete React framework with responsive navigation, flexible layouts, theming system, and reusable components for building modern applications.",
6
6
  "main": "dist/index.js",
@@ -46,7 +46,7 @@ type FormBlockViewProps = ModelProps<FormBlockModel> & {
46
46
  /**
47
47
  * Form content
48
48
  */
49
- form?: React.ReactNode;
49
+ children?: React.ReactNode;
50
50
 
51
51
  /**
52
52
  * Footer content (links, additional text, etc.)
@@ -99,7 +99,7 @@ function FormBlockView({
99
99
  title,
100
100
  description,
101
101
  coverImage,
102
- form,
102
+ children: form,
103
103
  footer,
104
104
  status,
105
105
  message,
@@ -0,0 +1,165 @@
1
+ /**
2
+ * SwitchInputField - Switch toggle component with data binding support
3
+ *
4
+ * Provides a standardized switch field with:
5
+ * - Consistent Material-UI styling
6
+ * - Data binding capabilities
7
+ * - Label and helper text support
8
+ * - Focus and error handling
9
+ *
10
+ * Copyright (c) 2025 QwickApps.com. All rights reserved.
11
+ */
12
+
13
+ import React from 'react';
14
+ import {
15
+ FormControl,
16
+ FormControlLabel,
17
+ FormHelperText,
18
+ Paper,
19
+ Switch,
20
+ Typography
21
+ } from '@mui/material';
22
+ import type { WithDataBinding, ModelProps } from '@qwickapps/schema';
23
+ import { QWICKAPP_COMPONENT, useBaseProps } from '../../hooks';
24
+ import { useDataBinding } from '../../hooks';
25
+ import SwitchInputFieldModel from '../../schemas/SwitchInputFieldSchema';
26
+
27
+ type SwitchInputFieldViewProps = ModelProps<SwitchInputFieldModel> & {
28
+ /** Change handler */
29
+ onChange?: (checked: boolean) => void;
30
+ /** Focus handler */
31
+ onFocus?: () => void;
32
+ };
33
+
34
+ export interface SwitchInputFieldProps extends SwitchInputFieldViewProps, WithDataBinding {}
35
+
36
+ // View component - handles the actual rendering
37
+ function SwitchInputFieldView({
38
+ label,
39
+ checked = false,
40
+ onChange,
41
+ onFocus,
42
+ required = false,
43
+ disabled = false,
44
+ error,
45
+ helperText,
46
+ size = 'medium',
47
+ color = 'primary',
48
+ ...restProps
49
+ }: SwitchInputFieldViewProps) {
50
+ const { styleProps, htmlProps } = useBaseProps(restProps);
51
+
52
+ const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
53
+ if (onChange) {
54
+ onChange(event.target.checked);
55
+ }
56
+ };
57
+
58
+ return (
59
+ <FormControl
60
+ {...htmlProps}
61
+ {...styleProps}
62
+ error={!!error}
63
+ required={required}
64
+ disabled={disabled}
65
+ sx={{
66
+ display: 'block',
67
+ ...styleProps.sx
68
+ }}
69
+ >
70
+ <FormControlLabel
71
+ control={
72
+ <Switch
73
+ checked={checked}
74
+ onChange={handleChange}
75
+ onFocus={onFocus}
76
+ size={size}
77
+ color={color}
78
+ disabled={disabled}
79
+ />
80
+ }
81
+ label={label}
82
+ disabled={disabled}
83
+ />
84
+ {(error || helperText) && (
85
+ <FormHelperText>
86
+ {error || helperText}
87
+ </FormHelperText>
88
+ )}
89
+ </FormControl>
90
+ );
91
+ }
92
+
93
+ /**
94
+ * SwitchInputField component with data binding support
95
+ * Supports both traditional props and dataSource-driven rendering
96
+ */
97
+ function SwitchInputField(props: SwitchInputFieldProps) {
98
+ const { dataSource, bindingOptions, ...restProps } = props;
99
+
100
+ // If no dataSource, use traditional props
101
+ if (!dataSource) {
102
+ return <SwitchInputFieldView {...restProps} />;
103
+ }
104
+
105
+ // Use data binding
106
+ const bindingResult = useDataBinding<SwitchInputFieldModel>(
107
+ dataSource,
108
+ restProps as Partial<SwitchInputFieldModel>,
109
+ SwitchInputFieldModel.getSchema(),
110
+ { cache: true, cacheTTL: 300000, strict: false, ...bindingOptions }
111
+ );
112
+
113
+ // Check if we're still loading data using the metadata properties
114
+ const bindingLoading = bindingResult.$loading;
115
+
116
+ // Extract all the actual switch properties (excluding metadata)
117
+ const { dataSource: _source, $loading, $error, $dataSource, $cached, cached, ...switchInputFieldProps } = bindingResult;
118
+ const error = bindingResult.$error;
119
+
120
+ // Show loading state while fetching data
121
+ if (bindingLoading) {
122
+ return (
123
+ <Paper
124
+ variant="outlined"
125
+ sx={{
126
+ p: 2,
127
+ textAlign: 'center'
128
+ }}
129
+ >
130
+ <Typography variant="body2">Loading SwitchInputField...</Typography>
131
+ <Typography variant="caption" color="text.secondary">
132
+ Loading switch field configuration from data source...
133
+ </Typography>
134
+ </Paper>
135
+ );
136
+ }
137
+
138
+ if (error) {
139
+ console.error('Error loading switch input field:', error);
140
+ if (process.env.NODE_ENV !== 'production') {
141
+ return (
142
+ <Paper
143
+ variant="outlined"
144
+ sx={{
145
+ p: 2,
146
+ textAlign: 'center',
147
+ borderColor: 'error.main'
148
+ }}
149
+ >
150
+ <Typography variant="body2" color="error">
151
+ Error loading switch field: {error.message}
152
+ </Typography>
153
+ </Paper>
154
+ );
155
+ }
156
+ return null;
157
+ }
158
+
159
+ return <SwitchInputFieldView {...switchInputFieldProps} />;
160
+ }
161
+
162
+ // Mark as QwickApp component
163
+ (SwitchInputField as any)[QWICKAPP_COMPONENT] = true;
164
+
165
+ export default SwitchInputField;
@@ -7,11 +7,13 @@
7
7
  export { default as ChoiceInputField } from './ChoiceInputField';
8
8
  export { default as HtmlInputField } from './HtmlInputField';
9
9
  export { default as SelectInputField } from './SelectInputField';
10
+ export { default as SwitchInputField } from './SwitchInputField';
10
11
  export { default as TextField } from './TextField';
11
12
  export { default as TextInputField } from './TextInputField';
12
13
 
13
14
  export type { ChoiceInputFieldProps } from './ChoiceInputField';
14
15
  export type { HtmlInputFieldProps } from './HtmlInputField';
15
16
  export type { SelectInputFieldProps, SelectOption } from './SelectInputField';
17
+ export type { SwitchInputFieldProps } from './SwitchInputField';
16
18
  export type { TextFieldProps } from './TextField';
17
19
  export type { TextInputFieldProps } from './TextInputField';