@dreamtree-org/twreact-ui 1.0.98 → 1.0.99

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/dist/index.esm.js CHANGED
@@ -17366,6 +17366,97 @@ var FileUpload = function FileUpload(_ref) {
17366
17366
  })));
17367
17367
  };
17368
17368
 
17369
+ var Condition = function Condition(_ref) {
17370
+ var condition = _ref.condition,
17371
+ children = _ref.children,
17372
+ _ref$fallback = _ref.fallback,
17373
+ fallback = _ref$fallback === void 0 ? null : _ref$fallback;
17374
+ return condition ? children : fallback;
17375
+ };
17376
+
17377
+ function Carousel(props) {
17378
+ var children = props.children,
17379
+ _props$autoPlay = props.autoPlay,
17380
+ autoPlay = _props$autoPlay === void 0 ? false : _props$autoPlay,
17381
+ _props$interval = props.interval,
17382
+ interval = _props$interval === void 0 ? 5000 : _props$interval,
17383
+ _props$showDots = props.showDots,
17384
+ showDots = _props$showDots === void 0 ? true : _props$showDots,
17385
+ className = props.className,
17386
+ itemClassName = props.itemClassName;
17387
+ var _React$useState = React__default.useState(0),
17388
+ _React$useState2 = _slicedToArray(_React$useState, 2),
17389
+ currentIndex = _React$useState2[0],
17390
+ setCurrentIndex = _React$useState2[1];
17391
+ var _React$useState3 = React__default.useState(false),
17392
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
17393
+ isPaused = _React$useState4[0],
17394
+ setIsPaused = _React$useState4[1];
17395
+ var timerRef = React__default.useRef(null);
17396
+ var next = React__default.useCallback(function () {
17397
+ setCurrentIndex(function (prevIndex) {
17398
+ return (prevIndex + 1) % React__default.Children.count(children);
17399
+ });
17400
+ }, [children]);
17401
+ var prev = React__default.useCallback(function () {
17402
+ var count = React__default.Children.count(children);
17403
+ setCurrentIndex(function (prevIndex) {
17404
+ return (prevIndex - 1 + count) % count;
17405
+ });
17406
+ }, [children]);
17407
+ React__default.useEffect(function () {
17408
+ if (autoPlay && !isPaused) {
17409
+ timerRef.current = setInterval(next, interval);
17410
+ }
17411
+ return function () {
17412
+ if (timerRef.current) clearInterval(timerRef.current);
17413
+ };
17414
+ }, [autoPlay, isPaused, next, interval]);
17415
+ var childrenArray = React__default.Children.toArray(children);
17416
+ return /*#__PURE__*/React__default.createElement("div", {
17417
+ className: cn$1("relative group overflow-hidden rounded-xl bg-card border border-border/50 shadow-sm", className),
17418
+ onMouseEnter: function onMouseEnter() {
17419
+ return setIsPaused(true);
17420
+ },
17421
+ onMouseLeave: function onMouseLeave() {
17422
+ return setIsPaused(false);
17423
+ }
17424
+ }, /*#__PURE__*/React__default.createElement("div", {
17425
+ className: "flex transition-transform duration-500 ease-out",
17426
+ style: {
17427
+ transform: "translateX(-".concat(currentIndex * 100, "%)")
17428
+ }
17429
+ }, childrenArray.map(function (child, index) {
17430
+ return /*#__PURE__*/React__default.createElement("div", {
17431
+ key: index,
17432
+ className: cn$1("w-full flex-shrink-0 min-w-full", itemClassName)
17433
+ }, child);
17434
+ })), /*#__PURE__*/React__default.createElement("button", {
17435
+ onClick: prev,
17436
+ className: "absolute left-4 top-1/2 -translate-y-1/2 z-10 p-2 rounded-full bg-background/80 backdrop-blur-md border border-border/50 text-foreground opacity-0 group-hover:opacity-100 transition-all hover:bg-background shadow-lg focus:outline-none focus:ring-2 focus:ring-primary",
17437
+ "aria-label": "Previous slide"
17438
+ }, /*#__PURE__*/React__default.createElement(ChevronLeft, {
17439
+ className: "w-5 h-5 text-white"
17440
+ })), /*#__PURE__*/React__default.createElement("button", {
17441
+ onClick: next,
17442
+ className: "absolute right-4 top-1/2 -translate-y-1/2 z-10 p-2 rounded-full bg-background/80 backdrop-blur-md border border-border/50 text-foreground opacity-0 group-hover:opacity-100 transition-all hover:bg-background shadow-lg focus:outline-none focus:ring-2 focus:ring-primary",
17443
+ "aria-label": "Next slide"
17444
+ }, /*#__PURE__*/React__default.createElement(ChevronRight, {
17445
+ className: "w-5 h-5 text-white"
17446
+ })), showDots && /*#__PURE__*/React__default.createElement("div", {
17447
+ className: "absolute bottom-4 left-1/2 -translate-x-1/2 flex gap-2 z-10"
17448
+ }, childrenArray.map(function (_, index) {
17449
+ return /*#__PURE__*/React__default.createElement("button", {
17450
+ key: index,
17451
+ onClick: function onClick() {
17452
+ return setCurrentIndex(index);
17453
+ },
17454
+ className: cn$1("w-2 h-2 rounded-full transition-all duration-300", currentIndex === index ? "bg-primary w-6" : "bg-muted-foreground/30 hover:bg-muted-foreground/50"),
17455
+ "aria-label": "Go to slide ".concat(index + 1)
17456
+ });
17457
+ })));
17458
+ }
17459
+
17369
17460
  var ThemeContext = /*#__PURE__*/createContext();
17370
17461
  var useTheme = function useTheme() {
17371
17462
  var context = useContext(ThemeContext);
@@ -26309,4 +26400,4 @@ var StoreProvider = function StoreProvider(_ref) {
26309
26400
  }, children));
26310
26401
  };
26311
26402
 
26312
- export { Accordion, Alert, Avatar, Badge, Breadcrumbs, Button, Card, Checkbox, ColorPicker, DatePicker, DateRangePicker, Dialog, EmitterClass as Emitter, FileUpload, FootNav, Form, Helpers, Input, Loader, LocationPicker, Navbar, Pagination, PriceRangePicker, ProgressBar, Radio, Rate, RoundedTag, Select, Sidebar, Skeleton, Stepper, StoreProvider, Switch, Table, Tabs, ThemeProvider, ThreeDotPopoverSimple as ThreeDotPopover, Toast, ToastContainer, Tooltip, cn$1 as cn, useApi, useMixins, useTheme, useToast };
26403
+ export { Accordion, Alert, Avatar, Badge, Breadcrumbs, Button, Card, Carousel, Checkbox, ColorPicker, Condition, DatePicker, DateRangePicker, Dialog, EmitterClass as Emitter, FileUpload, FootNav, Form, Helpers, Input, Loader, LocationPicker, Navbar, Pagination, PriceRangePicker, ProgressBar, Radio, Rate, RoundedTag, Select, Sidebar, Skeleton, Stepper, StoreProvider, Switch, Table, Tabs, ThemeProvider, ThreeDotPopoverSimple as ThreeDotPopover, Toast, ToastContainer, Tooltip, cn$1 as cn, useApi, useMixins, useTheme, useToast };
package/dist/index.js CHANGED
@@ -17386,6 +17386,97 @@ var FileUpload = function FileUpload(_ref) {
17386
17386
  })));
17387
17387
  };
17388
17388
 
17389
+ var Condition = function Condition(_ref) {
17390
+ var condition = _ref.condition,
17391
+ children = _ref.children,
17392
+ _ref$fallback = _ref.fallback,
17393
+ fallback = _ref$fallback === void 0 ? null : _ref$fallback;
17394
+ return condition ? children : fallback;
17395
+ };
17396
+
17397
+ function Carousel(props) {
17398
+ var children = props.children,
17399
+ _props$autoPlay = props.autoPlay,
17400
+ autoPlay = _props$autoPlay === void 0 ? false : _props$autoPlay,
17401
+ _props$interval = props.interval,
17402
+ interval = _props$interval === void 0 ? 5000 : _props$interval,
17403
+ _props$showDots = props.showDots,
17404
+ showDots = _props$showDots === void 0 ? true : _props$showDots,
17405
+ className = props.className,
17406
+ itemClassName = props.itemClassName;
17407
+ var _React$useState = React.useState(0),
17408
+ _React$useState2 = _slicedToArray(_React$useState, 2),
17409
+ currentIndex = _React$useState2[0],
17410
+ setCurrentIndex = _React$useState2[1];
17411
+ var _React$useState3 = React.useState(false),
17412
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
17413
+ isPaused = _React$useState4[0],
17414
+ setIsPaused = _React$useState4[1];
17415
+ var timerRef = React.useRef(null);
17416
+ var next = React.useCallback(function () {
17417
+ setCurrentIndex(function (prevIndex) {
17418
+ return (prevIndex + 1) % React.Children.count(children);
17419
+ });
17420
+ }, [children]);
17421
+ var prev = React.useCallback(function () {
17422
+ var count = React.Children.count(children);
17423
+ setCurrentIndex(function (prevIndex) {
17424
+ return (prevIndex - 1 + count) % count;
17425
+ });
17426
+ }, [children]);
17427
+ React.useEffect(function () {
17428
+ if (autoPlay && !isPaused) {
17429
+ timerRef.current = setInterval(next, interval);
17430
+ }
17431
+ return function () {
17432
+ if (timerRef.current) clearInterval(timerRef.current);
17433
+ };
17434
+ }, [autoPlay, isPaused, next, interval]);
17435
+ var childrenArray = React.Children.toArray(children);
17436
+ return /*#__PURE__*/React.createElement("div", {
17437
+ className: cn$1("relative group overflow-hidden rounded-xl bg-card border border-border/50 shadow-sm", className),
17438
+ onMouseEnter: function onMouseEnter() {
17439
+ return setIsPaused(true);
17440
+ },
17441
+ onMouseLeave: function onMouseLeave() {
17442
+ return setIsPaused(false);
17443
+ }
17444
+ }, /*#__PURE__*/React.createElement("div", {
17445
+ className: "flex transition-transform duration-500 ease-out",
17446
+ style: {
17447
+ transform: "translateX(-".concat(currentIndex * 100, "%)")
17448
+ }
17449
+ }, childrenArray.map(function (child, index) {
17450
+ return /*#__PURE__*/React.createElement("div", {
17451
+ key: index,
17452
+ className: cn$1("w-full flex-shrink-0 min-w-full", itemClassName)
17453
+ }, child);
17454
+ })), /*#__PURE__*/React.createElement("button", {
17455
+ onClick: prev,
17456
+ className: "absolute left-4 top-1/2 -translate-y-1/2 z-10 p-2 rounded-full bg-background/80 backdrop-blur-md border border-border/50 text-foreground opacity-0 group-hover:opacity-100 transition-all hover:bg-background shadow-lg focus:outline-none focus:ring-2 focus:ring-primary",
17457
+ "aria-label": "Previous slide"
17458
+ }, /*#__PURE__*/React.createElement(ChevronLeft, {
17459
+ className: "w-5 h-5 text-white"
17460
+ })), /*#__PURE__*/React.createElement("button", {
17461
+ onClick: next,
17462
+ className: "absolute right-4 top-1/2 -translate-y-1/2 z-10 p-2 rounded-full bg-background/80 backdrop-blur-md border border-border/50 text-foreground opacity-0 group-hover:opacity-100 transition-all hover:bg-background shadow-lg focus:outline-none focus:ring-2 focus:ring-primary",
17463
+ "aria-label": "Next slide"
17464
+ }, /*#__PURE__*/React.createElement(ChevronRight, {
17465
+ className: "w-5 h-5 text-white"
17466
+ })), showDots && /*#__PURE__*/React.createElement("div", {
17467
+ className: "absolute bottom-4 left-1/2 -translate-x-1/2 flex gap-2 z-10"
17468
+ }, childrenArray.map(function (_, index) {
17469
+ return /*#__PURE__*/React.createElement("button", {
17470
+ key: index,
17471
+ onClick: function onClick() {
17472
+ return setCurrentIndex(index);
17473
+ },
17474
+ className: cn$1("w-2 h-2 rounded-full transition-all duration-300", currentIndex === index ? "bg-primary w-6" : "bg-muted-foreground/30 hover:bg-muted-foreground/50"),
17475
+ "aria-label": "Go to slide ".concat(index + 1)
17476
+ });
17477
+ })));
17478
+ }
17479
+
17389
17480
  var ThemeContext = /*#__PURE__*/React.createContext();
17390
17481
  var useTheme = function useTheme() {
17391
17482
  var context = React.useContext(ThemeContext);
@@ -26336,8 +26427,10 @@ exports.Badge = Badge;
26336
26427
  exports.Breadcrumbs = Breadcrumbs;
26337
26428
  exports.Button = Button;
26338
26429
  exports.Card = Card;
26430
+ exports.Carousel = Carousel;
26339
26431
  exports.Checkbox = Checkbox;
26340
26432
  exports.ColorPicker = ColorPicker;
26433
+ exports.Condition = Condition;
26341
26434
  exports.DatePicker = DatePicker;
26342
26435
  exports.DateRangePicker = DateRangePicker;
26343
26436
  exports.Dialog = Dialog;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamtree-org/twreact-ui",
3
- "version": "1.0.98",
3
+ "version": "1.0.99",
4
4
  "description": "A comprehensive React + Tailwind components library for building modern web apps",
5
5
  "author": {
6
6
  "name": "Partha Preetham Krishna",