@blerp/design 1.3.17 → 1.4.1

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 (128) hide show
  1. package/dist/cjs/Blerp/BlerpImageRow.js +176 -57
  2. package/dist/cjs/Blerp/BlerpSavePopup.js +44 -40
  3. package/dist/cjs/Blerp/BlerpTitleRow.js +36 -19
  4. package/dist/cjs/Blerp/BlerpTopRow.js +110 -44
  5. package/dist/cjs/Blerp.js +9 -16
  6. package/dist/cjs/BlerpAudioContextProvider.js +2 -2
  7. package/dist/cjs/BlerpListView.js +318 -168
  8. package/dist/cjs/BlerpListViewPremium.js +155 -130
  9. package/dist/cjs/BlerpListViewSkeleton.js +60 -13
  10. package/dist/cjs/BlerpSkeleton.js +32 -9
  11. package/dist/cjs/CollectionCard.js +139 -60
  12. package/dist/cjs/CollectionListViewPremium.js +368 -297
  13. package/dist/cjs/CollectionSkeleton.js +74 -13
  14. package/dist/cjs/Dropdown.js +272 -172
  15. package/dist/cjs/EllipsisLoader.js +66 -21
  16. package/dist/cjs/GroupCard.js +64 -57
  17. package/dist/cjs/Icons/Icons.js +288 -426
  18. package/dist/cjs/ImageEditor.js +247 -0
  19. package/dist/cjs/ImageUpload.js +226 -0
  20. package/dist/cjs/NewBlerp.js +354 -160
  21. package/dist/cjs/NewBlerpTest.js +10 -792
  22. package/dist/cjs/NewCollectionModal.js +294 -310
  23. package/dist/cjs/PremiumCollectionCard.js +191 -454
  24. package/dist/cjs/PurchaseModals/CheckoutModal.js +1 -1
  25. package/dist/cjs/PurchaseModals/PremiumBlerpCheckoutModal.js +1 -1
  26. package/dist/cjs/PurchaseModals/PremiumCollectionCheckoutModal.js +1 -1
  27. package/dist/cjs/PurchaseModals/PremiumSubscriptionCheckoutModal.js +1 -1
  28. package/dist/cjs/ReactionButtons.js +26 -13
  29. package/dist/cjs/SnackbarContextProvider.js +200 -116
  30. package/dist/cjs/Theme.js +217 -90
  31. package/dist/cjs/Toggle.js +86 -32
  32. package/dist/cjs/UserCard.js +13 -32
  33. package/dist/cjs/UserPage/LibraryControls.js +180 -93
  34. package/dist/cjs/UserPage/UserLibraryHeader.js +23 -14
  35. package/dist/cjs/UserPage/UserProfileHeader.js +120 -105
  36. package/dist/cjs/UsernameWithPopout.js +12 -8
  37. package/dist/cjs/colors.js +15 -8
  38. package/dist/cjs/helpers.js +131 -0
  39. package/dist/cjs/index.js +92 -58
  40. package/dist/cjs/neo-components/Autocomplete.js +280 -0
  41. package/dist/cjs/neo-components/BottomNavigation.js +120 -0
  42. package/dist/cjs/neo-components/Box.js +48 -0
  43. package/dist/cjs/neo-components/Button.js +206 -0
  44. package/dist/cjs/neo-components/CircularProgress.js +92 -0
  45. package/dist/cjs/neo-components/Container.js +75 -0
  46. package/dist/cjs/neo-components/Dialog.js +441 -0
  47. package/dist/cjs/neo-components/Fab.js +237 -0
  48. package/dist/cjs/neo-components/FormControls.js +1057 -0
  49. package/dist/cjs/neo-components/Grid.js +256 -0
  50. package/dist/cjs/neo-components/IconButton.js +111 -0
  51. package/dist/cjs/neo-components/Input.js +493 -0
  52. package/dist/cjs/neo-components/Layout.js +1213 -0
  53. package/dist/cjs/neo-components/Misc.js +858 -0
  54. package/dist/cjs/neo-components/Navigation.js +1578 -0
  55. package/dist/cjs/neo-components/Paper.js +256 -0
  56. package/dist/cjs/neo-components/Stack.js +194 -0
  57. package/dist/cjs/neo-components/Stepper.js +291 -0
  58. package/dist/cjs/neo-components/Text.js +290 -0
  59. package/dist/cjs/neo-components/ThemeProvider.js +731 -0
  60. package/dist/cjs/neo-components/ToggleButton.js +223 -0
  61. package/dist/cjs/neo-components/createTheme.js +306 -0
  62. package/dist/cjs/neo-components/withSx.js +164 -0
  63. package/dist/cjs/neo-utils/sxToStyle.js +508 -0
  64. package/dist/esm/Blerp/BlerpImageRow.js +166 -46
  65. package/dist/esm/Blerp/BlerpSavePopup.js +35 -27
  66. package/dist/esm/Blerp/BlerpTitleRow.js +32 -13
  67. package/dist/esm/Blerp/BlerpTopRow.js +85 -16
  68. package/dist/esm/Blerp.js +4 -12
  69. package/dist/esm/BlerpAudioContextProvider.js +1 -2
  70. package/dist/esm/BlerpListView.js +313 -160
  71. package/dist/esm/BlerpListViewPremium.js +135 -109
  72. package/dist/esm/BlerpListViewSkeleton.js +60 -11
  73. package/dist/esm/BlerpSkeleton.js +32 -7
  74. package/dist/esm/CollectionCard.js +118 -38
  75. package/dist/esm/CollectionListViewPremium.js +367 -294
  76. package/dist/esm/CollectionSkeleton.js +73 -11
  77. package/dist/esm/Dropdown.js +260 -161
  78. package/dist/esm/EllipsisLoader.js +63 -18
  79. package/dist/esm/GroupCard.js +54 -46
  80. package/dist/esm/Icons/Icons.js +226 -367
  81. package/dist/esm/ImageEditor.js +240 -0
  82. package/dist/esm/ImageUpload.js +217 -0
  83. package/dist/esm/NewBlerp.js +282 -79
  84. package/dist/esm/NewBlerpTest.js +11 -781
  85. package/dist/esm/NewCollectionModal.js +289 -304
  86. package/dist/esm/PremiumCollectionCard.js +192 -451
  87. package/dist/esm/PurchaseModals/CheckoutModal.js +1 -1
  88. package/dist/esm/PurchaseModals/PremiumBlerpCheckoutModal.js +1 -1
  89. package/dist/esm/PurchaseModals/PremiumCollectionCheckoutModal.js +1 -1
  90. package/dist/esm/PurchaseModals/PremiumSubscriptionCheckoutModal.js +1 -1
  91. package/dist/esm/ReactionButtons.js +23 -8
  92. package/dist/esm/SnackbarContextProvider.js +196 -110
  93. package/dist/esm/Theme.js +187 -66
  94. package/dist/esm/Toggle.js +84 -29
  95. package/dist/esm/UserCard.js +1 -20
  96. package/dist/esm/UserPage/LibraryControls.js +159 -65
  97. package/dist/esm/UserPage/UserLibraryHeader.js +18 -10
  98. package/dist/esm/UserPage/UserProfileHeader.js +100 -79
  99. package/dist/esm/UsernameWithPopout.js +7 -4
  100. package/dist/esm/colors.js +11 -9
  101. package/dist/esm/helpers.js +122 -0
  102. package/dist/esm/icons.js +1 -1
  103. package/dist/esm/index.js +32 -2
  104. package/dist/esm/neo-components/Autocomplete.js +269 -0
  105. package/dist/esm/neo-components/BottomNavigation.js +109 -0
  106. package/dist/esm/neo-components/Box.js +36 -0
  107. package/dist/esm/neo-components/Button.js +194 -0
  108. package/dist/esm/neo-components/CircularProgress.js +81 -0
  109. package/dist/esm/neo-components/Container.js +63 -0
  110. package/dist/esm/neo-components/Dialog.js +423 -0
  111. package/dist/esm/neo-components/Fab.js +225 -0
  112. package/dist/esm/neo-components/FormControls.js +1041 -0
  113. package/dist/esm/neo-components/Grid.js +244 -0
  114. package/dist/esm/neo-components/IconButton.js +99 -0
  115. package/dist/esm/neo-components/Input.js +478 -0
  116. package/dist/esm/neo-components/Layout.js +1179 -0
  117. package/dist/esm/neo-components/Misc.js +840 -0
  118. package/dist/esm/neo-components/Navigation.js +1556 -0
  119. package/dist/esm/neo-components/Paper.js +243 -0
  120. package/dist/esm/neo-components/Stack.js +182 -0
  121. package/dist/esm/neo-components/Stepper.js +278 -0
  122. package/dist/esm/neo-components/Text.js +277 -0
  123. package/dist/esm/neo-components/ThemeProvider.js +718 -0
  124. package/dist/esm/neo-components/ToggleButton.js +214 -0
  125. package/dist/esm/neo-components/createTheme.js +297 -0
  126. package/dist/esm/neo-components/withSx.js +153 -0
  127. package/dist/esm/neo-utils/sxToStyle.js +502 -0
  128. package/package.json +19 -15
@@ -0,0 +1,508 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ require('@babel/runtime/helpers/defineProperty');
6
+
7
+ /**
8
+ * Converts MUI sx prop to inline styles
9
+ * Handles spacing shortcuts, theme colors, pseudo-selectors, nested selectors, and responsive values
10
+ */
11
+ // Spacing multiplier (MUI default is 8px)
12
+ const SPACING_UNIT = 8; // Map of sx shorthand props to CSS properties
13
+
14
+ const PROP_MAP = {
15
+ // Margin
16
+ m: 'margin',
17
+ mt: 'marginTop',
18
+ mb: 'marginBottom',
19
+ ml: 'marginLeft',
20
+ mr: 'marginRight',
21
+ mx: ['marginLeft', 'marginRight'],
22
+ my: ['marginTop', 'marginBottom'],
23
+ // Padding
24
+ p: 'padding',
25
+ pt: 'paddingTop',
26
+ pb: 'paddingBottom',
27
+ pl: 'paddingLeft',
28
+ pr: 'paddingRight',
29
+ px: ['paddingLeft', 'paddingRight'],
30
+ py: ['paddingTop', 'paddingBottom'],
31
+ // Sizing
32
+ w: 'width',
33
+ h: 'height',
34
+ minW: 'minWidth',
35
+ maxW: 'maxWidth',
36
+ minH: 'minHeight',
37
+ maxH: 'maxHeight',
38
+ // Flexbox
39
+ flexGrow: 'flexGrow',
40
+ flexShrink: 'flexShrink',
41
+ flexBasis: 'flexBasis',
42
+ justifyContent: 'justifyContent',
43
+ alignItems: 'alignItems',
44
+ alignSelf: 'alignSelf',
45
+ // Display
46
+ display: 'display',
47
+ overflow: 'overflow',
48
+ overflowX: 'overflowX',
49
+ overflowY: 'overflowY',
50
+ // Position
51
+ position: 'position',
52
+ top: 'top',
53
+ right: 'right',
54
+ bottom: 'bottom',
55
+ left: 'left',
56
+ zIndex: 'zIndex',
57
+ // Border
58
+ border: 'border',
59
+ borderTop: 'borderTop',
60
+ borderRight: 'borderRight',
61
+ borderBottom: 'borderBottom',
62
+ borderLeft: 'borderLeft',
63
+ borderColor: 'borderColor',
64
+ borderRadius: 'borderRadius',
65
+ borderWidth: 'borderWidth',
66
+ borderStyle: 'borderStyle',
67
+ // Background
68
+ bgcolor: 'backgroundColor',
69
+ backgroundColor: 'backgroundColor',
70
+ background: 'background',
71
+ backgroundImage: 'backgroundImage',
72
+ backgroundSize: 'backgroundSize',
73
+ backgroundPosition: 'backgroundPosition',
74
+ // Typography
75
+ fontFamily: 'fontFamily',
76
+ fontSize: 'fontSize',
77
+ fontStyle: 'fontStyle',
78
+ fontWeight: 'fontWeight',
79
+ letterSpacing: 'letterSpacing',
80
+ lineHeight: 'lineHeight',
81
+ textAlign: 'textAlign',
82
+ textDecoration: 'textDecoration',
83
+ textTransform: 'textTransform',
84
+ // Color
85
+ color: 'color',
86
+ // Shadow
87
+ boxShadow: 'boxShadow',
88
+ // Other
89
+ opacity: 'opacity',
90
+ cursor: 'cursor',
91
+ transition: 'transition',
92
+ transform: 'transform',
93
+ visibility: 'visibility',
94
+ whiteSpace: 'whiteSpace',
95
+ wordBreak: 'wordBreak',
96
+ boxSizing: 'boxSizing',
97
+ gap: 'gap',
98
+ rowGap: 'rowGap',
99
+ columnGap: 'columnGap',
100
+ gridTemplateColumns: 'gridTemplateColumns',
101
+ gridTemplateRows: 'gridTemplateRows',
102
+ gridColumn: 'gridColumn',
103
+ gridRow: 'gridRow',
104
+ flex: 'flex',
105
+ flexDirection: 'flexDirection',
106
+ flexWrap: 'flexWrap',
107
+ order: 'order',
108
+ // Additional MUI props
109
+ width: 'width',
110
+ height: 'height',
111
+ minWidth: 'minWidth',
112
+ maxWidth: 'maxWidth',
113
+ minHeight: 'minHeight',
114
+ maxHeight: 'maxHeight',
115
+ // Margin/padding with specific values
116
+ margin: 'margin',
117
+ padding: 'padding'
118
+ }; // Props that should resolve theme colors
119
+
120
+ const COLOR_PROPS = new Set(['color', 'backgroundColor', 'bgcolor', 'borderColor', 'background', 'borderTopColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'outlineColor', 'fill', 'stroke']);
121
+ /**
122
+ * Convert spacing value to pixels
123
+ * Numbers are multiplied by spacing unit, strings pass through
124
+ */
125
+
126
+ function parseSpacing(value) {
127
+ if (typeof value === 'number') {
128
+ return "".concat(value * SPACING_UNIT, "px");
129
+ }
130
+
131
+ return value;
132
+ }
133
+ /**
134
+ * Check if a value looks like a theme color reference
135
+ * e.g., "primary.main", "ibisRed.main", "grey6.main"
136
+ */
137
+
138
+
139
+ function isThemeColorRef(value) {
140
+ if (typeof value !== 'string') return false; // Must have a dot, not be a URL, not have common CSS patterns
141
+
142
+ if (!value.includes('.')) return false;
143
+ if (value.startsWith('http') || value.startsWith('url(')) return false;
144
+ if (value.includes('px') || value.includes('%') || value.includes('rem')) return false;
145
+ if (value.startsWith('#') || value.startsWith('rgb') || value.startsWith('hsl')) return false;
146
+ return true;
147
+ }
148
+ /**
149
+ * Resolve a theme color reference to an actual color value
150
+ * Handles: "ibisRed.main" -> "#FE295C"
151
+ * "notBlack.main" -> "#21000C"
152
+ * "grey6.main" -> looks up grey6 in colors
153
+ */
154
+
155
+
156
+ function resolveThemeColor(value) {
157
+ let themeColors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
158
+ if (!isThemeColorRef(value)) return value;
159
+ const parts = value.split('.');
160
+ let result = themeColors;
161
+
162
+ for (const part of parts) {
163
+ if (result && typeof result === 'object' && part in result) {
164
+ result = result[part];
165
+ } else {
166
+ // Color not found - return original value or a CSS variable fallback
167
+ const varName = "--".concat(value.replace(/\./g, '-').replace(/([A-Z])/g, '-$1').toLowerCase());
168
+ return "var(".concat(varName, ", ").concat(value, ")");
169
+ }
170
+ } // If we got a string, return it; if still an object, try .main
171
+
172
+
173
+ if (typeof result === 'string') {
174
+ return result;
175
+ } else if (result && typeof result === 'object' && 'main' in result) {
176
+ return result.main;
177
+ }
178
+
179
+ return value;
180
+ }
181
+ /**
182
+ * Check if a key is a nested CSS selector (class, element, or complex selector)
183
+ * Examples: ".braintree-method", "& > div", "& .child", ".foo .bar"
184
+ */
185
+
186
+
187
+ function isNestedSelector(key) {
188
+ // Starts with a dot (class selector)
189
+ if (key.startsWith('.')) return true; // Starts with & (parent reference)
190
+
191
+ if (key.startsWith('&')) return true; // Contains spaces (complex selector)
192
+
193
+ if (key.includes(' ')) return true; // Element selectors (common ones)
194
+
195
+ const elementSelectors = ['div', 'span', 'p', 'a', 'button', 'input', 'img', 'svg', 'path'];
196
+ if (elementSelectors.includes(key)) return true;
197
+ return false;
198
+ }
199
+ /**
200
+ * Check if a key is a pseudo-selector
201
+ * Examples: "&:hover", "&:disabled", "&[disabled]", "&::before"
202
+ */
203
+
204
+
205
+ function isPseudoSelector(key) {
206
+ if (!key.startsWith('&')) return false; // Must have : or [ after the &
207
+
208
+ const afterAmpersand = key.slice(1).trim();
209
+ return afterAmpersand.startsWith(':') || afterAmpersand.startsWith('[');
210
+ }
211
+ /**
212
+ * Check if a key is a media query
213
+ */
214
+
215
+
216
+ function isMediaQuery(key) {
217
+ return key.startsWith('@media');
218
+ }
219
+ /**
220
+ * Extract different types of styles from sx object
221
+ */
222
+
223
+
224
+ function extractSpecialSelectors(sx) {
225
+ const styles = {}; // Regular inline styles
226
+
227
+ const pseudos = {}; // Pseudo-selectors like &:hover
228
+
229
+ const nested = {}; // Nested selectors like .braintree-method
230
+
231
+ const mediaQueries = {}; // Media queries
232
+
233
+ for (const [key, value] of Object.entries(sx)) {
234
+ if (value === null || value === undefined) {
235
+ continue;
236
+ }
237
+
238
+ if (isMediaQuery(key)) {
239
+ mediaQueries[key] = value;
240
+ } else if (isPseudoSelector(key)) {
241
+ pseudos[key] = value;
242
+ } else if (isNestedSelector(key)) {
243
+ nested[key] = value;
244
+ } else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
245
+ // Could be responsive values { xs: ..., sm: ..., md: ... }
246
+ const isResponsive = Object.keys(value).some(k => ['xs', 'sm', 'md', 'lg', 'xl'].includes(k));
247
+
248
+ if (isResponsive) {
249
+ // For now, just use the first value or 'xs'
250
+ styles[key] = value.xs || value.sm || value.md || Object.values(value)[0];
251
+ } else {
252
+ // Unknown object structure - skip for inline styles
253
+ // This might be a nested selector without & prefix
254
+ nested[key] = value;
255
+ }
256
+ } else {
257
+ styles[key] = value;
258
+ }
259
+ }
260
+
261
+ return {
262
+ styles,
263
+ pseudos,
264
+ nested,
265
+ mediaQueries
266
+ };
267
+ }
268
+ /**
269
+ * Convert a single sx value to a style value
270
+ */
271
+
272
+
273
+ function convertValue(key, value, themeColors) {
274
+ // Handle null/undefined
275
+ if (value === null || value === undefined) return value; // Handle theme colors for color-related props
276
+
277
+ if (COLOR_PROPS.has(key) || COLOR_PROPS.has(PROP_MAP[key])) {
278
+ return resolveThemeColor(value, themeColors);
279
+ } // Handle spacing props
280
+
281
+
282
+ const spacingProps = ['m', 'mt', 'mb', 'ml', 'mr', 'mx', 'my', 'p', 'pt', 'pb', 'pl', 'pr', 'px', 'py', 'gap', 'rowGap', 'columnGap'];
283
+
284
+ if (spacingProps.includes(key)) {
285
+ return parseSpacing(value);
286
+ } // Handle borderRadius with theme spacing
287
+
288
+
289
+ if (key === 'borderRadius' && typeof value === 'number') {
290
+ return "".concat(value * 4, "px"); // MUI uses 4px for border radius units
291
+ }
292
+
293
+ return value;
294
+ }
295
+ /**
296
+ * Convert an sx styles object to a flat CSS properties object
297
+ */
298
+
299
+
300
+ function convertStylesToCSS(styles, themeColors) {
301
+ const result = {};
302
+
303
+ for (const [key, value] of Object.entries(styles)) {
304
+ if (typeof value === 'object' && value !== null) {
305
+ continue; // Skip nested objects
306
+ }
307
+
308
+ const cssProps = PROP_MAP[key] || key;
309
+ const convertedValue = convertValue(key, value, themeColors);
310
+ if (convertedValue === null || convertedValue === undefined) continue;
311
+
312
+ if (Array.isArray(cssProps)) {
313
+ cssProps.forEach(prop => {
314
+ result[prop] = convertedValue;
315
+ });
316
+ } else {
317
+ result[cssProps] = convertedValue;
318
+ }
319
+ }
320
+
321
+ return result;
322
+ }
323
+ /**
324
+ * Main function: Convert sx prop to inline style object
325
+ * @param {Object} sx - MUI sx prop object
326
+ * @param {Object} themeColors - Theme color mappings from ThemeProvider
327
+ * @returns {Object} - { style: {...}, pseudoStyles: {...}, nestedStyles: {...}, pseudoClassName: string }
328
+ */
329
+
330
+
331
+ function sxToStyle(sx) {
332
+ let themeColors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
333
+
334
+ if (!sx || typeof sx !== 'object') {
335
+ return {
336
+ style: {},
337
+ pseudoStyles: {},
338
+ nestedStyles: {},
339
+ mediaQueries: {},
340
+ pseudoClassName: ''
341
+ };
342
+ } // Handle array of sx objects (MUI supports this)
343
+
344
+
345
+ if (Array.isArray(sx)) {
346
+ const merged = sx.reduce((acc, sxObj) => {
347
+ if (sxObj) {
348
+ Object.assign(acc, sxObj);
349
+ }
350
+
351
+ return acc;
352
+ }, {});
353
+ return sxToStyle(merged, themeColors);
354
+ }
355
+
356
+ const {
357
+ styles,
358
+ pseudos,
359
+ nested,
360
+ mediaQueries
361
+ } = extractSpecialSelectors(sx); // Convert main styles
362
+
363
+ const result = convertStylesToCSS(styles, themeColors); // Process pseudo-selectors
364
+
365
+ const processedPseudos = {};
366
+
367
+ for (const [selector, pseudoSx] of Object.entries(pseudos)) {
368
+ if (typeof pseudoSx === 'object') {
369
+ processedPseudos[selector] = convertStylesToCSS(pseudoSx, themeColors);
370
+ }
371
+ } // Process nested selectors
372
+
373
+
374
+ const processedNested = {};
375
+
376
+ for (const [selector, nestedSx] of Object.entries(nested)) {
377
+ if (typeof nestedSx === 'object') {
378
+ // Recursively process nested styles (they might have their own pseudos/nested)
379
+ const {
380
+ styles: nestedStyles,
381
+ pseudos: nestedPseudos
382
+ } = extractSpecialSelectors(nestedSx);
383
+ processedNested[selector] = {
384
+ styles: convertStylesToCSS(nestedStyles, themeColors),
385
+ pseudos: {}
386
+ }; // Process any pseudo-selectors within the nested selector
387
+
388
+ for (const [pSelector, pSx] of Object.entries(nestedPseudos)) {
389
+ if (typeof pSx === 'object') {
390
+ processedNested[selector].pseudos[pSelector] = convertStylesToCSS(pSx, themeColors);
391
+ }
392
+ }
393
+ }
394
+ } // Process media queries
395
+
396
+
397
+ const processedMediaQueries = {};
398
+
399
+ for (const [query, querySx] of Object.entries(mediaQueries)) {
400
+ if (typeof querySx === 'object') {
401
+ processedMediaQueries[query] = convertStylesToCSS(querySx, themeColors);
402
+ }
403
+ }
404
+
405
+ const hasSpecialStyles = Object.keys(processedPseudos).length > 0 || Object.keys(processedNested).length > 0 || Object.keys(processedMediaQueries).length > 0;
406
+ return {
407
+ style: result,
408
+ pseudoStyles: processedPseudos,
409
+ nestedStyles: processedNested,
410
+ mediaQueries: processedMediaQueries,
411
+ pseudoClassName: hasSpecialStyles ? "blerp-sx-".concat(Math.random().toString(36).substr(2, 9)) : ''
412
+ };
413
+ }
414
+ /**
415
+ * Convert camelCase to kebab-case
416
+ */
417
+
418
+ function toKebabCase(str) {
419
+ return str.replace(/([A-Z])/g, '-$1').toLowerCase();
420
+ }
421
+ /**
422
+ * Convert a styles object to CSS declarations string
423
+ */
424
+
425
+
426
+ function stylesToDeclarations(styles) {
427
+ return Object.entries(styles).filter(_ref => {
428
+ let [, val] = _ref;
429
+ return val !== null && val !== undefined && val !== '';
430
+ }).map(_ref2 => {
431
+ let [prop, val] = _ref2;
432
+ return "".concat(toKebabCase(prop), ": ").concat(val);
433
+ }).join('; ');
434
+ }
435
+ /**
436
+ * Generate CSS string from all special styles (pseudos, nested, media queries)
437
+ */
438
+
439
+
440
+ function generatePseudoCSS(className, pseudoStyles) {
441
+ let nestedStyles = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
442
+ let mediaQueries = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
443
+
444
+ if (!className) {
445
+ return '';
446
+ }
447
+
448
+ let css = ''; // Generate pseudo-selector CSS
449
+
450
+ for (const [selector, styles] of Object.entries(pseudoStyles || {})) {
451
+ const cssSelector = selector.replace('&', ".".concat(className));
452
+ const declarations = stylesToDeclarations(styles);
453
+
454
+ if (declarations) {
455
+ css += "".concat(cssSelector, " { ").concat(declarations, " }\n");
456
+ }
457
+ } // Generate nested selector CSS
458
+
459
+
460
+ for (const [selector, data] of Object.entries(nestedStyles || {})) {
461
+ // Handle different selector formats
462
+ let cssSelector;
463
+
464
+ if (selector.startsWith('&')) {
465
+ // & .child or & > div
466
+ cssSelector = selector.replace('&', ".".concat(className));
467
+ } else if (selector.startsWith('.')) {
468
+ // .braintree-method - scope it under our class
469
+ cssSelector = ".".concat(className, " ").concat(selector);
470
+ } else {
471
+ // element selector like "div" or "span"
472
+ cssSelector = ".".concat(className, " ").concat(selector);
473
+ }
474
+
475
+ const declarations = stylesToDeclarations(data.styles || data);
476
+
477
+ if (declarations) {
478
+ css += "".concat(cssSelector, " { ").concat(declarations, " }\n");
479
+ } // Handle pseudo-selectors within nested selectors
480
+
481
+
482
+ if (data.pseudos) {
483
+ for (const [pSelector, pStyles] of Object.entries(data.pseudos)) {
484
+ const pCssSelector = "".concat(cssSelector).concat(pSelector.replace('&', ''));
485
+ const pDeclarations = stylesToDeclarations(pStyles);
486
+
487
+ if (pDeclarations) {
488
+ css += "".concat(pCssSelector, " { ").concat(pDeclarations, " }\n");
489
+ }
490
+ }
491
+ }
492
+ } // Generate media query CSS
493
+
494
+
495
+ for (const [query, styles] of Object.entries(mediaQueries || {})) {
496
+ const declarations = stylesToDeclarations(styles);
497
+
498
+ if (declarations) {
499
+ css += "".concat(query, " { .").concat(className, " { ").concat(declarations, " } }\n");
500
+ }
501
+ }
502
+
503
+ return css;
504
+ }
505
+
506
+ exports["default"] = sxToStyle;
507
+ exports.generatePseudoCSS = generatePseudoCSS;
508
+ exports.sxToStyle = sxToStyle;