@developer_tribe/react-builder 1.2.44 → 1.2.45

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.
@@ -0,0 +1,264 @@
1
+ import React from 'react';
2
+ import { useForm } from 'react-hook-form';
3
+ import Modal from './Modal';
4
+ import { Device } from '../types/Device';
5
+ import { useCustomDeviceStore } from '../store/customDeviceStore';
6
+
7
+ type CreateDeviceModalProps = {
8
+ onClose: () => void;
9
+ onSuccess: (device: Device) => void;
10
+ deviceToEdit?: Device;
11
+ };
12
+
13
+ type FormData = {
14
+ name: string;
15
+ platform: 'ios' | 'android';
16
+ width: number;
17
+ height: number;
18
+ type: 'phone' | 'tablet';
19
+ radius: number;
20
+ insetTop: number;
21
+ insetRight: number;
22
+ insetBottom: number;
23
+ insetLeft: number;
24
+ navigationBarType: Device['navigationBarType'];
25
+ importance: number;
26
+ multiplier: number;
27
+ };
28
+
29
+ export function CreateDeviceModal({
30
+ onClose,
31
+ onSuccess,
32
+ deviceToEdit,
33
+ }: CreateDeviceModalProps) {
34
+ const { addCustomDevice, updateCustomDevice } = useCustomDeviceStore();
35
+ const {
36
+ register,
37
+ handleSubmit,
38
+ watch,
39
+ formState: { errors },
40
+ } = useForm<FormData>({
41
+ defaultValues: deviceToEdit
42
+ ? {
43
+ name: deviceToEdit.name,
44
+ platform: deviceToEdit.platform as 'ios' | 'android',
45
+ type: deviceToEdit.type,
46
+ width: deviceToEdit.width,
47
+ height: deviceToEdit.height,
48
+ insetTop: deviceToEdit.insets?.[0] ?? 0,
49
+ insetRight: deviceToEdit.insets?.[1] ?? 0,
50
+ insetBottom: deviceToEdit.insets?.[2] ?? 0,
51
+ insetLeft: deviceToEdit.insets?.[3] ?? 0,
52
+ navigationBarType: deviceToEdit.navigationBarType,
53
+ radius: deviceToEdit.radius,
54
+ importance: deviceToEdit.importance,
55
+ multiplier: deviceToEdit.multiplier,
56
+ }
57
+ : {
58
+ platform: 'ios',
59
+ type: 'phone',
60
+ navigationBarType: 'homeIndicator',
61
+ width: 375,
62
+ height: 812,
63
+ insetTop: 44,
64
+ insetBottom: 34,
65
+ insetLeft: 0,
66
+ insetRight: 0,
67
+ radius: 40,
68
+ importance: 10,
69
+ multiplier: 1,
70
+ },
71
+ });
72
+
73
+ const platform = watch('platform');
74
+
75
+ const onSubmit = (data: FormData) => {
76
+ const newDevice: Device = {
77
+ name: data.name,
78
+ platform: data.platform,
79
+ width: Number(data.width),
80
+ height: Number(data.height),
81
+ type: data.type,
82
+ radius: Number(data.radius),
83
+ insets: [
84
+ Number(data.insetTop),
85
+ Number(data.insetRight),
86
+ Number(data.insetBottom),
87
+ Number(data.insetLeft),
88
+ ],
89
+ navigationBarType: data.navigationBarType,
90
+ aspect: (() => {
91
+ const r = Number(data.height) / Number(data.width);
92
+ if (r >= 2.05) return 'tall';
93
+ if (r <= 1.75) return 'wide';
94
+ return 'regular';
95
+ })(),
96
+ importance: Number(data.importance),
97
+ multiplier: Number(data.multiplier),
98
+ };
99
+
100
+ if (deviceToEdit) {
101
+ updateCustomDevice(deviceToEdit.name, newDevice);
102
+ } else {
103
+ addCustomDevice(newDevice);
104
+ }
105
+ onSuccess(newDevice);
106
+ onClose();
107
+ };
108
+
109
+ return (
110
+ <Modal
111
+ onClose={onClose}
112
+ ariaLabelledBy="create-device-title"
113
+ contentClassName="create-device-modal"
114
+ >
115
+ <div className="modal__header">
116
+ <h3 id="create-device-title" className="modal__title">
117
+ {deviceToEdit ? 'Edit Custom Device' : 'Create Custom Device'}
118
+ </h3>
119
+ <button type="button" className="editor-button" onClick={onClose}>
120
+ Cancel
121
+ </button>
122
+ </div>
123
+ <form
124
+ onSubmit={handleSubmit(onSubmit)}
125
+ className="modal__body create-device-form"
126
+ >
127
+ <div className="create-device-form__group">
128
+ <label className="create-device-form__label">Device Name</label>
129
+ <input
130
+ {...register('name', { required: 'Name is required' })}
131
+ className="editor-input"
132
+ placeholder="e.g. My Custom iPhone"
133
+ />
134
+ {errors.name && (
135
+ <span className="create-device-form__error">
136
+ {errors.name.message}
137
+ </span>
138
+ )}
139
+ </div>
140
+
141
+ <div className="create-device-form__row">
142
+ <div className="create-device-form__group">
143
+ <label className="create-device-form__label">Platform</label>
144
+ <select {...register('platform')} className="editor-input">
145
+ <option value="ios">iOS</option>
146
+ <option value="android">Android</option>
147
+ </select>
148
+ </div>
149
+ <div className="create-device-form__group">
150
+ <label className="create-device-form__label">Type</label>
151
+ <select {...register('type')} className="editor-input">
152
+ <option value="phone">Phone</option>
153
+ <option value="tablet">Tablet</option>
154
+ </select>
155
+ </div>
156
+ </div>
157
+
158
+ <div className="create-device-form__row">
159
+ <div className="create-device-form__group">
160
+ <label className="create-device-form__label">Width (px)</label>
161
+ <input
162
+ type="number"
163
+ {...register('width', { required: true, min: 1 })}
164
+ className="editor-input"
165
+ />
166
+ </div>
167
+ <div className="create-device-form__group">
168
+ <label className="create-device-form__label">Height (px)</label>
169
+ <input
170
+ type="number"
171
+ {...register('height', { required: true, min: 1 })}
172
+ className="editor-input"
173
+ />
174
+ </div>
175
+ </div>
176
+
177
+ <div className="create-device-form__row">
178
+ <div className="create-device-form__group">
179
+ <label className="create-device-form__label">Safe Area Top</label>
180
+ <input
181
+ type="number"
182
+ {...register('insetTop', { min: 0 })}
183
+ className="editor-input"
184
+ />
185
+ </div>
186
+ <div className="create-device-form__group">
187
+ <label className="create-device-form__label">
188
+ Safe Area Bottom
189
+ </label>
190
+ <input
191
+ type="number"
192
+ {...register('insetBottom', { min: 0 })}
193
+ className="editor-input"
194
+ />
195
+ </div>
196
+ </div>
197
+
198
+ <div className="create-device-form__row">
199
+ <div className="create-device-form__group">
200
+ <label className="create-device-form__label">Navigation Bar</label>
201
+ <select {...register('navigationBarType')} className="editor-input">
202
+ <option value="none">None</option>
203
+ {platform === 'ios' ? (
204
+ <>
205
+ <option value="homeIndicator">Home Indicator</option>
206
+ <option value="tabBar">Tab Bar</option>
207
+ </>
208
+ ) : (
209
+ <>
210
+ <option value="threeButtons">Three Buttons</option>
211
+ <option value="gesture">Gesture</option>
212
+ </>
213
+ )}
214
+ </select>
215
+ </div>
216
+ <div className="create-device-form__group">
217
+ <label className="create-device-form__label">Corner Radius</label>
218
+ <input
219
+ type="number"
220
+ {...register('radius', { min: 0 })}
221
+ className="editor-input"
222
+ />
223
+ </div>
224
+ </div>
225
+
226
+ <div className="create-device-form__row">
227
+ <div className="create-device-form__group">
228
+ <label className="create-device-form__label">
229
+ Scale Multiplier
230
+ </label>
231
+ <input
232
+ type="number"
233
+ step="0.01"
234
+ {...register('multiplier', { min: 0.1, max: 2 })}
235
+ className="editor-input"
236
+ />
237
+ </div>
238
+ <div className="create-device-form__group">
239
+ <label className="create-device-form__label">
240
+ Importance (1-100)
241
+ </label>
242
+ <input
243
+ type="number"
244
+ {...register('importance', { min: 1, max: 100 })}
245
+ className="editor-input"
246
+ />
247
+ </div>
248
+ </div>
249
+
250
+ <div className="create-device-modal__footer">
251
+ <button
252
+ type="submit"
253
+ className="editor-button editor-button--primary"
254
+ style={{ width: '100%' }}
255
+ >
256
+ {deviceToEdit ? 'Update Device' : 'Save Device'}
257
+ </button>
258
+ </div>
259
+ </form>
260
+ </Modal>
261
+ );
262
+ }
263
+
264
+ export default CreateDeviceModal;
@@ -3,6 +3,8 @@ import { Device } from '../types/Device';
3
3
  import Modal from './Modal';
4
4
  import { DeviceButton } from '../components/DeviceButton';
5
5
  import { useRenderStore } from '../store';
6
+ import { useCustomDeviceStore } from '../store/customDeviceStore';
7
+ import { CreateDeviceModal } from './CreateDeviceModal';
6
8
 
7
9
  type DeviceSelectorModalProps = {
8
10
  devices: Device[];
@@ -18,10 +20,17 @@ export function DeviceSelectorModal({
18
20
  onClose,
19
21
  }: DeviceSelectorModalProps) {
20
22
  const [searchTerm, setSearchTerm] = useState('');
23
+ const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
24
+ const [editingDevice, setEditingDevice] = useState<Device | null>(null);
21
25
  const { favoriteDevices, toggleFavoriteDevice } = useRenderStore((state) => ({
22
26
  favoriteDevices: state.favoriteDevices || [],
23
27
  toggleFavoriteDevice: state.toggleFavoriteDevice,
24
28
  }));
29
+ const { customDevices, removeCustomDevice } = useCustomDeviceStore();
30
+
31
+ const allDevices = useMemo(() => {
32
+ return [...customDevices, ...devices];
33
+ }, [customDevices, devices]);
25
34
 
26
35
  const handleDeviceSelect = (device: Device) => {
27
36
  onSelect(device);
@@ -29,10 +38,10 @@ export function DeviceSelectorModal({
29
38
  };
30
39
 
31
40
  const filteredDevices = useMemo(() => {
32
- return devices.filter((device) =>
41
+ return allDevices.filter((device) =>
33
42
  device.name.toLowerCase().includes(searchTerm.toLowerCase()),
34
43
  );
35
- }, [devices, searchTerm]);
44
+ }, [allDevices, searchTerm]);
36
45
 
37
46
  const { favorites, others } = useMemo(() => {
38
47
  const favs: Device[] = [];
@@ -66,18 +75,21 @@ export function DeviceSelectorModal({
66
75
  Close
67
76
  </button>
68
77
  </div>
69
- <div
70
- className="device-selector-modal__search"
71
- style={{ padding: '0 16px', marginBottom: '8px' }}
72
- >
78
+ <div className="device-selector-modal__search-container">
73
79
  <input
74
80
  type="text"
75
81
  placeholder="Search devices..."
76
82
  value={searchTerm}
77
83
  onChange={(e) => setSearchTerm(e.target.value)}
78
84
  className="editor-input"
79
- style={{ width: '100%', padding: '8px', boxSizing: 'border-box' }}
80
85
  />
86
+ <button
87
+ type="button"
88
+ className="editor-button editor-button--primary"
89
+ onClick={() => setIsCreateModalOpen(true)}
90
+ >
91
+ Add New
92
+ </button>
81
93
  </div>
82
94
  <div
83
95
  className="device-selector-modal__body"
@@ -103,6 +115,7 @@ export function DeviceSelectorModal({
103
115
  onSelect={handleDeviceSelect}
104
116
  isFavorite={true}
105
117
  onToggleFavorite={(d) => toggleFavoriteDevice(d.name)}
118
+ onEdit={(d) => setEditingDevice(d)}
106
119
  />
107
120
  ))}
108
121
  </div>
@@ -129,11 +142,35 @@ export function DeviceSelectorModal({
129
142
  onSelect={handleDeviceSelect}
130
143
  isFavorite={false}
131
144
  onToggleFavorite={(d) => toggleFavoriteDevice(d.name)}
145
+ onEdit={
146
+ customDevices.some((cd) => cd.name === device.name)
147
+ ? (d) => setEditingDevice(d)
148
+ : undefined
149
+ }
132
150
  />
133
151
  ))}
134
152
  </div>
135
153
  </section>
136
154
  </div>
155
+ {isCreateModalOpen && (
156
+ <CreateDeviceModal
157
+ onClose={() => setIsCreateModalOpen(false)}
158
+ onSuccess={(newDevice) => {
159
+ onSelect(newDevice);
160
+ onClose();
161
+ }}
162
+ />
163
+ )}
164
+ {editingDevice && (
165
+ <CreateDeviceModal
166
+ deviceToEdit={editingDevice}
167
+ onClose={() => setEditingDevice(null)}
168
+ onSuccess={(updatedDevice) => {
169
+ onSelect(updatedDevice);
170
+ onClose();
171
+ }}
172
+ />
173
+ )}
137
174
  </Modal>
138
175
  );
139
176
  }
@@ -1,4 +1,7 @@
1
- import { convertIOSPeriodUnit } from './periodLocalizationKeys';
1
+ import {
2
+ convertIOSPeriodUnit,
3
+ normalizeIOSPeriod,
4
+ } from './periodLocalizationKeys';
2
5
  import { iapLogger } from '../logger';
3
6
  import {
4
7
  calculateDiscount,
@@ -60,10 +63,13 @@ export function extractIOSParams(
60
63
  const currency = product.currency || product.currencyCode || '';
61
64
  const localizedPrice = product.localizedPrice || '';
62
65
 
63
- const periodUnit = convertIOSPeriodUnit(
64
- product.subscriptionPeriodUnitIOS || 'MONTH',
66
+ // iOS bazen WEEK yerine DAY+7 döndürür — normalize et
67
+ const normalizedPeriod = normalizeIOSPeriod(
68
+ product.subscriptionPeriodUnitIOS,
69
+ product.subscriptionPeriodNumberIOS,
65
70
  );
66
- const periodValue = String(product.subscriptionPeriodNumberIOS || 1);
71
+ const periodUnit = normalizedPeriod.unit;
72
+ const periodValue = String(normalizedPeriod.value);
67
73
  const periodType = `${periodValue} ${periodUnit}${parseInt(periodValue, 10) > 1 ? 's' : ''}`;
68
74
 
69
75
  const introPrice =
@@ -112,3 +112,49 @@ export function convertIOSPeriodUnit(
112
112
  const normalized = unitMap[iosUnit.toUpperCase()];
113
113
  return normalized || 'month';
114
114
  }
115
+
116
+ /**
117
+ * iOS'un döndüğü ham period değerlerini semantik olarak normalize eder.
118
+ *
119
+ * iOS bazen "WEEK" yerine "DAY" + 7, "MONTH" yerine "DAY" + 30 döndürür.
120
+ * Bu fonksiyon bu ham değerleri doğru semantic period'a çevirir.
121
+ *
122
+ * @example normalizeIOSPeriod('DAY', 7) → { unit: 'week', value: 1 }
123
+ * @example normalizeIOSPeriod('DAY', 14) → { unit: 'week', value: 2 }
124
+ * @example normalizeIOSPeriod('DAY', 30) → { unit: 'month', value: 1 }
125
+ * @example normalizeIOSPeriod('DAY', 365) → { unit: 'year', value: 1 }
126
+ * @example normalizeIOSPeriod('MONTH', 1) → { unit: 'month', value: 1 }
127
+ */
128
+ export function normalizeIOSPeriod(
129
+ iosUnit: string | undefined,
130
+ iosValue: number | undefined,
131
+ ): { unit: 'day' | 'week' | 'month' | 'year'; value: number } {
132
+ const rawUnit = convertIOSPeriodUnit(iosUnit);
133
+ const rawValue = iosValue || 1;
134
+
135
+ // DAY cinsinden gelen değerleri daha büyük birime çevir
136
+ if (rawUnit === 'day') {
137
+ if (rawValue % 365 === 0) {
138
+ return { unit: 'year', value: rawValue / 365 };
139
+ }
140
+ if (rawValue === 366) {
141
+ return { unit: 'year', value: 1 };
142
+ }
143
+ if (rawValue % 30 === 0) {
144
+ return { unit: 'month', value: rawValue / 30 };
145
+ }
146
+ if (rawValue === 31) {
147
+ return { unit: 'month', value: 1 };
148
+ }
149
+ if (rawValue % 7 === 0) {
150
+ return { unit: 'week', value: rawValue / 7 };
151
+ }
152
+ }
153
+
154
+ // MONTH cinsinden gelen değerleri yıla çevir
155
+ if (rawUnit === 'month' && rawValue % 12 === 0) {
156
+ return { unit: 'year', value: rawValue / 12 };
157
+ }
158
+
159
+ return { unit: rawUnit, value: rawValue };
160
+ }
@@ -0,0 +1,38 @@
1
+ import { create } from 'zustand';
2
+ import { persist } from 'zustand/middleware';
3
+ import { Device } from '../types/Device';
4
+
5
+ interface CustomDeviceState {
6
+ customDevices: Device[];
7
+ addCustomDevice: (device: Device) => void;
8
+ removeCustomDevice: (name: string) => void;
9
+ updateCustomDevice: (name: string, updatedDevice: Device) => void;
10
+ }
11
+
12
+ export const useCustomDeviceStore = create<CustomDeviceState>()(
13
+ persist(
14
+ (set) => ({
15
+ customDevices: [],
16
+ addCustomDevice: (device) =>
17
+ set((state) => ({
18
+ customDevices: [
19
+ device,
20
+ ...state.customDevices.filter((d) => d.name !== device.name),
21
+ ],
22
+ })),
23
+ removeCustomDevice: (name) =>
24
+ set((state) => ({
25
+ customDevices: state.customDevices.filter((d) => d.name !== name),
26
+ })),
27
+ updateCustomDevice: (name, updatedDevice) =>
28
+ set((state) => ({
29
+ customDevices: state.customDevices.map((d) =>
30
+ d.name === name ? updatedDevice : d,
31
+ ),
32
+ })),
33
+ }),
34
+ {
35
+ name: 'custom-devices-storage',
36
+ },
37
+ ),
38
+ );
@@ -94,7 +94,7 @@
94
94
  }
95
95
  }
96
96
 
97
- .editor-device-button span {
97
+ .editor-device-button__platform {
98
98
  position: absolute;
99
99
  bottom: 4px;
100
100
  right: 4px;
@@ -106,7 +106,7 @@
106
106
  overflow: hidden;
107
107
  }
108
108
 
109
- .editor-device-button img {
109
+ .editor-device-button__platform img {
110
110
  position: absolute;
111
111
  top: 50%;
112
112
  left: 50%;
@@ -117,6 +117,16 @@
117
117
  height: auto;
118
118
  }
119
119
 
120
+ .editor-device-button__edit {
121
+ transition:
122
+ opacity 0.2s ease,
123
+ transform 0.2s ease;
124
+ &:hover {
125
+ opacity: 1 !important;
126
+ transform: scale(1.1);
127
+ }
128
+ }
129
+
120
130
  .editor-header__actions {
121
131
  margin-left: auto; /* push actions to the far right */
122
132
  display: flex;
@@ -32,5 +32,6 @@
32
32
  @use './modals/benefit-presets-modal';
33
33
  @use './modals/inspect-modal';
34
34
  @use './modals/prompt-manager-modal';
35
+ @use './modals/create-device';
35
36
 
36
37
  @use './utilities/carousel';
@@ -0,0 +1,113 @@
1
+ @use '../foundation/colors' as colors;
2
+ @use '../foundation/sizes' as sizes;
3
+ @use '../foundation/typography' as typography;
4
+
5
+ .create-device-modal {
6
+ width: 100%;
7
+ max-width: 480px;
8
+
9
+ .modal__body {
10
+ padding: sizes.$spaceComfy;
11
+ display: flex;
12
+ flex-direction: column;
13
+ gap: sizes.$spaceCozy;
14
+ }
15
+ }
16
+
17
+ .create-device-form {
18
+ &__group {
19
+ display: flex;
20
+ flex-direction: column;
21
+ gap: sizes.$spaceTight;
22
+ }
23
+
24
+ &__row {
25
+ display: flex;
26
+ gap: sizes.$spaceCozy;
27
+
28
+ > * {
29
+ flex: 1;
30
+ }
31
+ }
32
+
33
+ &__label {
34
+ font-size: sizes.$fontSizeSm;
35
+ font-weight: 600;
36
+ color: colors.$mutedTextColor;
37
+ text-transform: uppercase;
38
+ letter-spacing: sizes.$letterSpacingTight;
39
+ }
40
+
41
+ &__error {
42
+ color: colors.$dangerColor;
43
+ font-size: sizes.$fontSizeXs;
44
+ margin-top: 2px;
45
+ }
46
+
47
+ &__footer {
48
+ margin-top: sizes.$spaceCozy;
49
+ display: flex;
50
+ justify-content: flex-end;
51
+ }
52
+ }
53
+
54
+ // Global-ish classes but styled for this context if not already defined
55
+ .editor-input {
56
+ height: sizes.$controlHeightMd;
57
+ padding: 0 sizes.$spaceInset;
58
+ border-radius: sizes.$radiusMid;
59
+ border: 1px solid colors.$borderColor;
60
+ background: colors.$surfaceColor;
61
+ color: colors.$textColor;
62
+ font-family: inherit;
63
+ font-size: sizes.$fontSizeBase;
64
+ width: 100%;
65
+ transition:
66
+ border-color 0.2s ease,
67
+ box-shadow 0.2s ease;
68
+
69
+ &:focus {
70
+ outline: none;
71
+ border-color: colors.$accentColor;
72
+ box-shadow: 0 0 0 3px hsl(var(--rb-primary) / 0.15);
73
+ }
74
+
75
+ &::placeholder {
76
+ color: colors.$mutedTextColor;
77
+ opacity: 0.5;
78
+ }
79
+ }
80
+
81
+ select.editor-input {
82
+ cursor: pointer;
83
+ appearance: none;
84
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 5 3 3 3-3'/%3E%3C/svg%3E");
85
+ background-repeat: no-repeat;
86
+ background-position: right sizes.$spaceInset center;
87
+ padding-right: sizes.$spaceRoomy;
88
+ }
89
+
90
+ .editor-button--primary {
91
+ background: colors.$textColor;
92
+ color: colors.$surfaceColor;
93
+ font-weight: 600;
94
+ border-color: colors.$textColor;
95
+
96
+ &:hover {
97
+ background: colors.$accentColor;
98
+ border-color: colors.$accentColor;
99
+ }
100
+ }
101
+
102
+ .device-selector-modal__search-container {
103
+ padding: 0 sizes.$spaceComfy;
104
+ margin-top: sizes.$spaceComfy;
105
+ margin-bottom: sizes.$spaceCompact;
106
+ display: flex;
107
+ gap: sizes.$spaceCozy;
108
+ align-items: center;
109
+
110
+ .editor-input {
111
+ flex: 1;
112
+ }
113
+ }
@@ -79,6 +79,14 @@ export function normalizeNodeForValidation(
79
79
  ? normalizeUnknownValue(attributes)
80
80
  : attributes;
81
81
 
82
+ if (
83
+ isPlainObject(attributes) &&
84
+ Array.isArray(attributes.styles) &&
85
+ attributes.styles.length === 0
86
+ ) {
87
+ attributes.styles = {};
88
+ }
89
+
82
90
  const children =
83
91
  recordData.children !== undefined
84
92
  ? (normalizeNodeForValidation(
@@ -14,6 +14,7 @@ import {
14
14
  isNodeNullOrUndefined,
15
15
  isNodeString,
16
16
  } from './nodeGuards';
17
+ import { logger } from './logger';
17
18
 
18
19
  export type AnalyseResultWithPath = {
19
20
  valid: boolean;
@@ -407,7 +408,13 @@ function validateAttributesByPattern(
407
408
  // Validate nested `attributes.styles` (canonical store for AttributesEditor).
408
409
  if (maybeStyles != null) {
409
410
  if (!isPlainObject(maybeStyles)) {
410
- return fail(`styles must be an object`, joinPath(path, 'styles'));
411
+ const msg = `styles must be an object`;
412
+ logger.error('analyseNodeByPatterns', msg, {
413
+ path: joinPath(path, 'styles'),
414
+ actualValue: maybeStyles,
415
+ actualType: Array.isArray(maybeStyles) ? 'array' : typeof maybeStyles,
416
+ });
417
+ return fail(msg, joinPath(path, 'styles'));
411
418
  }
412
419
  const stylesRecord = maybeStyles as Record<string, unknown>;
413
420
  for (const [styleKey, styleValue] of Object.entries(stylesRecord)) {