@app-studio/web 0.9.79 → 0.9.80

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.
@@ -3279,11 +3279,23 @@
3279
3279
  getColorHex
3280
3280
  } = appStudio.useTheme();
3281
3281
  /* MAIN COLOR – determines the entire palette */
3282
- var mainColorKey = (_ref6 = backgroundColor != null ? backgroundColor : color) != null ? _ref6 : 'theme.primary';
3283
- var mainTone = getColorHex(isDisabled ? 'theme.disabled' : mainColorKey);
3282
+ // Priority: explicit backgroundColor/color prop -> theme.button.background -> theme.primary
3283
+ var mainColorKey = (_ref6 = backgroundColor != null ? backgroundColor : color) != null ? _ref6 : 'theme.button.background';
3284
+ // Decide which theme token to resolve based on state
3285
+ var stateColorKey = isDisabled ? 'theme.disabled' : isLoading ? 'theme.loading' : mainColorKey;
3286
+ // Resolve to actual hex color.
3287
+ // If 'theme.button.background' isn't defined, it falls back to 'theme.primary'
3288
+ var mainTone = getColorHex(stateColorKey);
3289
+ if (mainTone === 'theme.button.background' || mainTone === 'theme.loading') {
3290
+ mainTone = getColorHex(isLoading ? 'color.dark.500' : 'theme.primary');
3291
+ }
3284
3292
  /* text color - explicitly provided or default to white */
3285
- var resolvedTextColorKey = textColor != null ? textColor : 'color.white';
3293
+ // Priority: explicit textColor prop -> theme.button.text -> color.white
3294
+ var resolvedTextColorKey = textColor != null ? textColor : 'theme.button.text';
3286
3295
  var resolvedTextColor = getColorHex(resolvedTextColorKey);
3296
+ if (resolvedTextColor === 'theme.button.text') {
3297
+ resolvedTextColor = getColorHex('color.white');
3298
+ }
3287
3299
  /* variant palette */
3288
3300
  var palette = React.useMemo(() => getButtonVariants(mainTone, resolvedTextColor, reversed), [mainTone, resolvedTextColor, reversed]);
3289
3301
  var base = palette[variant];
@@ -3356,50 +3368,57 @@
3356
3368
  * - Rounded corners: Consistent border radius
3357
3369
  * - Transitions: Subtle animations
3358
3370
  */
3371
+ /**
3372
+ * Card sizes following the 4px grid system
3373
+ */
3374
+ var CardSizes = {
3375
+ sm: {
3376
+ padding: '12px'
3377
+ },
3378
+ md: {
3379
+ padding: '16px'
3380
+ },
3381
+ lg: {
3382
+ padding: '24px'
3383
+ }
3384
+ };
3359
3385
  /**
3360
3386
  * Card shapes with consistent border radius
3361
3387
  */
3362
3388
  var CardShapes = {
3363
3389
  sharp: 0,
3364
3390
  rounded: '8px',
3365
- pillShaped: '16px'
3391
+ pillShaped: '24px'
3366
3392
  };
3367
3393
  /**
3368
3394
  * Get card variants with consistent styling based on theme mode
3369
3395
  */
3370
3396
  var getCardVariants = themeMode => {
3397
+ var isDark = themeMode === 'dark';
3371
3398
  return {
3372
3399
  default: {
3373
- backgroundColor: 'color.white',
3400
+ backgroundColor: isDark ? 'color.gray.900' : 'color.white',
3374
3401
  border: 'none',
3375
3402
  transition: 'background-color 0.2s ease, box-shadow 0.2s ease'
3376
3403
  },
3377
3404
  outlined: {
3378
- backgroundColor: 'color.white',
3405
+ backgroundColor: isDark ? 'color.gray.900' : 'color.white',
3379
3406
  borderWidth: '1px',
3380
3407
  borderStyle: 'solid',
3381
- borderColor: 'color.gray.200',
3408
+ borderColor: isDark ? 'color.gray.700' : 'color.gray.200',
3382
3409
  transition: 'border-color 0.2s ease, box-shadow 0.2s ease',
3383
3410
  _hover: {
3384
- borderColor: 'color.gray.300',
3411
+ borderColor: isDark ? 'color.gray.600' : 'color.gray.300',
3385
3412
  boxShadow: '0px 1px 3px rgba(0, 0, 0, 0.05)'
3386
- },
3387
- _focusVisible: {
3388
- outline: 'none',
3389
- boxShadow: '0 0 0 2px rgba(255, 255, 255, 1), 0 0 0 4px rgba(0, 0, 0, 0.1)'
3390
3413
  }
3391
3414
  },
3392
3415
  elevated: {
3393
- backgroundColor: 'color.white',
3394
- boxShadow: '0px 1px 3px rgba(0, 0, 0, 0.08), 0px 1px 2px rgba(0, 0, 0, 0.06)',
3416
+ backgroundColor: isDark ? 'color.gray.900' : 'color.white',
3417
+ boxShadow: isDark ? '0px 4px 12px rgba(0, 0, 0, 0.3)' : '0px 1px 3px rgba(0, 0, 0, 0.08), 0px 1px 2px rgba(0, 0, 0, 0.06)',
3395
3418
  border: 'none',
3396
3419
  transition: 'box-shadow 0.2s ease',
3397
3420
  _hover: {
3398
- boxShadow: '0px 4px 6px rgba(0, 0, 0, 0.08), 0px 2px 4px rgba(0, 0, 0, 0.06)'
3399
- },
3400
- _focusVisible: {
3401
- outline: 'none',
3402
- boxShadow: '0 0 0 2px rgba(255, 255, 255, 1), 0 0 0 4px rgba(0, 0, 0, 0.1), 0px 4px 6px rgba(0, 0, 0, 0.08)'
3421
+ boxShadow: isDark ? '0px 8px 16px rgba(0, 0, 0, 0.4)' : '0px 4px 6px rgba(0, 0, 0, 0.08), 0px 2px 4px rgba(0, 0, 0, 0.06)'
3403
3422
  }
3404
3423
  }
3405
3424
  };
@@ -3409,50 +3428,31 @@
3409
3428
  * @param theme - Theme object from useTheme hook
3410
3429
  */
3411
3430
  var getDefaultCardStyles = theme => {
3431
+ var isDark = theme.themeMode === 'dark';
3412
3432
  return {
3413
3433
  container: {
3414
- backgroundColor: 'color.white',
3415
- color: 'color.black',
3434
+ backgroundColor: isDark ? 'color.gray.900' : 'color.white',
3435
+ color: isDark ? 'color.white' : 'color.black',
3416
3436
  borderRadius: '8px',
3417
3437
  overflow: 'hidden',
3418
- transition: 'all 0.2s ease',
3419
- media: {
3420
- mobile: {
3421
- borderRadius: '4px'
3422
- }
3423
- }
3438
+ transition: 'all 0.2s ease'
3424
3439
  },
3425
3440
  header: {
3426
3441
  padding: '16px',
3427
3442
  borderBottomWidth: '1px',
3428
3443
  borderBottomStyle: 'solid',
3429
- borderBottomColor: 'color.gray.200',
3430
- color: 'color.black',
3431
- media: {
3432
- mobile: {
3433
- padding: '12px'
3434
- }
3435
- }
3444
+ borderBottomColor: isDark ? 'color.gray.800' : 'color.gray.100',
3445
+ color: 'theme.primary'
3436
3446
  },
3437
3447
  content: {
3438
3448
  padding: '16px',
3439
- color: 'color.black',
3440
- media: {
3441
- mobile: {
3442
- padding: '12px'
3443
- }
3444
- }
3449
+ color: isDark ? 'color.gray.300' : 'color.gray.600'
3445
3450
  },
3446
3451
  footer: {
3447
3452
  padding: '16px',
3448
3453
  borderTopWidth: '1px',
3449
3454
  borderTopStyle: 'solid',
3450
- borderTopColor: 'color.gray.200',
3451
- media: {
3452
- mobile: {
3453
- padding: '12px'
3454
- }
3455
- }
3455
+ borderTopColor: isDark ? 'color.gray.800' : 'color.gray.100'
3456
3456
  }
3457
3457
  };
3458
3458
  };
@@ -3477,12 +3477,14 @@
3477
3477
  var {
3478
3478
  styles: contextStyles
3479
3479
  } = useCardContext();
3480
- var defaultStyles = getDefaultCardStyles().header;
3480
+ var defaultStyles = getDefaultCardStyles(theme).header;
3481
3481
  // Merge styles: Default < Context Override < Direct Props/Style
3482
3482
  var mergedProps = Object.assign({}, defaultStyles, contextStyles == null ? void 0 : contextStyles.header, props, {
3483
3483
  style: Object.assign({}, defaultStyles == null ? void 0 : defaultStyles.style, contextStyles == null || (_contextStyles$header = contextStyles.header) == null ? void 0 : _contextStyles$header.style, style)
3484
3484
  });
3485
- return /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({}, mergedProps), children);
3485
+ return /*#__PURE__*/React__default.createElement(appStudio.Vertical, Object.assign({
3486
+ gap: 8
3487
+ }, mergedProps), children);
3486
3488
  };
3487
3489
  var CardContent = _ref2 => {
3488
3490
  var _contextStyles$conten;
@@ -3495,12 +3497,14 @@
3495
3497
  var {
3496
3498
  styles: contextStyles
3497
3499
  } = useCardContext();
3498
- var defaultStyles = getDefaultCardStyles().content;
3500
+ var defaultStyles = getDefaultCardStyles(theme).content;
3499
3501
  // Merge styles: Default < Context Override < Direct Props/Style
3500
3502
  var mergedProps = Object.assign({}, defaultStyles, contextStyles == null ? void 0 : contextStyles.content, props, {
3501
3503
  style: Object.assign({}, defaultStyles == null ? void 0 : defaultStyles.style, contextStyles == null || (_contextStyles$conten = contextStyles.content) == null ? void 0 : _contextStyles$conten.style, style)
3502
3504
  });
3503
- return /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({}, mergedProps), children);
3505
+ return /*#__PURE__*/React__default.createElement(appStudio.Vertical, Object.assign({
3506
+ gap: 12
3507
+ }, mergedProps), children);
3504
3508
  };
3505
3509
  var CardFooter = _ref3 => {
3506
3510
  var _contextStyles$footer;
@@ -3513,15 +3517,17 @@
3513
3517
  var {
3514
3518
  styles: contextStyles
3515
3519
  } = useCardContext();
3516
- var defaultStyles = getDefaultCardStyles().footer;
3520
+ var defaultStyles = getDefaultCardStyles(theme).footer;
3517
3521
  // Merge styles: Default < Context Override < Direct Props/Style
3518
3522
  var mergedProps = Object.assign({}, defaultStyles, contextStyles == null ? void 0 : contextStyles.footer, props, {
3519
3523
  style: Object.assign({}, defaultStyles == null ? void 0 : defaultStyles.style, contextStyles == null || (_contextStyles$footer = contextStyles.footer) == null ? void 0 : _contextStyles$footer.style, style)
3520
3524
  });
3521
- return /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({}, mergedProps), children);
3525
+ return /*#__PURE__*/React__default.createElement(appStudio.Vertical, Object.assign({
3526
+ gap: 8
3527
+ }, mergedProps), children);
3522
3528
  };
3523
3529
  var CardView = _ref4 => {
3524
- var _contextValue$styles$;
3530
+ var _CardSizes$size, _contextValue$styles$;
3525
3531
  var {
3526
3532
  variant = 'default',
3527
3533
  size = 'md',
@@ -3536,20 +3542,32 @@
3536
3542
  } = _ref4,
3537
3543
  props = _objectWithoutPropertiesLoose(_ref4, _excluded4$3);
3538
3544
  var theme = appStudio.useTheme();
3539
- var defaultStyles = getDefaultCardStyles();
3545
+ var defaultStyles = getDefaultCardStyles(theme);
3546
+ // Get size padding
3547
+ var sizePadding = ((_CardSizes$size = CardSizes[size]) == null ? void 0 : _CardSizes$size.padding) || '16px';
3540
3548
  // Prepare context value, merging default styles with user's `views` overrides
3541
3549
  var contextValue = React.useMemo(() => ({
3542
3550
  styles: {
3543
3551
  container: Object.assign({}, defaultStyles.container, views == null ? void 0 : views.container),
3544
- header: Object.assign({}, defaultStyles.header, views == null ? void 0 : views.header),
3545
- content: Object.assign({}, defaultStyles.content, views == null ? void 0 : views.content),
3546
- footer: Object.assign({}, defaultStyles.footer, views == null ? void 0 : views.footer)
3547
- }
3548
- }), [defaultStyles, views]);
3552
+ header: Object.assign({}, defaultStyles.header, {
3553
+ padding: sizePadding
3554
+ }, views == null ? void 0 : views.header),
3555
+ content: Object.assign({}, defaultStyles.content, {
3556
+ padding: sizePadding
3557
+ }, views == null ? void 0 : views.content),
3558
+ footer: Object.assign({}, defaultStyles.footer, {
3559
+ padding: sizePadding
3560
+ }, views == null ? void 0 : views.footer)
3561
+ }
3562
+ }), [defaultStyles, views, sizePadding]);
3549
3563
  // Determine if we have explicit Card.Header, Card.Content, Card.Footer components
3550
- // or if we need to wrap children in a default layout
3551
3564
  var hasExplicitStructure = React__default.Children.toArray(children).some(child => /*#__PURE__*/React__default.isValidElement(child) && (child.type === CardHeader || child.type === CardContent || child.type === CardFooter));
3552
- var variantStyles = getCardVariants()[variant];
3565
+ // Get the appropriate variant styles based on theme mode
3566
+ var {
3567
+ themeMode
3568
+ } = theme;
3569
+ var currentThemeMode = elementMode || themeMode;
3570
+ var variantStyles = getCardVariants(currentThemeMode)[variant];
3553
3571
  // Merge styles for the root element
3554
3572
  var mergedRootProps = Object.assign({
3555
3573
  width: isFullWidth ? '100%' : 'auto',
@@ -3560,7 +3578,9 @@
3560
3578
  });
3561
3579
  return /*#__PURE__*/React__default.createElement(CardContext.Provider, {
3562
3580
  value: contextValue
3563
- }, /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({}, mergedRootProps), hasExplicitStructure ? children : (/*#__PURE__*/React__default.createElement(appStudio.Vertical, null, header && /*#__PURE__*/React__default.createElement(CardHeader, null, header), /*#__PURE__*/React__default.createElement(CardContent, null, children), footer && /*#__PURE__*/React__default.createElement(CardFooter, null, footer)))));
3581
+ }, /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({}, mergedRootProps), hasExplicitStructure ? children : (/*#__PURE__*/React__default.createElement(appStudio.Vertical, {
3582
+ width: "100%"
3583
+ }, header && /*#__PURE__*/React__default.createElement(CardHeader, null, header), /*#__PURE__*/React__default.createElement(CardContent, null, children), footer && /*#__PURE__*/React__default.createElement(CardFooter, null, footer)))));
3564
3584
  };
3565
3585
 
3566
3586
  /**
@@ -7296,12 +7316,9 @@
7296
7316
  // State-specific colors
7297
7317
  states: {
7298
7318
  hover: {
7299
- active: {
7300
- opacity: 0.9
7301
- },
7302
- inactive: {
7303
- backgroundColor: 'color.gray.400'
7304
- }
7319
+ active: 'theme.primary',
7320
+ inactive: 'color.gray.400',
7321
+ activeOpacity: 0.9
7305
7322
  },
7306
7323
  focus: {
7307
7324
  active: {
@@ -7315,6 +7332,17 @@
7315
7332
  }
7316
7333
  }
7317
7334
  };
7335
+ /**
7336
+ * Transition styles for the Switch component
7337
+ */
7338
+ var TransitionStyles = {
7339
+ slider: {
7340
+ transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)'
7341
+ },
7342
+ knob: {
7343
+ transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)'
7344
+ }
7345
+ };
7318
7346
 
7319
7347
  var _excluded$t = ["id", "name", "label", "inActiveChild", "isChecked", "activeChild", "labelPosition", "shadow", "size", "value", "isHovered", "isDisabled", "isReadOnly", "on", "setOn", "onChange", "setValue", "setIsHovered", "helperText", "views"];
7320
7348
  var SwitchContent = props => /*#__PURE__*/React__default.createElement(appStudio.Input, Object.assign({
@@ -7353,7 +7381,8 @@
7353
7381
  if (onChange) onChange(newValue);
7354
7382
  }
7355
7383
  };
7356
- var handleHover = () => setIsHovered(!isHovered);
7384
+ var handleMouseEnter = () => setIsHovered(true);
7385
+ var handleMouseLeave = () => setIsHovered(false);
7357
7386
  /**
7358
7387
  * Styles for the switch component
7359
7388
  */
@@ -7375,8 +7404,8 @@
7375
7404
  };
7376
7405
  return /*#__PURE__*/React__default.createElement(Label, Object.assign({
7377
7406
  htmlFor: id,
7378
- onMouseEnter: handleHover,
7379
- onMouseLeave: handleHover
7407
+ onMouseEnter: handleMouseEnter,
7408
+ onMouseLeave: handleMouseLeave
7380
7409
  }, switchStyle.container, props), /*#__PURE__*/React__default.createElement(SwitchContent, Object.assign({
7381
7410
  id: id,
7382
7411
  name: name,
@@ -7404,12 +7433,10 @@
7404
7433
  borderRadius: "9999px" // Full rounded for pill shape
7405
7434
  ,
7406
7435
  backgroundColor: isDisabled ? ColorSchemes.default.disabled : value ? isHovered ? ColorSchemes.states.hover.active : ColorSchemes.default.active : isHovered ? ColorSchemes.states.hover.inactive : ColorSchemes.default.inactive,
7407
- overflow: "hidden",
7436
+ opacity: !isDisabled && value && isHovered ? ColorSchemes.states.hover.activeOpacity : 1,
7408
7437
  // State properties
7409
- cursor: "pointer",
7410
- // Animation
7411
- transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)"
7412
- }, shadow, SliderPadding[size], SliderSizes[size], views['slider']), activeChild && value && (/*#__PURE__*/React__default.createElement(appStudio.View, {
7438
+ cursor: "pointer"
7439
+ }, TransitionStyles.slider, shadow, SliderPadding[size], SliderSizes[size], views['slider']), activeChild && value && (/*#__PURE__*/React__default.createElement(appStudio.View, {
7413
7440
  marginLeft: 8,
7414
7441
  marginRight: 4,
7415
7442
  transition: "all 0.3s ease",
@@ -7420,8 +7447,9 @@
7420
7447
  }, activeChild)), /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
7421
7448
  borderRadius: "50%",
7422
7449
  backgroundColor: ColorSchemes.default.knob,
7423
- boxShadow: "0 1px 2px rgba(0, 0, 0, 0.1)",
7424
- transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
7450
+ boxShadow: isHovered ? '0 2px 4px rgba(0, 0, 0, 0.2)' : '0 1px 2px rgba(0, 0, 0, 0.1)',
7451
+ transform: isHovered ? 'scale(1.05)' : 'scale(1)'
7452
+ }, TransitionStyles.knob, {
7425
7453
  zIndex: 1
7426
7454
  }, KnobSizes[size], views['circle'])), inActiveChild && !value && (/*#__PURE__*/React__default.createElement(appStudio.View, {
7427
7455
  marginRight: 8,
@@ -11233,29 +11261,32 @@
11233
11261
  alignItems: "center",
11234
11262
  gap: 6,
11235
11263
  padding: chipSize.padding,
11236
- backgroundColor: "white",
11264
+ backgroundColor: "color.gray.100",
11237
11265
  borderRadius: "16px",
11238
- border: "1px solid",
11239
- borderColor: "color.black.100",
11266
+ borderWidth: "1px",
11267
+ borderStyle: "solid",
11268
+ borderColor: "color.gray.300",
11240
11269
  boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
11241
11270
  transition: "all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",
11242
11271
  opacity: isDisabled ? 0.6 : 1,
11243
11272
  _hover: !isDisabled && !isReadOnly ? {
11244
- borderColor: 'color.gray.300',
11273
+ backgroundColor: 'color.gray.200',
11274
+ borderColor: 'color.gray.400',
11245
11275
  boxShadow: '0 4px 6px rgba(0,0,0,0.05)',
11246
11276
  transform: 'translateY(-1px)'
11247
11277
  } : {}
11248
11278
  }, views == null ? void 0 : views.tag), /*#__PURE__*/React__default.createElement(appStudio.Text, Object.assign({
11249
11279
  fontSize: chipSize.fontSize,
11250
- color: isDisabled ? 'color.gray.400' : 'color.gray.700',
11251
- fontWeight: "500",
11280
+ color: isDisabled ? 'color.gray.400' : 'theme.primary',
11281
+ fontWeight: "bold",
11252
11282
  whiteSpace: "nowrap"
11253
11283
  }, views == null ? void 0 : views.tagText), tag), isRemovable && !isDisabled && !isReadOnly && (/*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
11254
11284
  cursor: "pointer",
11255
11285
  padding: "2px",
11256
11286
  borderRadius: "50%",
11257
11287
  transition: "all 0.2s ease",
11258
- backgroundColor: isRemoveHovered ? 'color.red.50' : 'transparent',
11288
+ backgroundColor: isRemoveHovered ? 'color.red.100' : 'transparent',
11289
+ opacity: isRemoveHovered ? 1 : 0.7,
11259
11290
  onMouseEnter: () => setIsRemoveHovered(true),
11260
11291
  onMouseLeave: () => setIsRemoveHovered(false),
11261
11292
  onClick: e => {
@@ -11322,7 +11353,7 @@
11322
11353
  outline: 'none',
11323
11354
  backgroundColor: 'transparent',
11324
11355
  fontSize: appStudio.Typography.fontSizes[size],
11325
- color: isDisabled ? 'color.gray.400' : 'color.gray.900',
11356
+ color: isDisabled ? 'color.gray.400' : 'color.gray.800',
11326
11357
  flex: 1,
11327
11358
  minWidth: '120px'
11328
11359
  }, views == null ? void 0 : views.input);