@evoke-platform/ui-components 1.6.0-dev.1 → 1.6.0-dev.11

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 (41) hide show
  1. package/dist/published/components/core/SwipeableDrawer/SwipeableDrawer.d.ts +4 -0
  2. package/dist/published/components/core/SwipeableDrawer/SwipeableDrawer.js +8 -0
  3. package/dist/published/components/core/SwipeableDrawer/index.d.ts +3 -0
  4. package/dist/published/components/core/SwipeableDrawer/index.js +3 -0
  5. package/dist/published/components/core/index.d.ts +2 -1
  6. package/dist/published/components/core/index.js +2 -1
  7. package/dist/published/components/custom/BuilderGrid/BuilderGrid.js +27 -27
  8. package/dist/published/components/custom/Form/FormComponents/RepeatableFieldComponent/RepeatableField.js +87 -57
  9. package/dist/published/components/custom/Form/tests/Form.test.js +1 -1
  10. package/dist/published/components/custom/FormField/AddressFieldComponent/addressFieldComponent.js +1 -1
  11. package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.js +3 -3
  12. package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.js +7 -1
  13. package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.js +7 -1
  14. package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js +6 -3
  15. package/dist/published/components/custom/FormField/Select/Select.js +17 -5
  16. package/dist/published/components/custom/FormField/TimePickerSelect/TimePickerSelect.js +13 -3
  17. package/dist/published/components/custom/HistoryLog/HistoryData.d.ts +1 -0
  18. package/dist/published/components/custom/HistoryLog/HistoryData.js +14 -6
  19. package/dist/published/components/custom/HistoryLog/HistoryLoading.d.ts +4 -1
  20. package/dist/published/components/custom/HistoryLog/HistoryLoading.js +14 -8
  21. package/dist/published/components/custom/HistoryLog/index.d.ts +2 -0
  22. package/dist/published/components/custom/HistoryLog/index.js +4 -4
  23. package/dist/published/components/custom/ResponsiveOverflow/ResponsiveOverflow.d.ts +33 -0
  24. package/dist/published/components/custom/ResponsiveOverflow/ResponsiveOverflow.js +143 -0
  25. package/dist/published/components/custom/ResponsiveOverflow/ResponsiveOverflow.test.d.ts +1 -0
  26. package/dist/published/components/custom/ResponsiveOverflow/ResponsiveOverflow.test.js +100 -0
  27. package/dist/published/components/custom/ResponsiveOverflow/index.d.ts +4 -0
  28. package/dist/published/components/custom/ResponsiveOverflow/index.js +3 -0
  29. package/dist/published/components/custom/index.d.ts +1 -0
  30. package/dist/published/components/custom/index.js +1 -0
  31. package/dist/published/index.d.ts +1 -1
  32. package/dist/published/index.js +1 -1
  33. package/dist/published/stories/ResponsiveOverflow.stories.d.ts +8 -0
  34. package/dist/published/stories/ResponsiveOverflow.stories.js +91 -0
  35. package/dist/published/theme/hooks.d.ts +78 -0
  36. package/dist/published/theme/hooks.js +65 -0
  37. package/dist/published/theme/hooks.test.d.ts +1 -0
  38. package/dist/published/theme/hooks.test.js +187 -0
  39. package/dist/published/theme/index.d.ts +2 -2
  40. package/dist/published/theme/index.js +2 -2
  41. package/package.json +2 -1
@@ -0,0 +1,187 @@
1
+ import { renderHook } from '@testing-library/react';
2
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
3
+ import { useWidgetSize } from '.';
4
+ // Shared mock bounds for useMeasure
5
+ let mockBounds = {
6
+ left: 0,
7
+ top: 0,
8
+ width: 0,
9
+ height: 0,
10
+ bottom: 0,
11
+ right: 0,
12
+ x: 0,
13
+ y: 0,
14
+ };
15
+ function setMockBounds(newBounds) {
16
+ mockBounds = { ...mockBounds, ...newBounds };
17
+ }
18
+ // Mock useMeasure from react-use-measure
19
+ vi.mock('react-use-measure', () => {
20
+ const useMeasure = () => [
21
+ vi.fn(),
22
+ mockBounds,
23
+ ];
24
+ return { __esModule: true, default: useMeasure, useMeasure };
25
+ });
26
+ describe('useWidgetSize', () => {
27
+ beforeEach(() => {
28
+ // Reset bounds before each test
29
+ setMockBounds({
30
+ left: 0,
31
+ top: 0,
32
+ width: 0,
33
+ height: 0,
34
+ bottom: 0,
35
+ right: 0,
36
+ x: 0,
37
+ y: 0,
38
+ });
39
+ });
40
+ it('should provide ref and basic structure', () => {
41
+ setMockBounds({ width: 123, height: 456 });
42
+ const { result } = renderHook(() => useWidgetSize());
43
+ expect(result.current.ref).toBeDefined();
44
+ expect(typeof result.current.ref).toBe('function');
45
+ expect(result.current.width).toBe(123);
46
+ expect(result.current.height).toBe(456);
47
+ });
48
+ describe('breakpoints', () => {
49
+ it('should set isXs for width < 800', () => {
50
+ setMockBounds({ width: 799, height: 100 });
51
+ const { result } = renderHook(() => useWidgetSize());
52
+ expect(result.current.breakpoints.isXs).toBe(true);
53
+ expect(result.current.breakpoints.isSm).toBe(false);
54
+ expect(result.current.breakpoints.isMd).toBe(false);
55
+ expect(result.current.breakpoints.isLg).toBe(false);
56
+ expect(result.current.breakpoints.isXl).toBe(false);
57
+ });
58
+ it('should set isSm for 800 <= width < 1000', () => {
59
+ setMockBounds({ width: 800, height: 100 });
60
+ let { result } = renderHook(() => useWidgetSize());
61
+ expect(result.current.breakpoints.isXs).toBe(false);
62
+ expect(result.current.breakpoints.isSm).toBe(true);
63
+ expect(result.current.breakpoints.isMd).toBe(false);
64
+ expect(result.current.breakpoints.isLg).toBe(false);
65
+ expect(result.current.breakpoints.isXl).toBe(false);
66
+ setMockBounds({ width: 999, height: 100 });
67
+ result = renderHook(() => useWidgetSize()).result;
68
+ expect(result.current.breakpoints.isXs).toBe(false);
69
+ expect(result.current.breakpoints.isSm).toBe(true);
70
+ expect(result.current.breakpoints.isMd).toBe(false);
71
+ expect(result.current.breakpoints.isLg).toBe(false);
72
+ expect(result.current.breakpoints.isXl).toBe(false);
73
+ });
74
+ it('should set isMd for 1000 <= width < 1200', () => {
75
+ setMockBounds({ width: 1000, height: 100 });
76
+ let { result } = renderHook(() => useWidgetSize());
77
+ expect(result.current.breakpoints.isXs).toBe(false);
78
+ expect(result.current.breakpoints.isSm).toBe(false);
79
+ expect(result.current.breakpoints.isMd).toBe(true);
80
+ expect(result.current.breakpoints.isLg).toBe(false);
81
+ expect(result.current.breakpoints.isXl).toBe(false);
82
+ setMockBounds({ width: 1199, height: 100 });
83
+ result = renderHook(() => useWidgetSize()).result;
84
+ expect(result.current.breakpoints.isXs).toBe(false);
85
+ expect(result.current.breakpoints.isSm).toBe(false);
86
+ expect(result.current.breakpoints.isMd).toBe(true);
87
+ expect(result.current.breakpoints.isLg).toBe(false);
88
+ expect(result.current.breakpoints.isXl).toBe(false);
89
+ });
90
+ it('should set isLg for 1200 <= width < 1400', () => {
91
+ setMockBounds({ width: 1200, height: 100 });
92
+ let { result } = renderHook(() => useWidgetSize());
93
+ expect(result.current.breakpoints.isXs).toBe(false);
94
+ expect(result.current.breakpoints.isSm).toBe(false);
95
+ expect(result.current.breakpoints.isMd).toBe(false);
96
+ expect(result.current.breakpoints.isLg).toBe(true);
97
+ expect(result.current.breakpoints.isXl).toBe(false);
98
+ setMockBounds({ width: 1399, height: 100 });
99
+ result = renderHook(() => useWidgetSize()).result;
100
+ expect(result.current.breakpoints.isXs).toBe(false);
101
+ expect(result.current.breakpoints.isSm).toBe(false);
102
+ expect(result.current.breakpoints.isMd).toBe(false);
103
+ expect(result.current.breakpoints.isLg).toBe(true);
104
+ expect(result.current.breakpoints.isXl).toBe(false);
105
+ });
106
+ it('should set isXl for width >= 1400', () => {
107
+ setMockBounds({ width: 1400, height: 100 });
108
+ let { result } = renderHook(() => useWidgetSize());
109
+ expect(result.current.breakpoints.isXs).toBe(false);
110
+ expect(result.current.breakpoints.isSm).toBe(false);
111
+ expect(result.current.breakpoints.isMd).toBe(false);
112
+ expect(result.current.breakpoints.isLg).toBe(false);
113
+ expect(result.current.breakpoints.isXl).toBe(true);
114
+ setMockBounds({ width: 2000, height: 100 });
115
+ result = renderHook(() => useWidgetSize()).result;
116
+ expect(result.current.breakpoints.isXs).toBe(false);
117
+ expect(result.current.breakpoints.isSm).toBe(false);
118
+ expect(result.current.breakpoints.isMd).toBe(false);
119
+ expect(result.current.breakpoints.isLg).toBe(false);
120
+ expect(result.current.breakpoints.isXl).toBe(true);
121
+ });
122
+ it('should set isCompact for height < 300', () => {
123
+ setMockBounds({ width: 1000, height: 299 });
124
+ const { result } = renderHook(() => useWidgetSize());
125
+ expect(result.current.breakpoints.isCompact).toBe(true);
126
+ expect(result.current.breakpoints.isTall).toBe(false);
127
+ });
128
+ it('should set isTall for height >= 600', () => {
129
+ setMockBounds({ width: 1000, height: 600 });
130
+ const { result } = renderHook(() => useWidgetSize());
131
+ expect(result.current.breakpoints.isTall).toBe(true);
132
+ expect(result.current.breakpoints.isCompact).toBe(false);
133
+ setMockBounds({ width: 1000, height: 800 });
134
+ const { result: result2 } = renderHook(() => useWidgetSize());
135
+ expect(result2.current.breakpoints.isTall).toBe(true);
136
+ expect(result2.current.breakpoints.isCompact).toBe(false);
137
+ });
138
+ it('should not set isCompact or isTall for 300 <= height < 600', () => {
139
+ setMockBounds({ width: 1000, height: 300 });
140
+ let { result } = renderHook(() => useWidgetSize());
141
+ expect(result.current.breakpoints.isCompact).toBe(false);
142
+ expect(result.current.breakpoints.isTall).toBe(false);
143
+ setMockBounds({ width: 1000, height: 599 });
144
+ result = renderHook(() => useWidgetSize()).result;
145
+ expect(result.current.breakpoints.isCompact).toBe(false);
146
+ expect(result.current.breakpoints.isTall).toBe(false);
147
+ });
148
+ });
149
+ it('should provide bounds information', () => {
150
+ setMockBounds({
151
+ left: 1,
152
+ top: 2,
153
+ width: 300,
154
+ height: 400,
155
+ bottom: 402,
156
+ right: 301,
157
+ x: 1,
158
+ y: 2,
159
+ });
160
+ const { result } = renderHook(() => useWidgetSize());
161
+ expect(result.current.bounds).toBeDefined();
162
+ expect(result.current.bounds.left).toBe(1);
163
+ expect(result.current.bounds.top).toBe(2);
164
+ expect(result.current.bounds.width).toBe(300);
165
+ expect(result.current.bounds.height).toBe(400);
166
+ expect(result.current.bounds.bottom).toBe(402);
167
+ expect(result.current.bounds.right).toBe(301);
168
+ expect(result.current.bounds.x).toBe(1);
169
+ expect(result.current.bounds.y).toBe(2);
170
+ });
171
+ it('should provide responsive utility functions', () => {
172
+ setMockBounds({ width: 1200 });
173
+ const { result } = renderHook(() => useWidgetSize());
174
+ expect(result.current.isAbove).toBeDefined();
175
+ expect(typeof result.current.isAbove).toBe('function');
176
+ expect(result.current.isBelow).toBeDefined();
177
+ expect(typeof result.current.isBelow).toBe('function');
178
+ });
179
+ it('should calculate responsive utility functions correctly', () => {
180
+ setMockBounds({ width: 1100 });
181
+ const { result } = renderHook(() => useWidgetSize());
182
+ expect(result.current.isAbove('sm')).toBe(true); // 1100 >= 1000
183
+ expect(result.current.isBelow('lg')).toBe(true); // 1100 < 1400
184
+ expect(result.current.isAbove('xl')).toBe(false); // 1100 < Infinity
185
+ expect(result.current.isBelow('xs')).toBe(false); // 1100 >= 800
186
+ });
187
+ });
@@ -1,5 +1,5 @@
1
1
  import { useMediaQuery, useTheme } from '@mui/material';
2
2
  import UIThemeProvider from './UIThemeProvider';
3
- import { useResponsive } from './hooks';
4
- export { useMediaQuery, useResponsive, useTheme };
3
+ import { useResponsive, useWidgetSize, type WidgetSizeInfo } from './hooks';
4
+ export { useMediaQuery, useResponsive, useTheme, useWidgetSize, type WidgetSizeInfo };
5
5
  export default UIThemeProvider;
@@ -1,5 +1,5 @@
1
1
  import { useMediaQuery, useTheme } from '@mui/material';
2
2
  import UIThemeProvider from './UIThemeProvider';
3
- import { useResponsive } from './hooks';
4
- export { useMediaQuery, useResponsive, useTheme };
3
+ import { useResponsive, useWidgetSize } from './hooks';
4
+ export { useMediaQuery, useResponsive, useTheme, useWidgetSize };
5
5
  export default UIThemeProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.6.0-dev.1",
3
+ "version": "1.6.0-dev.11",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",
@@ -128,6 +128,7 @@
128
128
  "react-input-mask": "^2.0.4",
129
129
  "react-number-format": "^4.9.3",
130
130
  "react-querybuilder": "^6.0.2",
131
+ "react-use-measure": "^2.1.7",
131
132
  "rtf.js": "^3.0.9",
132
133
  "sift": "^17.1.3",
133
134
  "small-date": "^2.0.0",