@basic-ui/material 1.0.0-alpha.23 → 1.0.0-alpha.25
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/build/cjs/index.js +134 -20
- package/build/cjs/index.js.map +1 -1
- package/build/esm/Badge/Badge.d.ts +2 -2
- package/build/esm/Badge/Badge.js +28 -2
- package/build/esm/Badge/Badge.js.map +1 -1
- package/build/esm/Chip/ButtonChip.d.ts +1 -1
- package/build/esm/NavRail/NavRailItem.d.ts +3 -3
- package/build/esm/NavRail/NavRailItem.js +0 -1
- package/build/esm/NavRail/NavRailItem.js.map +1 -1
- package/build/esm/NavRail/icons/test-icons.d.ts +4 -0
- package/build/esm/NavRail/icons/test-icons.js +42 -0
- package/build/esm/NavRail/icons/test-icons.js.map +1 -0
- package/build/esm/Tab/Tab.d.ts +1 -1
- package/build/esm/Tab/Tab.js +45 -9
- package/build/esm/Tab/Tab.js.map +1 -1
- package/build/esm/Tab/TabList.d.ts +2 -1
- package/build/esm/Tab/TabList.js +5 -2
- package/build/esm/Tab/TabList.js.map +1 -1
- package/build/esm/Tab/context.d.ts +1 -0
- package/build/esm/Tab/context.js +2 -1
- package/build/esm/Tab/context.js.map +1 -1
- package/build/esm/TabIndicator/TabIndicator.d.ts +4 -2
- package/build/esm/TabIndicator/TabIndicator.js +75 -9
- package/build/esm/TabIndicator/TabIndicator.js.map +1 -1
- package/build/esm/Table/TableHead.d.ts +1 -1
- package/build/esm/theme/theme.js +1 -1
- package/build/esm/theme/theme.js.map +1 -1
- package/build/tsconfig-build.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/Badge/Badge.story.tsx +68 -0
- package/src/Badge/Badge.tsx +33 -3
- package/src/NavRail/NavRail.story.tsx +1 -45
- package/src/NavRail/NavRailItem.tsx +0 -1
- package/src/NavRail/icons/test-icons.tsx +46 -0
- package/src/Tab/Tab.story.tsx +170 -14
- package/src/Tab/Tab.tsx +52 -10
- package/src/Tab/TabList.tsx +5 -1
- package/src/Tab/context.ts +2 -0
- package/src/TabIndicator/TabIndicator.tsx +83 -7
- package/src/theme/theme.ts +1 -1
package/build/cjs/index.js
CHANGED
|
@@ -192,7 +192,7 @@ const theme = {
|
|
|
192
192
|
'title-small': font('plain', 20, 14, 0.1, 500),
|
|
193
193
|
'label-large': font('plain', 20, 14, 0.1, 500),
|
|
194
194
|
'label-medium': font('plain', 16, 12, 0.5, 500),
|
|
195
|
-
'label-small': font('plain',
|
|
195
|
+
'label-small': font('plain', 15, 11, 0.5, 500),
|
|
196
196
|
'body-large': font('plain', 24, 16, 0.5, 400),
|
|
197
197
|
'body-medium': font('plain', 20, 14, 0.25, 400),
|
|
198
198
|
'body-small': font('plain', 16, 12, 0.4, 400),
|
|
@@ -1530,10 +1530,35 @@ const Alert = /*#__PURE__*/react$1.forwardRef(function Alert(props, forwardedRef
|
|
|
1530
1530
|
});
|
|
1531
1531
|
|
|
1532
1532
|
const Badge = /*#__PURE__*/react$1.forwardRef(function Badge(props, forwardedRef) {
|
|
1533
|
-
const {
|
|
1533
|
+
const {
|
|
1534
|
+
size = 'large',
|
|
1535
|
+
__css,
|
|
1536
|
+
...otherProps
|
|
1534
1537
|
} = props;
|
|
1535
1538
|
return /*#__PURE__*/jsxRuntime.jsx(Box, {
|
|
1536
1539
|
ref: forwardedRef,
|
|
1540
|
+
__css: {
|
|
1541
|
+
variant: 'text.label-small',
|
|
1542
|
+
bg: 'error',
|
|
1543
|
+
color: 'on.error',
|
|
1544
|
+
borderRadius: 'full',
|
|
1545
|
+
...(size === 'small' ? {
|
|
1546
|
+
maxWidth: "0.375rem",
|
|
1547
|
+
maxHeight: "0.375rem",
|
|
1548
|
+
minWidth: "0.375rem",
|
|
1549
|
+
minHeight: "0.375rem"
|
|
1550
|
+
} : {
|
|
1551
|
+
px: 1,
|
|
1552
|
+
maxHeight: "1rem",
|
|
1553
|
+
minWidth: "1rem",
|
|
1554
|
+
minHeight: "1rem"
|
|
1555
|
+
}),
|
|
1556
|
+
display: 'inline-flex',
|
|
1557
|
+
alignItems: 'center',
|
|
1558
|
+
justifyContent: 'center',
|
|
1559
|
+
fontVariantNumeric: 'tabular-nums',
|
|
1560
|
+
...__css
|
|
1561
|
+
},
|
|
1537
1562
|
...otherProps
|
|
1538
1563
|
});
|
|
1539
1564
|
});
|
|
@@ -3853,7 +3878,6 @@ const NavRailItem = /*#__PURE__*/react$1.forwardRef(function NavRailItem(props,
|
|
|
3853
3878
|
backgroundColor: 'transparent',
|
|
3854
3879
|
margin: 0,
|
|
3855
3880
|
padding: 0,
|
|
3856
|
-
px: "0.75rem",
|
|
3857
3881
|
minHeight: "3.75rem",
|
|
3858
3882
|
height: "3.75rem",
|
|
3859
3883
|
cursor: 'pointer',
|
|
@@ -5280,54 +5304,110 @@ const {
|
|
|
5280
5304
|
} = TabIndicatorContext;
|
|
5281
5305
|
const useTabIndicatorContext = () => react$1.useContext(TabIndicatorContext);
|
|
5282
5306
|
|
|
5307
|
+
const WIDTH_PROPERTY_NAME = '--indicator-width';
|
|
5308
|
+
const SCALE_PROPERTY_NAME = '--indicator-scale';
|
|
5283
5309
|
const useEnhancedEffect = typeof window !== 'undefined' ? react$1.useLayoutEffect : react$1.useEffect;
|
|
5284
5310
|
const TabIndicator = /*#__PURE__*/react$1.forwardRef(function TabIndicator(props, forwardedRef) {
|
|
5285
5311
|
const {
|
|
5286
5312
|
as = 'span',
|
|
5287
5313
|
selected,
|
|
5288
5314
|
color = 'primary',
|
|
5315
|
+
variant,
|
|
5316
|
+
labelRef,
|
|
5289
5317
|
...otherProps
|
|
5290
5318
|
} = props;
|
|
5291
5319
|
const ref = react$1.useRef(null);
|
|
5292
5320
|
const {
|
|
5293
5321
|
currentIndicator
|
|
5294
5322
|
} = useTabIndicatorContext();
|
|
5323
|
+
const resizeObserverRef = react$1.useRef();
|
|
5295
5324
|
useEnhancedEffect(() => {
|
|
5296
5325
|
if (selected && ref.current) {
|
|
5297
5326
|
if (currentIndicator.current !== null) {
|
|
5298
5327
|
// We are switching indicator, let's slide!
|
|
5299
5328
|
const previousClientRect = currentIndicator.current.getBoundingClientRect();
|
|
5300
5329
|
const currentClientRect = ref.current.getBoundingClientRect();
|
|
5301
|
-
const widthDelta = previousClientRect.width / currentClientRect.width;
|
|
5302
5330
|
const xPosition = previousClientRect.left - currentClientRect.left;
|
|
5303
5331
|
const prevTransition = ref.current.style.transition;
|
|
5304
5332
|
const prevTransform = ref.current.style.transform;
|
|
5305
5333
|
ref.current.style.transition = 'none';
|
|
5306
|
-
|
|
5334
|
+
|
|
5335
|
+
if (variant === 'primary') {
|
|
5336
|
+
const prevWidth = currentIndicator.current.style.getPropertyValue(WIDTH_PROPERTY_NAME);
|
|
5337
|
+
const currentWidth = ref.current.style.getPropertyValue(WIDTH_PROPERTY_NAME);
|
|
5338
|
+
const widthDelta = String(parseFloat(prevWidth) / parseFloat(currentWidth));
|
|
5339
|
+
ref.current.style.setProperty(SCALE_PROPERTY_NAME, widthDelta);
|
|
5340
|
+
ref.current.style.transform = `translateX(${xPosition}px)`;
|
|
5341
|
+
} else {
|
|
5342
|
+
const widthDelta = previousClientRect.width / currentClientRect.width;
|
|
5343
|
+
ref.current.style.transform = `translateX(${xPosition}px) scaleX(${widthDelta})`;
|
|
5344
|
+
} // Force repaint before updating classes and transform to ensure the transform properly takes effect
|
|
5345
|
+
|
|
5307
5346
|
|
|
5308
5347
|
ref.current.getBoundingClientRect(); // Restore and let transition do it's magic
|
|
5309
5348
|
|
|
5310
5349
|
ref.current.style.transition = prevTransition;
|
|
5311
5350
|
ref.current.style.transform = prevTransform;
|
|
5351
|
+
|
|
5352
|
+
if (variant === 'primary') {
|
|
5353
|
+
ref.current.style.setProperty(SCALE_PROPERTY_NAME, '1');
|
|
5354
|
+
}
|
|
5312
5355
|
}
|
|
5313
5356
|
|
|
5314
5357
|
currentIndicator.current = ref.current;
|
|
5315
5358
|
}
|
|
5316
|
-
}, [selected]);
|
|
5359
|
+
}, [selected, variant]);
|
|
5360
|
+
useEnhancedEffect(() => {
|
|
5361
|
+
if (variant === 'secondary') {
|
|
5362
|
+
return;
|
|
5363
|
+
}
|
|
5364
|
+
|
|
5365
|
+
if (labelRef.current && ref.current) {
|
|
5366
|
+
const width = labelRef.current.getBoundingClientRect().width;
|
|
5367
|
+
ref.current.style.setProperty(WIDTH_PROPERTY_NAME, `${width}px`);
|
|
5368
|
+
|
|
5369
|
+
if (typeof ResizeObserver === 'function') {
|
|
5370
|
+
resizeObserverRef.current ??= new ResizeObserver(([entry]) => {
|
|
5371
|
+
if (ref.current) {
|
|
5372
|
+
ref.current.style.setProperty(WIDTH_PROPERTY_NAME, `${entry.contentRect.width}px`);
|
|
5373
|
+
}
|
|
5374
|
+
});
|
|
5375
|
+
resizeObserverRef.current?.observe(labelRef.current);
|
|
5376
|
+
return () => resizeObserverRef.current?.disconnect();
|
|
5377
|
+
}
|
|
5378
|
+
}
|
|
5379
|
+
}, [labelRef, variant]);
|
|
5317
5380
|
return /*#__PURE__*/jsxRuntime.jsx(Box, {
|
|
5318
5381
|
as: as,
|
|
5319
5382
|
ref: core.assignMultipleRefs(ref, forwardedRef),
|
|
5320
|
-
width: "100%",
|
|
5321
|
-
height: "0.125rem",
|
|
5322
5383
|
__css: {
|
|
5323
5384
|
bg: color,
|
|
5324
5385
|
position: 'absolute',
|
|
5325
5386
|
bottom: 0,
|
|
5326
5387
|
transform: `scale(1)`,
|
|
5327
5388
|
opacity: selected ? 1 : 0,
|
|
5328
|
-
transformOrigin: 'left',
|
|
5329
5389
|
transition: `transform .25s ${EASING_STANDARD}`,
|
|
5330
|
-
zIndex: 1
|
|
5390
|
+
zIndex: 1,
|
|
5391
|
+
...(variant === 'secondary' ? {
|
|
5392
|
+
width: '100%',
|
|
5393
|
+
height: "0.125rem"
|
|
5394
|
+
} : {
|
|
5395
|
+
width: '100%',
|
|
5396
|
+
'&::before': {
|
|
5397
|
+
content: '""',
|
|
5398
|
+
width: `var(${WIDTH_PROPERTY_NAME}, 0px)`,
|
|
5399
|
+
height: "0.1875rem",
|
|
5400
|
+
borderTopLeftRadius: "0.1875rem",
|
|
5401
|
+
borderTopRightRadius: "0.1875rem",
|
|
5402
|
+
bg: color,
|
|
5403
|
+
position: 'absolute',
|
|
5404
|
+
transformOrigin: 'center',
|
|
5405
|
+
bottom: 0,
|
|
5406
|
+
left: '50%',
|
|
5407
|
+
transition: `inherit`,
|
|
5408
|
+
transform: `translateX(-50%) scaleX(var(${SCALE_PROPERTY_NAME}, 1))}`
|
|
5409
|
+
}
|
|
5410
|
+
})
|
|
5331
5411
|
},
|
|
5332
5412
|
...otherProps
|
|
5333
5413
|
});
|
|
@@ -5335,7 +5415,8 @@ const TabIndicator = /*#__PURE__*/react$1.forwardRef(function TabIndicator(props
|
|
|
5335
5415
|
|
|
5336
5416
|
const TabListContext = /*#__PURE__*/react$1.createContext({
|
|
5337
5417
|
indicatorColor: 'primary',
|
|
5338
|
-
textColor: 'on.surface'
|
|
5418
|
+
textColor: 'on.surface',
|
|
5419
|
+
variant: 'secondary'
|
|
5339
5420
|
});
|
|
5340
5421
|
const {
|
|
5341
5422
|
Provider: TabListProvider
|
|
@@ -5364,6 +5445,7 @@ const TabList = /*#__PURE__*/react$1.forwardRef(function TabList(props, forwarde
|
|
|
5364
5445
|
indicatorColor = 'primary',
|
|
5365
5446
|
textColor = 'on.surface',
|
|
5366
5447
|
selectedTextColor,
|
|
5448
|
+
variant = 'secondary',
|
|
5367
5449
|
...otherProps
|
|
5368
5450
|
} = props;
|
|
5369
5451
|
const currentIndicator = react$1.useRef(null);
|
|
@@ -5371,7 +5453,8 @@ const TabList = /*#__PURE__*/react$1.forwardRef(function TabList(props, forwarde
|
|
|
5371
5453
|
value: {
|
|
5372
5454
|
indicatorColor,
|
|
5373
5455
|
textColor,
|
|
5374
|
-
selectedTextColor
|
|
5456
|
+
selectedTextColor,
|
|
5457
|
+
variant
|
|
5375
5458
|
},
|
|
5376
5459
|
children: /*#__PURE__*/jsxRuntime.jsx(TabIndicatorProvider, {
|
|
5377
5460
|
value: {
|
|
@@ -5398,13 +5481,20 @@ const TabInner = /*#__PURE__*/react$1.forwardRef(function Tab(props, forwardedRe
|
|
|
5398
5481
|
const {
|
|
5399
5482
|
textColor,
|
|
5400
5483
|
indicatorColor,
|
|
5401
|
-
selectedTextColor
|
|
5484
|
+
selectedTextColor,
|
|
5485
|
+
variant
|
|
5402
5486
|
} = useTabListContext();
|
|
5487
|
+
const labelRef = react$1.useRef(null);
|
|
5488
|
+
const [mounted, setMounted] = react$1.useState(false);
|
|
5489
|
+
react$1.useEffect(() => {
|
|
5490
|
+
setMounted(true);
|
|
5491
|
+
}, []);
|
|
5403
5492
|
return /*#__PURE__*/jsxRuntime.jsxs(Box, {
|
|
5404
5493
|
position: "relative",
|
|
5405
5494
|
display: "flex",
|
|
5406
5495
|
flex: 1,
|
|
5407
5496
|
flexDirection: "column",
|
|
5497
|
+
height: "100%",
|
|
5408
5498
|
children: [/*#__PURE__*/jsxRuntime.jsx(RippleBox, {
|
|
5409
5499
|
as: innerAs,
|
|
5410
5500
|
ref: forwardedRef,
|
|
@@ -5412,9 +5502,10 @@ const TabInner = /*#__PURE__*/react$1.forwardRef(function Tab(props, forwardedRe
|
|
|
5412
5502
|
disabled: disabled,
|
|
5413
5503
|
__css: {
|
|
5414
5504
|
px: 3,
|
|
5415
|
-
|
|
5505
|
+
py: 0,
|
|
5416
5506
|
color: selected ? selectedTextColor || indicatorColor : alpha(textColor, disabled ? 0.37 : 0.7),
|
|
5417
|
-
|
|
5507
|
+
minHeight: "3rem",
|
|
5508
|
+
height: '100%',
|
|
5418
5509
|
backgroundColor: 'transparent',
|
|
5419
5510
|
border: 'none',
|
|
5420
5511
|
':focus': {
|
|
@@ -5426,15 +5517,38 @@ const TabInner = /*#__PURE__*/react$1.forwardRef(function Tab(props, forwardedRe
|
|
|
5426
5517
|
...otherProps,
|
|
5427
5518
|
children: /*#__PURE__*/jsxRuntime.jsx(Text, {
|
|
5428
5519
|
as: "span",
|
|
5429
|
-
variant: "
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5520
|
+
variant: "title-small",
|
|
5521
|
+
ref: labelRef,
|
|
5522
|
+
__css: {
|
|
5523
|
+
display: 'inline-flex',
|
|
5524
|
+
justifyContent: 'center',
|
|
5525
|
+
alignItems: 'center',
|
|
5526
|
+
color: 'inherit',
|
|
5527
|
+
height: '100%',
|
|
5528
|
+
textAlign: 'center',
|
|
5529
|
+
position: 'relative',
|
|
5530
|
+
flexDirection: 'column',
|
|
5531
|
+
...(variant === 'primary' && selected && !mounted && {
|
|
5532
|
+
'&::before': {
|
|
5533
|
+
content: '""',
|
|
5534
|
+
bg: indicatorColor,
|
|
5535
|
+
position: 'absolute',
|
|
5536
|
+
bottom: 0,
|
|
5537
|
+
zIndex: 1,
|
|
5538
|
+
width: '100%',
|
|
5539
|
+
height: "0.1875rem",
|
|
5540
|
+
borderTopLeftRadius: "0.1875rem",
|
|
5541
|
+
borderTopRightRadius: "0.1875rem"
|
|
5542
|
+
}
|
|
5543
|
+
})
|
|
5544
|
+
},
|
|
5433
5545
|
children: children
|
|
5434
5546
|
})
|
|
5435
5547
|
}), /*#__PURE__*/jsxRuntime.jsx(TabIndicator, {
|
|
5436
5548
|
selected: selected,
|
|
5437
|
-
color: indicatorColor
|
|
5549
|
+
color: indicatorColor,
|
|
5550
|
+
variant: variant,
|
|
5551
|
+
labelRef: labelRef
|
|
5438
5552
|
})]
|
|
5439
5553
|
});
|
|
5440
5554
|
});
|