@admin-layout/tailwind-design-pro 12.0.16-alpha.51 → 12.0.16-alpha.53
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/lib/components/Layout/TailwindLayout.js +2 -2
- package/lib/components/Layout/TailwindLayout.js.map +1 -1
- package/lib/components/SettingDrawer/InvitationSettings.d.ts.map +1 -1
- package/lib/components/SettingDrawer/InvitationSettings.js +5 -16
- package/lib/components/SettingDrawer/InvitationSettings.js.map +1 -1
- package/lib/components/SettingDrawer/LayoutChange.d.ts.map +1 -1
- package/lib/components/SettingDrawer/LayoutChange.js +11 -43
- package/lib/components/SettingDrawer/LayoutChange.js.map +1 -1
- package/lib/components/SettingDrawer/NavigationsModes.d.ts.map +1 -1
- package/lib/components/SettingDrawer/NavigationsModes.js +8 -47
- package/lib/components/SettingDrawer/NavigationsModes.js.map +1 -1
- package/lib/components/SettingDrawer/RegionalSettings.d.ts.map +1 -1
- package/lib/components/SettingDrawer/RegionalSettings.js +29 -50
- package/lib/components/SettingDrawer/RegionalSettings.js.map +1 -1
- package/lib/components/SettingDrawer/SettingDrawer.d.ts.map +1 -1
- package/lib/components/SettingDrawer/SettingDrawer.js +63 -75
- package/lib/components/SettingDrawer/SettingDrawer.js.map +1 -1
- package/lib/machines/settingsMachine.d.ts.map +1 -1
- package/lib/machines/settingsMachine.js +52 -33
- package/lib/machines/settingsMachine.js.map +1 -1
- package/lib/machines/types.d.ts +0 -1
- package/lib/machines/types.d.ts.map +1 -1
- package/lib/utils/configOverrides.js +1 -239
- package/lib/utils/configOverrides.js.map +1 -1
- package/lib/utils/settingsUtils.d.ts +13 -63
- package/lib/utils/settingsUtils.d.ts.map +1 -1
- package/lib/utils/settingsUtils.js +92 -0
- package/lib/utils/settingsUtils.js.map +1 -0
- package/package.json +5 -5
|
@@ -72,44 +72,6 @@
|
|
|
72
72
|
* parseMultipleBracketIdentifiers("[/dashboard.mobile]") // Backward compatibility
|
|
73
73
|
* // Returns: ['/dashboard', 'mobile']
|
|
74
74
|
*/
|
|
75
|
-
function parseMultipleBracketIdentifiers(overrideKey) {
|
|
76
|
-
const identifiers = [];
|
|
77
|
-
// Match all bracket pairs: [something]
|
|
78
|
-
const bracketMatches = overrideKey.match(/\[([^\]]+)\]/g);
|
|
79
|
-
if (!bracketMatches) {
|
|
80
|
-
return identifiers;
|
|
81
|
-
}
|
|
82
|
-
// If there's only one bracket, check if it contains a dot (old format)
|
|
83
|
-
if (bracketMatches.length === 1) {
|
|
84
|
-
const content = bracketMatches[0].slice(1, -1); // Remove brackets
|
|
85
|
-
// Check if it's the old format with dot notation
|
|
86
|
-
if (content.includes('.')) {
|
|
87
|
-
const parts = content.split('.');
|
|
88
|
-
// Handle [.device] pattern
|
|
89
|
-
if (parts[0] === '' && parts[1]) {
|
|
90
|
-
identifiers.push(parts[1]);
|
|
91
|
-
}
|
|
92
|
-
// Handle [route.device] pattern
|
|
93
|
-
else {
|
|
94
|
-
parts.forEach(part => {
|
|
95
|
-
if (part) identifiers.push(part);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
// Single identifier without dot
|
|
100
|
-
identifiers.push(content);
|
|
101
|
-
}
|
|
102
|
-
} else {
|
|
103
|
-
// Multiple brackets: extract content from each
|
|
104
|
-
bracketMatches.forEach(match => {
|
|
105
|
-
const content = match.slice(1, -1); // Remove brackets
|
|
106
|
-
if (content) {
|
|
107
|
-
identifiers.push(content);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
return identifiers;
|
|
112
|
-
}
|
|
113
75
|
/**
|
|
114
76
|
* Convert a dot-notation path to a nested object
|
|
115
77
|
* @example
|
|
@@ -152,204 +114,4 @@ function getNestedValue(obj, path, defaultValue) {
|
|
|
152
114
|
current = current[key];
|
|
153
115
|
}
|
|
154
116
|
return current !== undefined ? current : defaultValue;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Build an override context key from context
|
|
158
|
-
*
|
|
159
|
-
* Format: [route][device] or [route] or [device]
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* buildOverrideKey({ route: '/dashboard', device: 'mobile' })
|
|
163
|
-
* // Returns: "[/dashboard][mobile]"
|
|
164
|
-
*
|
|
165
|
-
* buildOverrideKey({ route: '/dashboard' })
|
|
166
|
-
* // Returns: "[/dashboard]"
|
|
167
|
-
*
|
|
168
|
-
* buildOverrideKey({ device: 'mobile' })
|
|
169
|
-
* // Returns: "[mobile]"
|
|
170
|
-
*/
|
|
171
|
-
function buildOverrideKey(context) {
|
|
172
|
-
const {
|
|
173
|
-
route,
|
|
174
|
-
device,
|
|
175
|
-
...rest
|
|
176
|
-
} = context;
|
|
177
|
-
// Handle route and device specifically - use multiple bracket format
|
|
178
|
-
if (route && device) {
|
|
179
|
-
return `[${route}][${device}]`;
|
|
180
|
-
} else if (route) {
|
|
181
|
-
return `[${route}]`;
|
|
182
|
-
} else if (device) {
|
|
183
|
-
return `[${device}]`;
|
|
184
|
-
}
|
|
185
|
-
// Fallback for other context keys (future extensibility)
|
|
186
|
-
const parts = [];
|
|
187
|
-
for (const [key, value] of Object.entries(rest)) {
|
|
188
|
-
if (value !== undefined && value !== null) {
|
|
189
|
-
parts.push(`${key}=${value}`);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
if (parts.length > 0) {
|
|
193
|
-
return `[${parts.join(',')}]`;
|
|
194
|
-
}
|
|
195
|
-
return '';
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Parse an override key into its components
|
|
199
|
-
* Supports both new multiple bracket format and legacy dot notation
|
|
200
|
-
*
|
|
201
|
-
* @example
|
|
202
|
-
* parseOverrideKey("[/dashboard][mobile]") // New format
|
|
203
|
-
* // Returns: { route: '/dashboard', device: 'mobile' }
|
|
204
|
-
*
|
|
205
|
-
* parseOverrideKey("[/dashboard.mobile]") // Legacy format
|
|
206
|
-
* // Returns: { route: '/dashboard', device: 'mobile' }
|
|
207
|
-
*
|
|
208
|
-
* parseOverrideKey("[/dashboard]")
|
|
209
|
-
* // Returns: { route: '/dashboard' }
|
|
210
|
-
*
|
|
211
|
-
* parseOverrideKey("[mobile]")
|
|
212
|
-
* // Returns: { device: 'mobile' }
|
|
213
|
-
*
|
|
214
|
-
* parseOverrideKey("[.mobile]") // Legacy device-only format
|
|
215
|
-
* // Returns: { device: 'mobile' }
|
|
216
|
-
*/
|
|
217
|
-
function parseOverrideKey(overrideKey) {
|
|
218
|
-
const context = {};
|
|
219
|
-
// First try multiple bracket pattern: [/route][device]
|
|
220
|
-
const multipleBracketMatch = overrideKey.match(/^(\[[^\]]+\])+$/);
|
|
221
|
-
if (multipleBracketMatch) {
|
|
222
|
-
const identifiers = parseMultipleBracketIdentifiers(overrideKey);
|
|
223
|
-
identifiers.forEach(identifier => {
|
|
224
|
-
if (identifier.startsWith('/')) {
|
|
225
|
-
context.route = identifier;
|
|
226
|
-
} else if (identifier === 'mobile' || identifier === 'desktop') {
|
|
227
|
-
context.device = identifier;
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
return context;
|
|
231
|
-
}
|
|
232
|
-
// Fallback to legacy single bracket pattern: [route.device] or [route] or [.device]
|
|
233
|
-
const match = overrideKey.match(/^\[([^\]]+)\]$/);
|
|
234
|
-
if (!match) {
|
|
235
|
-
return context;
|
|
236
|
-
}
|
|
237
|
-
const content = match[1];
|
|
238
|
-
// Check if it contains a dot
|
|
239
|
-
if (content.includes('.')) {
|
|
240
|
-
const parts = content.split('.');
|
|
241
|
-
// Handle [.device] pattern
|
|
242
|
-
if (parts[0] === '') {
|
|
243
|
-
context.device = parts[1];
|
|
244
|
-
}
|
|
245
|
-
// Handle [route.device] pattern
|
|
246
|
-
else {
|
|
247
|
-
context.route = parts[0];
|
|
248
|
-
if (parts[1]) {
|
|
249
|
-
context.device = parts[1];
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
} else {
|
|
253
|
-
// Handle [route] pattern (no dot means route only)
|
|
254
|
-
context.route = content;
|
|
255
|
-
}
|
|
256
|
-
return context;
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Get a configuration value with override support
|
|
260
|
-
*
|
|
261
|
-
* Priority:
|
|
262
|
-
* 1. Most specific override (all context matches)
|
|
263
|
-
* 2. Partial overrides (some context matches)
|
|
264
|
-
* 3. Base configuration value
|
|
265
|
-
* 4. Default value
|
|
266
|
-
*
|
|
267
|
-
* Works with nested storage where overrides are stored as:
|
|
268
|
-
* { "[route=/dashboard][device=mobile]": { uilayout: { regions: { header: { showLogo: false } } } } }
|
|
269
|
-
*/
|
|
270
|
-
function getConfigValue(settings, configKey, context, defaultValue) {
|
|
271
|
-
// Build the context key
|
|
272
|
-
const contextKey = buildOverrideKey(context);
|
|
273
|
-
// Check for exact override in nested structure
|
|
274
|
-
if (contextKey && settings?.[contextKey]) {
|
|
275
|
-
const overrideValue = getNestedValue(settings[contextKey], `uilayout.${configKey}`);
|
|
276
|
-
if (overrideValue !== undefined) {
|
|
277
|
-
return overrideValue;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
// Check for partial overrides with priority:
|
|
281
|
-
// 1. [route.device] (most specific)
|
|
282
|
-
// 2. [route] (route only)
|
|
283
|
-
// 3. [.device] (device only)
|
|
284
|
-
if (settings) {
|
|
285
|
-
const partialMatches = [];
|
|
286
|
-
for (const key of Object.keys(settings)) {
|
|
287
|
-
// Only check keys that look like context keys (start with '[')
|
|
288
|
-
if (!key.startsWith('[')) continue;
|
|
289
|
-
const parsed = parseOverrideKey(key);
|
|
290
|
-
// Check if this override matches current context
|
|
291
|
-
let matches = true;
|
|
292
|
-
let specificity = 0;
|
|
293
|
-
if (parsed.route !== undefined) {
|
|
294
|
-
if (parsed.route === context.route) {
|
|
295
|
-
specificity += 2; // Route match is worth 2 points
|
|
296
|
-
} else {
|
|
297
|
-
matches = false;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
if (parsed.device !== undefined) {
|
|
301
|
-
if (parsed.device === context.device) {
|
|
302
|
-
specificity += 1; // Device match is worth 1 point
|
|
303
|
-
} else {
|
|
304
|
-
matches = false;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
if (matches && specificity > 0) {
|
|
308
|
-
partialMatches.push({
|
|
309
|
-
key,
|
|
310
|
-
specificity
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
// Use the most specific override
|
|
315
|
-
if (partialMatches.length > 0) {
|
|
316
|
-
const mostSpecific = partialMatches.reduce((a, b) => a.specificity > b.specificity ? a : b);
|
|
317
|
-
const overrideValue = getNestedValue(settings[mostSpecific.key], `uilayout.${configKey}`);
|
|
318
|
-
if (overrideValue !== undefined) {
|
|
319
|
-
return overrideValue;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
// Check base configuration
|
|
324
|
-
const baseValue = getNestedValue(settings, `uilayout.${configKey}`);
|
|
325
|
-
if (baseValue !== undefined) {
|
|
326
|
-
return baseValue;
|
|
327
|
-
}
|
|
328
|
-
return defaultValue;
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Set a configuration value as an override
|
|
332
|
-
*
|
|
333
|
-
* Returns the context key and nested value structure.
|
|
334
|
-
* The service layer will merge this into the settings object.
|
|
335
|
-
*
|
|
336
|
-
* @example
|
|
337
|
-
* const result = setConfigOverride('regions.header.showLogo', false, { route: '/dashboard', device: 'mobile' });
|
|
338
|
-
* // Returns: {
|
|
339
|
-
* // contextKey: '[device=mobile][route=/dashboard]',
|
|
340
|
-
* // path: 'uilayout.regions.header.showLogo',
|
|
341
|
-
* // value: false,
|
|
342
|
-
* // nestedValue: { uilayout: { regions: { header: { showLogo: false } } } }
|
|
343
|
-
* // }
|
|
344
|
-
*/
|
|
345
|
-
function setConfigOverride(configKey, value, context) {
|
|
346
|
-
const contextKey = buildOverrideKey(context);
|
|
347
|
-
const path = `uilayout.${configKey}`;
|
|
348
|
-
const nestedValue = setNestedValue({}, path, value);
|
|
349
|
-
return {
|
|
350
|
-
contextKey,
|
|
351
|
-
path,
|
|
352
|
-
value,
|
|
353
|
-
nestedValue
|
|
354
|
-
};
|
|
355
|
-
}export{buildOverrideKey,getConfigValue,getNestedValue,parseMultipleBracketIdentifiers,parseOverrideKey,setConfigOverride,setNestedValue};//# sourceMappingURL=configOverrides.js.map
|
|
117
|
+
}export{getNestedValue,setNestedValue};//# sourceMappingURL=configOverrides.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configOverrides.js","sources":["../../src/utils/configOverrides.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DG;AAUH;;;;;;;;;;;;;AAaG
|
|
1
|
+
{"version":3,"file":"configOverrides.js","sources":["../../src/utils/configOverrides.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DG;AAUH;;;;;;;;;;;;;AAaG;;;;;AAoIA;AACH;AACI,uBAAwB,CAAG,GAAE,EAAA,IAAA,EAAA,KAAA,EAAA;AAC7B,EAAA,MAAA,WAAe,CAAA,KAAK,CAAA,GAAK,CAAC;QACtB,MAAA,GAAO;AAEX,IAAA,GAAA;AACI,GAAA;AACA,EAAA,IAAA,OAAK,GAAA,MAAQ;AACT,EAAA,KAAA,IAAA,CAAA,GAAA,CAAA,EAAA,CAAO,GAAC,IAAI,CAAG,MAAG,GAAA,CAAA,EAAA,CAAA,EAAA,EAAA;UACrB,GAAA,GAAA,IAAA,CAAA,CAAA,CAAA;gBAAO,CAAA,GAAA,CAAA,IAAA,OAAA,OAAA,CAAA,GAAA,CAAA,KAAA,QAAA,EAAA;aACJ,CAAA,GAAA,CAAA,GAAQ,EAAG;WACd;AACD,MAAA,OAAA,CAAA,GAAO,CAAG,GAAA;QACb,GAAA,OAAA,CAAA,GAAA;AAED,OAAA;AACA,IAAA;AACJ,IAAC,OAAA,GAAA,OAAA,CAAA,GAAA,CAAA;AAED,EAAA;;;;;AAKG;AACH;;;AAII;AACI,SAAI,cAAgB,CAAA,GAAI,EAAA,IAAO,EAAA,YAAc,EAAA;AACzC,EAAA,MAAA,IAAA,GAAA,IAAO;aACV,GAAA,GAAA;AACD,EAAA,KAAA,MAAA,GAAO,IAAG,IAAA,EAAQ;IACtB,IAAC,OAAA,KAAA,IAAA,IAAA,OAAA,KAAA,SAAA,IAAA,OAAA,OAAA,KAAA,QAAA,EAAA;MAED,OAAO,YAAY;AACvB,IAAC;AAED,IAAA,OAAA,GAAA,OAAA,CAAA,GAAA,CAAA;;AAEG,EAAA,OAAA,OAAA,KAAA,SAAA,GAAA,OAAA,GAAA,YAAA;AACH"}
|
|
@@ -1,70 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
deviceSettings: any;
|
|
7
|
-
layoutSettings: any;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Helper function to get value from uilayout with route/device override support
|
|
11
|
-
* @param path - Dot-notation path to the setting (e.g., 'header.showLogo')
|
|
12
|
-
* @param settings - Main settings object
|
|
13
|
-
* @param currentRoute - Current route path
|
|
14
|
-
* @param deviceType - Device type (mobile/desktop)
|
|
15
|
-
* @returns The setting value
|
|
16
|
-
*/
|
|
17
|
-
export declare const getUILayoutValue: (path: string, settings: any, currentRoute: string, deviceType: string) => any;
|
|
18
|
-
/**
|
|
19
|
-
* Builds device settings from uilayout
|
|
20
|
-
* @param settings - Main settings object
|
|
21
|
-
* @param currentRoute - Current route path
|
|
22
|
-
* @param deviceType - Device type (mobile/desktop)
|
|
23
|
-
* @returns Device settings object
|
|
24
|
-
*/
|
|
25
|
-
export declare const buildDeviceSettings: (settings: any, currentRoute: string, deviceType: string) => {
|
|
26
|
-
header: any;
|
|
27
|
-
background: any;
|
|
28
|
-
footer: any;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Builds layout settings from uilayout
|
|
32
|
-
* @param settings - Main settings object
|
|
2
|
+
* Get a setting value based on applyToAllRoutes flag and current route/device context
|
|
3
|
+
* @param machineSettings - The settings object from XState machine (may have overrides applied)
|
|
4
|
+
* @param settingName - The setting key to retrieve (e.g., 'fixedHeader', 'organization.members.invitations')
|
|
5
|
+
* @param applyToAllRoutes - Whether to use global or route-specific overrides
|
|
33
6
|
* @param currentRoute - Current route path
|
|
34
|
-
* @param deviceType -
|
|
35
|
-
* @
|
|
7
|
+
* @param deviceType - Current device type ('desktop' or 'mobile')
|
|
8
|
+
* @param defaultValue - Default value if setting not found
|
|
9
|
+
* @returns The setting value from the appropriate scope
|
|
36
10
|
*/
|
|
37
|
-
export declare const
|
|
38
|
-
contentWidth: any;
|
|
39
|
-
navigationMode: any;
|
|
40
|
-
sideMenuType: any;
|
|
41
|
-
fixedHeader: any;
|
|
42
|
-
fixedSidebar: any;
|
|
43
|
-
splitMenus: any;
|
|
44
|
-
upperMenuDividerName: any;
|
|
45
|
-
middleMenuDividerName: any;
|
|
46
|
-
lowerMenuDividerName: any;
|
|
47
|
-
};
|
|
11
|
+
export declare const getSettingValue: (machineSettings: any, settingName: string, applyToAllRoutes: boolean, currentRoute: string, deviceType: "desktop" | "mobile", defaultValue?: any) => any;
|
|
48
12
|
/**
|
|
49
|
-
*
|
|
13
|
+
* Calculate the default value for applyToAllRoutes based on what overrides exist
|
|
14
|
+
* @param settings - The full settings object with overrides
|
|
50
15
|
* @param currentRoute - Current route path
|
|
51
|
-
* @param deviceType -
|
|
52
|
-
* @
|
|
53
|
-
* @param fallbackDeviceSettings - Fallback device settings (unused, for backward compatibility)
|
|
54
|
-
* @param fallbackLayoutSettings - Fallback layout settings (unused, for backward compatibility)
|
|
55
|
-
* @returns Merged device and layout settings
|
|
56
|
-
*/
|
|
57
|
-
export declare const mergeSettingsWithUIOverrides: (currentRoute: string, deviceType: string, settings: any, fallbackDeviceSettings?: any, fallbackLayoutSettings?: any) => SettingsMergeResult;
|
|
58
|
-
/**
|
|
59
|
-
* @deprecated No longer using routeSettings structure. Use buildDeviceSettings/buildLayoutSettings instead.
|
|
60
|
-
*/
|
|
61
|
-
export declare const getRouteSettings: (currentRoute: string, settings: any) => any;
|
|
62
|
-
/**
|
|
63
|
-
* @deprecated No longer using regions structure. Use buildDeviceSettings instead.
|
|
64
|
-
*/
|
|
65
|
-
export declare const getDeviceSettingsFromRoute: (routeSettings: any, deviceType: string) => {};
|
|
66
|
-
/**
|
|
67
|
-
* @deprecated No longer using layout nested structure. Use buildLayoutSettings instead.
|
|
16
|
+
* @param deviceType - Current device type ('desktop' or 'mobile')
|
|
17
|
+
* @returns The default value for applyToAllRoutes
|
|
68
18
|
*/
|
|
69
|
-
export declare const
|
|
19
|
+
export declare const getDefaultApplyToAllRoutes: (settings: any, currentRoute: string, deviceType: "desktop" | "mobile") => boolean;
|
|
70
20
|
//# sourceMappingURL=settingsUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settingsUtils.d.ts","sourceRoot":"","sources":["../../src/utils/settingsUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"settingsUtils.d.ts","sourceRoot":"","sources":["../../src/utils/settingsUtils.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GACxB,iBAAiB,GAAG,EACpB,aAAa,MAAM,EACnB,kBAAkB,OAAO,EACzB,cAAc,MAAM,EACpB,YAAY,SAAS,GAAG,QAAQ,EAChC,eAAe,GAAG,QA2DrB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,GACnC,UAAU,GAAG,EACb,cAAc,MAAM,EACpB,YAAY,SAAS,GAAG,QAAQ,KACjC,OAuBF,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {getNestedValue}from'./configOverrides.js';/**
|
|
2
|
+
* Get a setting value based on applyToAllRoutes flag and current route/device context
|
|
3
|
+
* @param machineSettings - The settings object from XState machine (may have overrides applied)
|
|
4
|
+
* @param settingName - The setting key to retrieve (e.g., 'fixedHeader', 'organization.members.invitations')
|
|
5
|
+
* @param applyToAllRoutes - Whether to use global or route-specific overrides
|
|
6
|
+
* @param currentRoute - Current route path
|
|
7
|
+
* @param deviceType - Current device type ('desktop' or 'mobile')
|
|
8
|
+
* @param defaultValue - Default value if setting not found
|
|
9
|
+
* @returns The setting value from the appropriate scope
|
|
10
|
+
*/
|
|
11
|
+
const getSettingValue = (machineSettings, settingName, applyToAllRoutes, currentRoute, deviceType, defaultValue) => {
|
|
12
|
+
const overrides = machineSettings?.uiSettings?.overrides || {};
|
|
13
|
+
// Get clean base settings by removing any applied overrides
|
|
14
|
+
const getCleanBaseSettings = () => {
|
|
15
|
+
const cleanSettings = {
|
|
16
|
+
...machineSettings
|
|
17
|
+
};
|
|
18
|
+
// Remove any overrides that might have been applied to the top level
|
|
19
|
+
if (overrides) {
|
|
20
|
+
// Remove global device overrides
|
|
21
|
+
const deviceKey = `[${deviceType}]`;
|
|
22
|
+
const deviceOverride = overrides[deviceKey];
|
|
23
|
+
if (deviceOverride?.uilayout) {
|
|
24
|
+
Object.keys(deviceOverride.uilayout).forEach(key => {
|
|
25
|
+
delete cleanSettings[key];
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
// Remove route-specific overrides
|
|
29
|
+
const routeDeviceKey = `[${currentRoute}][${deviceType}]`;
|
|
30
|
+
const routeOverride = overrides[routeDeviceKey];
|
|
31
|
+
if (routeOverride?.uilayout) {
|
|
32
|
+
Object.keys(routeOverride.uilayout).forEach(key => {
|
|
33
|
+
delete cleanSettings[key];
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return cleanSettings;
|
|
38
|
+
};
|
|
39
|
+
if (applyToAllRoutes) {
|
|
40
|
+
// Global mode: look for [device].uilayout.settingName ONLY
|
|
41
|
+
const deviceKey = `[${deviceType}]`;
|
|
42
|
+
const deviceOverride = overrides[deviceKey];
|
|
43
|
+
if (deviceOverride?.uilayout) {
|
|
44
|
+
const value = getNestedValue(deviceOverride.uilayout, settingName);
|
|
45
|
+
if (value !== undefined) {
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// If no global override, fall back to clean base setting
|
|
50
|
+
const cleanSettings = getCleanBaseSettings();
|
|
51
|
+
return getNestedValue(cleanSettings, settingName) ?? defaultValue;
|
|
52
|
+
} else {
|
|
53
|
+
// Route-specific mode: look for [route][device].uilayout.settingName ONLY
|
|
54
|
+
const contextKey = `[${currentRoute}][${deviceType}]`;
|
|
55
|
+
const routeOverride = overrides[contextKey];
|
|
56
|
+
if (routeOverride?.uilayout) {
|
|
57
|
+
const value = getNestedValue(routeOverride.uilayout, settingName);
|
|
58
|
+
if (value !== undefined) {
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// If no route-specific override, fall back to clean base setting
|
|
63
|
+
const cleanSettings = getCleanBaseSettings();
|
|
64
|
+
return getNestedValue(cleanSettings, settingName) ?? defaultValue;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Calculate the default value for applyToAllRoutes based on what overrides exist
|
|
69
|
+
* @param settings - The full settings object with overrides
|
|
70
|
+
* @param currentRoute - Current route path
|
|
71
|
+
* @param deviceType - Current device type ('desktop' or 'mobile')
|
|
72
|
+
* @returns The default value for applyToAllRoutes
|
|
73
|
+
*/
|
|
74
|
+
const getDefaultApplyToAllRoutes = (settings, currentRoute, deviceType) => {
|
|
75
|
+
const overrides = settings?.uiSettings?.overrides || {};
|
|
76
|
+
const routeDeviceKey = `[${currentRoute}][${deviceType}]`;
|
|
77
|
+
const deviceKey = `[${deviceType}]`;
|
|
78
|
+
// Check if route-specific override exists
|
|
79
|
+
const hasRouteOverride = !!overrides[routeDeviceKey];
|
|
80
|
+
// Check if global override exists
|
|
81
|
+
const hasGlobalOverride = !!overrides[deviceKey];
|
|
82
|
+
// If route has its own override, use route-specific (applyToAllRoutes = false)
|
|
83
|
+
if (hasRouteOverride) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
// If no route override but global override exists, use global (applyToAllRoutes = true)
|
|
87
|
+
if (hasGlobalOverride) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
// No route or global override, default to route-specific (applyToAllRoutes = false)
|
|
91
|
+
return false;
|
|
92
|
+
};export{getDefaultApplyToAllRoutes,getSettingValue};//# sourceMappingURL=settingsUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settingsUtils.js","sources":["../../src/utils/settingsUtils.ts"],"sourcesContent":[null],"names":[],"mappings":"kDAEA;;;;;;;;;AASG;AACI,MAAM,eAAe,GAAG,CAC3B,eAAoB,EACpB,WAAmB,EACnB,gBAAyB,EACzB,YAAoB,EACpB,UAAgC,EAChC,YAAkB,KAClB;QACA,SAAM,kBAAY,EAAe,YAAY,SAAE,IAAS,EAAI;;QAG5D,oBAAM,GAAoB,MAAM;AAC5B,IAAA,MAAA;SAEA;;;AAGI,IAAA,IAAA,SAAA,EAAM;AACN;AACA,MAAA,MAAA,SAAI,GAAA,CAAA,CAAA,EAAA,UAAgB,CAAA,CAAQ,CAAA;AACxB,MAAA,MAAA,cAAO,GAAK,SAAA,CAAA,SAAe,CAAA;AACvB,MAAA,IAAA,cAAA,EAAA,QAAO,EAAA;AACX,QAAA,MAAA,CAAA,IAAG,CAAA,cAAA,CAAA,QAAA,CAAA,CAAA,OAAA,CAAA,GAAA,IAAA;iBACN,aAAA,CAAA,GAAA,CAAA;;AAGD,MAAA;AACA;AACA,MAAA,MAAA,cAAI,GAAa,CAAA,CAAE,EAAA,YAAW,CAAA,EAAA,EAAA,UAAA,CAAA,CAAA,CAAA;AAC1B,MAAA,MAAA,aAAO,GAAK,SAAA,CAAA,cAAwB,CAAA;AAChC,MAAA,IAAA,aAAA,EAAA,QAAO,EAAA;AACX,QAAA,MAAA,CAAA,IAAG,CAAA,aAAA,CAAA,QAAA,CAAA,CAAA,OAAA,CAAA,GAAA,IAAA;iBACN,aAAA,CAAA,GAAA,CAAA;QACL,CAAC,CAAA;AAED,MAAA;AACJ,IAAA;IAEA,OAAI,aAAgB;;AAEhB,EAAA,IAAA,gBAAM,EAAS;AACf;AACA,IAAA,MAAA,SAAI,GAAA,CAAA,CAAA,EAAc,UAAU,CAAA,CAAE,CAAC;wBAChB,GAAG,SAAA,CAAA,SAAe,CAAA;AAC7B,IAAA,IAAA,cAAS,EAAA,QAAK,EAAA;AACV,MAAA,MAAA,KAAA,GAAA,cAAa,CAAA,cAAA,CAAA,QAAA,EAAA,WAAA,CAAA;eAChB,KAAA,SAAA,EAAA;QACL,OAAC,KAAA;;AAED,IAAA;;IAEJ,MAAC,aAAA,GAAA,oBAAA,EAAA;WAAO,cAAA,CAAA,aAAA,EAAA,WAAA,CAAA,IAAA,YAAA;SACJ;AACA;AACA,IAAA,MAAA,iBAAmB,YAAY,CAAC,EAAA,EAAA,UAAY,CAAA,CAAA,CAAA;AAC5C,IAAA,MAAA,aAAI,GAAa,SAAU,CAAA,UAAG,CAAA;qBACpB,EAAK,QAAG,EAAA;AACd,MAAA,MAAA,KAAI,GAAA,cAAU,CAAS,aAAG,CAAA,QAAA,EAAA,WAAA,CAAA;AACtB,MAAA,IAAA,KAAA,KAAA,SAAa,EAAA;eAChB,KAAA;;;AAGL;UACA,aAAO,GAAA;IACX,OAAC,cAAA,CAAA,aAAA,EAAA,WAAA,CAAA,IAAA,YAAA;AACL,EAAE;AAEF;;;;;;AAMG;AACH;AAKU,MAAA,6BAAgC,CAAA,QAAE,EAAS,YAAO,EAAA,UAAA,KAAA;AACxD,EAAA,MAAA,oBAAuB,EAAA,qBAAqB,IAAA,EAAA;AAC5C,EAAA,MAAA,cAAkB,GAAA,CAAI,CAAA,EAAA,YAAc,CAAA,EAAA,EAAA,UAAA,CAAA,CAAA,CAAA;QAEpC,SAAA,GAAA,CAAA,CAAA,EAAA,UAAA,CAAA,CAAA,CAAA;;QAGA,gBAAA,GAAA,CAAA,CAAA,SAAkC,CAAA,cAAA,CAAA;;QAGlC,iBAAA,GAAA,CAAA,CAAA,SAAA,CAAA,SAAA,CAAA;;AAEI,EAAA,IAAA,gBAAa,EAAA;IACjB,OAAC,KAAA;;;AAIG,EAAA,IAAA,iBAAY,EAAA;IAChB,OAAC,IAAA;;AAGD;AACJ,EAAE,OAAA,KAAA;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@admin-layout/tailwind-design-pro",
|
|
3
|
-
"version": "12.0.16-alpha.
|
|
3
|
+
"version": "12.0.16-alpha.53",
|
|
4
4
|
"description": "Sample core for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@admin-layout/assets": "12.0.16-alpha.36",
|
|
25
|
-
"@admin-layout/client": "12.0.16-alpha.
|
|
26
|
-
"@admin-layout/tailwind-ui": "12.0.16-alpha.
|
|
25
|
+
"@admin-layout/client": "12.0.16-alpha.53",
|
|
26
|
+
"@admin-layout/tailwind-ui": "12.0.16-alpha.53",
|
|
27
27
|
"react-favicon": "^0.0.23",
|
|
28
28
|
"react-intl": "^6.1.1",
|
|
29
29
|
"react-responsive": "^10.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@adminide-stack/extension-api": "^12.0.4-alpha.
|
|
32
|
+
"@adminide-stack/extension-api": "^12.0.4-alpha.298",
|
|
33
33
|
"@tailwindcss/aspect-ratio": "^0.4.2",
|
|
34
34
|
"@tailwindcss/forms": "^0.5.4",
|
|
35
35
|
"@tailwindcss/typography": "^0.5.9",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"typescript": {
|
|
54
54
|
"definition": "lib/index.d.ts"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "16b623c76ef2f6fed4252f49e473f32b19983d1f"
|
|
57
57
|
}
|