@qwickapps/react-framework 1.3.3 → 1.3.5
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/README.md +227 -0
- package/dist/components/blocks/Content.d.ts.map +1 -1
- package/dist/components/blocks/ProductCard.d.ts.map +1 -1
- package/dist/components/forms/FormBlock.d.ts +1 -1
- package/dist/components/forms/FormBlock.d.ts.map +1 -1
- package/dist/components/input/SwitchInputField.d.ts +28 -0
- package/dist/components/input/SwitchInputField.d.ts.map +1 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/input/index.d.ts.map +1 -1
- package/dist/components/layout/CollapsibleLayout/CollapsibleLayout.d.ts +34 -0
- package/dist/components/layout/CollapsibleLayout/CollapsibleLayout.d.ts.map +1 -0
- package/dist/components/layout/CollapsibleLayout/index.d.ts +9 -0
- package/dist/components/layout/CollapsibleLayout/index.d.ts.map +1 -0
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/layout/index.d.ts.map +1 -1
- package/dist/contexts/ThemeContext.d.ts.map +1 -1
- package/dist/index.esm.js +963 -105
- package/dist/index.js +967 -101
- package/dist/schemas/CollapsibleLayoutSchema.d.ts +31 -0
- package/dist/schemas/CollapsibleLayoutSchema.d.ts.map +1 -0
- package/dist/schemas/SwitchInputFieldSchema.d.ts +18 -0
- package/dist/schemas/SwitchInputFieldSchema.d.ts.map +1 -0
- package/dist/types/CollapsibleLayout.d.ts +142 -0
- package/dist/types/CollapsibleLayout.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/blocks/Content.tsx +25 -77
- package/src/components/blocks/ProductCard.tsx +50 -51
- package/src/components/forms/FormBlock.tsx +2 -2
- package/src/components/input/SwitchInputField.tsx +165 -0
- package/src/components/input/index.ts +2 -0
- package/src/components/layout/CollapsibleLayout/CollapsibleLayout.tsx +554 -0
- package/src/components/layout/CollapsibleLayout/__tests__/CollapsibleLayout.test.tsx +1469 -0
- package/src/components/layout/CollapsibleLayout/index.tsx +17 -0
- package/src/components/layout/index.ts +4 -1
- package/src/components/pages/FormPage.tsx +1 -1
- package/src/contexts/ThemeContext.tsx +1 -2
- package/src/schemas/CollapsibleLayoutSchema.ts +276 -0
- package/src/schemas/SwitchInputFieldSchema.ts +99 -0
- package/src/stories/CollapsibleLayout.stories.tsx +1566 -0
- package/src/types/CollapsibleLayout.ts +231 -0
- package/src/types/index.ts +1 -0
|
@@ -0,0 +1,231 @@
|
|
|
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
|
+
|
|
10
|
+
import React, { ReactNode } from 'react';
|
|
11
|
+
import type { WithDataBinding, ModelProps } from '@qwickapps/schema';
|
|
12
|
+
import type { WithBaseProps } from '../hooks/useBaseProps';
|
|
13
|
+
import CollapsibleLayoutModel from '../schemas/CollapsibleLayoutSchema';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Core CollapsibleLayout properties extending the schema model
|
|
17
|
+
*
|
|
18
|
+
* This interface combines the schema-defined properties with React-specific types
|
|
19
|
+
* and additional component functionality not captured in the schema.
|
|
20
|
+
*/
|
|
21
|
+
export type CollapsibleLayoutViewProps = ModelProps<CollapsibleLayoutModel> &
|
|
22
|
+
WithBaseProps & {
|
|
23
|
+
// ========================================
|
|
24
|
+
// React Event Handlers
|
|
25
|
+
// ========================================
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Callback fired when the collapsed state changes
|
|
29
|
+
* @param collapsed - The new collapsed state
|
|
30
|
+
*/
|
|
31
|
+
onToggle?: (collapsed: boolean) => void;
|
|
32
|
+
|
|
33
|
+
// ========================================
|
|
34
|
+
// React Node Overrides
|
|
35
|
+
// ========================================
|
|
36
|
+
|
|
37
|
+
/** Lead icon as React node (overrides string-based leadIcon from schema) */
|
|
38
|
+
leadIcon?: ReactNode;
|
|
39
|
+
|
|
40
|
+
/** Header actions as React node (overrides string-based headerActions from schema) */
|
|
41
|
+
headerActions?: ReactNode;
|
|
42
|
+
|
|
43
|
+
/** Collapsed view content as React node (overrides string-based collapsedView from schema) */
|
|
44
|
+
collapsedView?: ReactNode;
|
|
45
|
+
|
|
46
|
+
/** Main content as React node (overrides string-based children from schema) */
|
|
47
|
+
children?: ReactNode;
|
|
48
|
+
|
|
49
|
+
/** Footer content as React node (overrides string-based footerView from schema) */
|
|
50
|
+
footerView?: ReactNode;
|
|
51
|
+
|
|
52
|
+
/** Collapsed state icon as React node (overrides string-based collapsedIcon from schema) */
|
|
53
|
+
collapsedIcon?: ReactNode;
|
|
54
|
+
|
|
55
|
+
/** Expanded state icon as React node (overrides string-based expandedIcon from schema) */
|
|
56
|
+
expandedIcon?: ReactNode;
|
|
57
|
+
|
|
58
|
+
// ========================================
|
|
59
|
+
// Additional Component Props
|
|
60
|
+
// ========================================
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Unique key for local storage persistence (when persistState is true)
|
|
64
|
+
* Defaults to component id or generates one automatically
|
|
65
|
+
*/
|
|
66
|
+
storageKey?: string;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Animation duration in milliseconds
|
|
70
|
+
* @default 300
|
|
71
|
+
*/
|
|
72
|
+
animationDuration?: number;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Disable all animations (useful for testing or accessibility)
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
78
|
+
disableAnimations?: boolean;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Custom CSS class for the container
|
|
82
|
+
*/
|
|
83
|
+
containerClassName?: string;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Custom CSS class for the header
|
|
87
|
+
*/
|
|
88
|
+
headerClassName?: string;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Custom CSS class for the content area
|
|
92
|
+
*/
|
|
93
|
+
contentClassName?: string;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Custom CSS class for the footer
|
|
97
|
+
*/
|
|
98
|
+
footerClassName?: string;
|
|
99
|
+
|
|
100
|
+
// ========================================
|
|
101
|
+
// Accessibility Props
|
|
102
|
+
// ========================================
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* ARIA label for the toggle button
|
|
106
|
+
* @default "Toggle content visibility"
|
|
107
|
+
*/
|
|
108
|
+
toggleAriaLabel?: string;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* ID of element that describes the collapsible content
|
|
112
|
+
*/
|
|
113
|
+
'aria-describedby'?: string;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Additional ARIA attributes for the content region
|
|
117
|
+
*/
|
|
118
|
+
contentAriaProps?: {
|
|
119
|
+
'aria-label'?: string;
|
|
120
|
+
'aria-labelledby'?: string;
|
|
121
|
+
role?: string;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Complete CollapsibleLayout component props interface
|
|
127
|
+
*
|
|
128
|
+
* This is the interface that should be used by the CollapsibleLayout component.
|
|
129
|
+
* It combines the view props with data binding capabilities.
|
|
130
|
+
*/
|
|
131
|
+
export interface CollapsibleLayoutProps extends CollapsibleLayoutViewProps, WithDataBinding {}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Type guard to check if a component has CollapsibleLayout props
|
|
135
|
+
*/
|
|
136
|
+
export function isCollapsibleLayoutProps(props: any): props is CollapsibleLayoutProps {
|
|
137
|
+
return props && typeof props === 'object' && ('collapsed' in props || 'defaultCollapsed' in props);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Default props for CollapsibleLayout component
|
|
142
|
+
*/
|
|
143
|
+
export const defaultCollapsibleLayoutProps: Partial<CollapsibleLayoutProps> = {
|
|
144
|
+
// Note: collapsed is intentionally omitted so components can be uncontrolled
|
|
145
|
+
defaultCollapsed: false,
|
|
146
|
+
triggerArea: 'both',
|
|
147
|
+
animationStyle: 'slide',
|
|
148
|
+
persistState: false,
|
|
149
|
+
showDivider: true,
|
|
150
|
+
variant: 'default',
|
|
151
|
+
headerSpacing: 'comfortable',
|
|
152
|
+
contentSpacing: 'comfortable',
|
|
153
|
+
animationDuration: 300,
|
|
154
|
+
disableAnimations: false,
|
|
155
|
+
toggleAriaLabel: 'Toggle content visibility',
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Animation style configurations
|
|
160
|
+
*/
|
|
161
|
+
export interface AnimationConfig {
|
|
162
|
+
duration: number;
|
|
163
|
+
easing: string;
|
|
164
|
+
transform?: string;
|
|
165
|
+
opacity?: [number, number];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export const animationConfigs: Record<NonNullable<CollapsibleLayoutProps['animationStyle']>, AnimationConfig> = {
|
|
169
|
+
fade: {
|
|
170
|
+
duration: 300,
|
|
171
|
+
easing: 'cubic-bezier(0.4, 0, 0.2, 1)',
|
|
172
|
+
opacity: [0, 1],
|
|
173
|
+
},
|
|
174
|
+
slide: {
|
|
175
|
+
duration: 300,
|
|
176
|
+
easing: 'cubic-bezier(0.4, 0, 0.2, 1)',
|
|
177
|
+
transform: 'translateY(-10px)',
|
|
178
|
+
},
|
|
179
|
+
scale: {
|
|
180
|
+
duration: 200,
|
|
181
|
+
easing: 'cubic-bezier(0.34, 1.56, 0.64, 1)',
|
|
182
|
+
transform: 'scale(0.95)',
|
|
183
|
+
opacity: [0, 1],
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Spacing configurations
|
|
189
|
+
*/
|
|
190
|
+
export interface SpacingConfig {
|
|
191
|
+
padding: string;
|
|
192
|
+
gap?: string;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export const spacingConfigs: Record<NonNullable<CollapsibleLayoutProps['headerSpacing'] | CollapsibleLayoutProps['contentSpacing']>, SpacingConfig> = {
|
|
196
|
+
compact: {
|
|
197
|
+
padding: '8px 12px',
|
|
198
|
+
gap: '4px',
|
|
199
|
+
},
|
|
200
|
+
comfortable: {
|
|
201
|
+
padding: '16px 20px',
|
|
202
|
+
gap: '8px',
|
|
203
|
+
},
|
|
204
|
+
spacious: {
|
|
205
|
+
padding: '24px 32px',
|
|
206
|
+
gap: '16px',
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Utility type for extracting controlled vs uncontrolled props
|
|
212
|
+
*/
|
|
213
|
+
export type ControlledCollapsibleLayoutProps = CollapsibleLayoutProps & {
|
|
214
|
+
collapsed: boolean;
|
|
215
|
+
onToggle: (collapsed: boolean) => void;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export type UncontrolledCollapsibleLayoutProps = CollapsibleLayoutProps & {
|
|
219
|
+
defaultCollapsed?: boolean;
|
|
220
|
+
onToggle?: (collapsed: boolean) => void;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Hook return type for managing collapsed state
|
|
225
|
+
*/
|
|
226
|
+
export interface UseCollapsibleLayoutState {
|
|
227
|
+
collapsed: boolean;
|
|
228
|
+
toggle: () => void;
|
|
229
|
+
setCollapsed: (collapsed: boolean) => void;
|
|
230
|
+
isControlled: boolean;
|
|
231
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -93,6 +93,7 @@ export type LoadingState = 'idle' | 'loading' | 'success' | 'error';
|
|
|
93
93
|
|
|
94
94
|
// Export all content-related types
|
|
95
95
|
export * from './CacheProvider';
|
|
96
|
+
export * from './CollapsibleLayout';
|
|
96
97
|
export * from './ContentProxy';
|
|
97
98
|
export * from './DataTypes';
|
|
98
99
|
export * from './TemplateProvider';
|