@q2devel/q2-storybook 1.0.10 → 1.0.11

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.
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import React from 'react';
3
+ var Badge = function (_a) {
4
+ var children = _a.children, onClick = _a.onClick, _b = _a.color, color = _b === void 0 ? 'bg-blue-100 text-blue-800' : _b, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.labelClassName, labelClassName = _d === void 0 ? '' : _d, rightIcon = _a.rightIcon;
5
+ return (React.createElement("span", { className: "inline-flex items-center rounded px-2.5 py-0.5 text-xs font-medium ".concat(color, " ").concat(className), onClick: onClick },
6
+ React.createElement("span", { className: labelClassName }, children),
7
+ rightIcon && React.createElement("span", { className: "ml-1" }, rightIcon)));
8
+ };
9
+ export default Badge;
@@ -0,0 +1,137 @@
1
+ 'use client';
2
+ import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/react/24/outline';
3
+ import React, { useEffect, useState } from 'react';
4
+ import buildClassesByJoining from '../../utils/StyleHelper';
5
+ export var Banner = function (_a) {
6
+ var items = _a.items, _b = _a.height, height = _b === void 0 ? 'md' : _b, _c = _a.autoplay, autoplay = _c === void 0 ? false : _c, _d = _a.autoplayInterval, autoplayInterval = _d === void 0 ? 5000 : _d, _e = _a.controls, controls = _e === void 0 ? 'both' : _e, _f = _a.overlayStyle, overlayStyle = _f === void 0 ? 'gradient' : _f, _g = _a.textAlignment, textAlignment = _g === void 0 ? 'center' : _g, _h = _a.textPosition, textPosition = _h === void 0 ? 'center' : _h, _j = _a.className, className = _j === void 0 ? '' : _j, _k = _a.imageClassName, imageClassName = _k === void 0 ? '' : _k, _l = _a.titleClassName, titleClassName = _l === void 0 ? '' : _l, _m = _a.subtitleClassName, subtitleClassName = _m === void 0 ? '' : _m, _o = _a.buttonClassName, buttonClassName = _o === void 0 ? '' : _o, _p = _a.indicatorsClassName, indicatorsClassName = _p === void 0 ? '' : _p, _q = _a.controlsClassName, controlsClassName = _q === void 0 ? '' : _q, _r = _a.contentClassName, contentClassName = _r === void 0 ? '' : _r, _s = _a.rounded, rounded = _s === void 0 ? 'none' : _s, _t = _a.buttonRounded, buttonRounded = _t === void 0 ? 'md' : _t, _u = _a.animation, animation = _u === void 0 ? 'slide' : _u, _v = _a.animationDuration, animationDuration = _v === void 0 ? 500 : _v, _w = _a.pauseOnHover, pauseOnHover = _w === void 0 ? true : _w, _x = _a.infiniteLoop, infiniteLoop = _x === void 0 ? true : _x, _y = _a.objectFit, objectFit = _y === void 0 ? 'cover' : _y, _z = _a.objectPosition, objectPosition = _z === void 0 ? 'center' : _z, renderItem = _a.renderItem, renderControls = _a.renderControls, renderIndicators = _a.renderIndicators, onSlideChange = _a.onSlideChange, _0 = _a.withOverlay, withOverlay = _0 === void 0 ? true : _0, _1 = _a.overlayOpacity, overlayOpacity = _1 === void 0 ? 0.5 : _1;
7
+ var _2 = useState(0), currentIndex = _2[0], setCurrentIndex = _2[1];
8
+ var _3 = useState(0), prevIndex = _3[0], setPrevIndex = _3[1];
9
+ var _4 = useState(false), isHovered = _4[0], setIsHovered = _4[1];
10
+ var showArrows = controls === 'arrows' || controls === 'both';
11
+ var showDots = controls === 'dots' || controls === 'both';
12
+ var heightClasses = {
13
+ sm: 'h-48 sm:h-64',
14
+ md: 'h-64 sm:h-96',
15
+ lg: 'h-80 sm:h-[32rem]',
16
+ xl: 'h-96 sm:h-[40rem]',
17
+ full: 'h-screen',
18
+ auto: 'h-auto',
19
+ };
20
+ var overlayClasses = {
21
+ dark: "bg-black/".concat(Math.round(overlayOpacity * 100)),
22
+ light: "bg-white/".concat(Math.round(overlayOpacity * 100)),
23
+ gradient: 'bg-gradient-to-t from-black/70 via-black/30 to-transparent',
24
+ none: '',
25
+ };
26
+ var textAlignmentClasses = {
27
+ left: 'text-left items-start',
28
+ center: 'text-center items-center',
29
+ right: 'text-right items-end',
30
+ };
31
+ var textPositionClasses = {
32
+ top: 'justify-start pt-10',
33
+ center: 'justify-center',
34
+ bottom: 'justify-end pb-10',
35
+ };
36
+ var roundedClasses = {
37
+ none: 'rounded-none',
38
+ sm: 'rounded-sm',
39
+ md: 'rounded-md',
40
+ lg: 'rounded-lg',
41
+ xl: 'rounded-xl',
42
+ full: 'rounded-full',
43
+ };
44
+ var buttonRoundedClasses = {
45
+ none: 'rounded-none',
46
+ sm: 'rounded-sm',
47
+ md: 'rounded-md',
48
+ lg: 'rounded-lg',
49
+ xl: 'rounded-xl',
50
+ full: 'rounded-full',
51
+ };
52
+ var objectFitClasses = {
53
+ cover: 'object-cover',
54
+ contain: 'object-contain',
55
+ fill: 'object-fill',
56
+ none: 'object-none',
57
+ };
58
+ var objectPositionClasses = {
59
+ center: 'object-center',
60
+ top: 'object-top',
61
+ bottom: 'object-bottom',
62
+ left: 'object-left',
63
+ right: 'object-right',
64
+ };
65
+ var animationClasses = {
66
+ slide: "transition-transform duration-".concat(animationDuration),
67
+ fade: "transition-opacity duration-".concat(animationDuration),
68
+ zoom: "transform transition-transform duration-".concat(animationDuration),
69
+ none: '',
70
+ };
71
+ var goToNext = function () {
72
+ setPrevIndex(currentIndex);
73
+ setCurrentIndex(function (prev) {
74
+ var newIndex = prev === items.length - 1 ? (infiniteLoop ? 0 : prev) : prev + 1;
75
+ onSlideChange && onSlideChange(newIndex, prev);
76
+ return newIndex;
77
+ });
78
+ };
79
+ var goToPrev = function () {
80
+ setPrevIndex(currentIndex);
81
+ setCurrentIndex(function (prev) {
82
+ var newIndex = prev === 0 ? (infiniteLoop ? items.length - 1 : prev) : prev - 1;
83
+ onSlideChange && onSlideChange(newIndex, prev);
84
+ return newIndex;
85
+ });
86
+ };
87
+ var goToSlide = function (index) {
88
+ if (index === currentIndex)
89
+ return;
90
+ setPrevIndex(currentIndex);
91
+ setCurrentIndex(index);
92
+ onSlideChange && onSlideChange(index, currentIndex);
93
+ };
94
+ // Autoplay effet
95
+ useEffect(function () {
96
+ if (!autoplay || (pauseOnHover && isHovered) || items.length <= 1)
97
+ return;
98
+ var interval = setInterval(goToNext, autoplayInterval);
99
+ return function () { return clearInterval(interval); };
100
+ }, [autoplay, autoplayInterval, isHovered, items.length, pauseOnHover]);
101
+ if (!items || items.length === 0) {
102
+ return null;
103
+ }
104
+ // Renderovanie individuálneho slide
105
+ var renderDefaultItem = function (item, index) { return (React.createElement("div", { key: item.id, className: "min-w-full h-full relative ".concat(animation === 'fade' ? (index === currentIndex ? 'opacity-100' : 'opacity-0') : '') },
106
+ React.createElement("div", { className: "absolute inset-0 w-full h-full" },
107
+ React.createElement("img", { src: item.imageSrc, alt: item.imageAlt || item.title, className: buildClassesByJoining('w-full h-full', roundedClasses[rounded], objectFitClasses[objectFit], objectPositionClasses[objectPosition], imageClassName), style: { objectFit: objectFit } }),
108
+ withOverlay && (React.createElement("div", { className: buildClassesByJoining('absolute inset-0', overlayClasses[overlayStyle], roundedClasses[rounded]), style: item.overlayOpacity ? { opacity: item.overlayOpacity } : {} }))),
109
+ item.customContent || (React.createElement("div", { className: buildClassesByJoining('relative h-full w-full flex flex-col px-6', textPositionClasses[textPosition], textAlignmentClasses[textAlignment], contentClassName) },
110
+ React.createElement("h2", { className: buildClassesByJoining('text-3xl sm:text-4xl md:text-5xl font-bold text-white mb-2', titleClassName) }, item.title),
111
+ React.createElement("p", { className: buildClassesByJoining('text-xl text-white/80 max-w-2xl', subtitleClassName) }, item.subtitle),
112
+ item.buttonText && item.buttonLink && (React.createElement("a", { href: item.buttonLink, className: buildClassesByJoining('mt-4 px-6 py-2 bg-white text-black font-medium hover:bg-opacity-90 transition-colors inline-block', buttonRoundedClasses[buttonRounded], buttonClassName) }, item.buttonText)))))); };
113
+ // Pre jeden slide použijeme zjednodušený výstup
114
+ if (items.length === 1) {
115
+ var item = items[0];
116
+ return (React.createElement("div", { className: buildClassesByJoining('relative overflow-hidden w-full', heightClasses[height], roundedClasses[rounded], className) }, renderItem ? renderItem(item, 0) : renderDefaultItem(item, 0)));
117
+ }
118
+ // Pre viac slideov vytvoríme karusel
119
+ return (React.createElement("div", { className: buildClassesByJoining('relative overflow-hidden w-full', heightClasses[height], roundedClasses[rounded], className), onMouseEnter: function () { return pauseOnHover && setIsHovered(true); }, onMouseLeave: function () { return pauseOnHover && setIsHovered(false); } },
120
+ React.createElement("div", { className: buildClassesByJoining('flex h-full', animationClasses[animation]), style: animation === 'slide'
121
+ ? { transform: "translateX(-".concat(currentIndex * 100, "%)") }
122
+ : {} }, items.map(function (item, index) {
123
+ return renderItem ? renderItem(item, index) : renderDefaultItem(item, index);
124
+ })),
125
+ showArrows &&
126
+ items.length > 1 &&
127
+ (renderControls ? (renderControls(goToNext, goToPrev)) : (React.createElement(React.Fragment, null,
128
+ React.createElement("button", { onClick: goToPrev, className: buildClassesByJoining('absolute left-4 top-1/2 -translate-y-1/2 w-10 h-10 flex items-center justify-center rounded-full bg-black/30 hover:bg-black/50 text-white transition-colors', controlsClassName), "aria-label": "P\u0159edchoz\u00ED" },
129
+ React.createElement(ChevronLeftIcon, { className: "h-6 w-6" })),
130
+ React.createElement("button", { onClick: goToNext, className: buildClassesByJoining('absolute right-4 top-1/2 -translate-y-1/2 w-10 h-10 flex items-center justify-center rounded-full bg-black/30 hover:bg-black/50 text-white transition-colors', controlsClassName), "aria-label": "Dal\u0161\u00ED" },
131
+ React.createElement(ChevronRightIcon, { className: "h-6 w-6" }))))),
132
+ showDots &&
133
+ items.length > 1 &&
134
+ (renderIndicators ? (renderIndicators(currentIndex, items.length, goToSlide)) : (React.createElement("div", { className: buildClassesByJoining('absolute bottom-4 left-1/2 -translate-x-1/2 flex gap-2', indicatorsClassName) }, items.map(function (_, index) { return (React.createElement("button", { key: index, onClick: function () { return goToSlide(index); }, className: buildClassesByJoining('w-3 h-3 rounded-full transition-colors', index === currentIndex
135
+ ? 'bg-white'
136
+ : 'bg-white/40 hover:bg-white/60'), "aria-label": "P\u0159ej\u00EDt na slide ".concat(index + 1) })); }))))));
137
+ };
@@ -0,0 +1,7 @@
1
+ // src/components/Button.tsx
2
+ import React from 'react';
3
+ var Button = function (_a) {
4
+ var onClick = _a.onClick, label = _a.label, _b = _a.variant, variant = _b === void 0 ? 'primary' : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c;
5
+ return (React.createElement("button", { onClick: onClick, className: "px-4 py-2 rounded text-white cursor-pointer ".concat(variant === 'primary' ? 'bg-blue-500' : 'bg-gray-500', " ").concat(disabled ? 'opacity-50 cursor-not-allowed' : ''), disabled: disabled }, label));
6
+ };
7
+ export default Button;
@@ -0,0 +1,14 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import React from 'react';
13
+ export var CloseIcon = function (props) { return (React.createElement("svg", __assign({ width: 16, height: 16, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", className: props.className, onClick: props.onClick, onMouseDown: props.onMouseDown }, props),
14
+ React.createElement("path", { d: "M6 18L18 6M6 6l12 12", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" }))); };
@@ -0,0 +1,15 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import React from 'react';
13
+ export var InfoIcon = function (props) { return (React.createElement("svg", __assign({ className: "w-4 h-4 text-blue-600 ".concat(props.className || ''), fill: "none", stroke: "currentColor", strokeWidth: "2", viewBox: "0 0 24 24" }, props),
14
+ React.createElement("circle", { cx: "12", cy: "12", r: "10", stroke: "currentColor" }),
15
+ React.createElement("path", { d: "M12 8v4m0 4h.01", stroke: "currentColor" }))); };
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ var Label = function (_a) {
3
+ var text = _a.text, i18nKey = _a.i18nKey, isRequired = _a.isRequired, htmlFor = _a.htmlFor, subtitle = _a.subtitle, srOnly = _a.srOnly, _b = _a.className, className = _b === void 0 ? '' : _b;
4
+ if (!text && !i18nKey)
5
+ return null;
6
+ return (React.createElement("label", { htmlFor: htmlFor, className: "text-sm font-medium text-gray-700 flex flex-col ".concat(srOnly ? 'sr-only' : '', " ").concat(className) },
7
+ React.createElement("span", null, text || i18nKey),
8
+ isRequired && React.createElement("span", { className: "ml-1 text-red-500" }, "*"),
9
+ subtitle && React.createElement("span", { className: "text-xs text-gray-500" }, subtitle)));
10
+ };
11
+ export default Label;
@@ -0,0 +1,36 @@
1
+ 'use client';
2
+ import { Bars3Icon, XMarkIcon } from '@heroicons/react/24/outline';
3
+ import React, { useState } from 'react';
4
+ import buildClassesByJoining from '../../utils/StyleHelper';
5
+ export var NavBar = function (_a) {
6
+ var
7
+ // Structure
8
+ _b = _a.items,
9
+ // Structure
10
+ items = _b === void 0 ? [] : _b,
11
+ // Logo
12
+ _c = _a.logo,
13
+ // Logo
14
+ logo = _c === void 0 ? React.createElement("div", { className: "h-8 w-8 bg-indigo-600 rounded-md" }) : _c,
15
+ // Right side elements
16
+ rightContent = _a.rightContent,
17
+ // Styling
18
+ _d = _a.backgroundColor,
19
+ // Styling
20
+ backgroundColor = _d === void 0 ? 'bg-white' : _d, _e = _a.textColor, textColor = _e === void 0 ? 'text-gray-600' : _e, _f = _a.activeColor, activeColor = _f === void 0 ? 'text-indigo-600' : _f, _g = _a.mobileMenuBgColor, mobileMenuBgColor = _g === void 0 ? 'bg-white' : _g, _h = _a.containerClassName, containerClassName = _h === void 0 ? '' : _h, _j = _a.navClassName, navClassName = _j === void 0 ? '' : _j, _k = _a.itemClassName, itemClassName = _k === void 0 ? '' : _k, _l = _a.mobileItemClassName, mobileItemClassName = _l === void 0 ? '' : _l;
21
+ var _m = useState(false), mobileMenuOpen = _m[0], setMobileMenuOpen = _m[1];
22
+ return (React.createElement("header", { className: buildClassesByJoining(backgroundColor, containerClassName) },
23
+ React.createElement("nav", { className: buildClassesByJoining('mx-auto max-w-7xl px-4 sm:px-6 lg:px-8', navClassName) },
24
+ React.createElement("div", { className: "flex h-16 items-center justify-between" },
25
+ React.createElement("div", { className: "flex-shrink-0" }, logo),
26
+ React.createElement("div", { className: "flex md:hidden" },
27
+ React.createElement("button", { type: "button", className: buildClassesByJoining('inline-flex items-center justify-center rounded-md p-2', textColor, "hover:".concat(activeColor, " hover:bg-gray-100")), onClick: function () { return setMobileMenuOpen(!mobileMenuOpen); } },
28
+ React.createElement("span", { className: "sr-only" }, "Open main menu"),
29
+ mobileMenuOpen ? (React.createElement(XMarkIcon, { className: "block h-6 w-6", "aria-hidden": "true" })) : (React.createElement(Bars3Icon, { className: "block h-6 w-6", "aria-hidden": "true" })))),
30
+ React.createElement("div", { className: "hidden md:flex md:flex-1 md:items-center md:justify-center md:space-x-8" }, items.map(function (item) { return (React.createElement("a", { key: item.name, href: item.href, className: buildClassesByJoining('text-sm font-medium', textColor, "hover:".concat(activeColor), itemClassName) }, item.name)); })),
31
+ rightContent && (React.createElement("div", { className: "hidden md:flex md:items-center" }, rightContent)))),
32
+ mobileMenuOpen && (React.createElement("div", { className: buildClassesByJoining('md:hidden', mobileMenuBgColor) },
33
+ React.createElement("div", { className: "space-y-1 px-2 pb-3 pt-2" }, items.map(function (item) { return (React.createElement("a", { key: item.name, href: item.href, className: buildClassesByJoining('block rounded-md px-3 py-2 text-base font-medium', textColor, "hover:".concat(activeColor, " hover:bg-gray-100"), mobileItemClassName) }, item.name)); })),
34
+ rightContent && (React.createElement("div", { className: "border-t border-gray-200 pb-3 pt-4" },
35
+ React.createElement("div", { className: "flex items-center px-5" }, rightContent)))))));
36
+ };
@@ -0,0 +1,148 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { MinusIcon, PlusIcon } from '@heroicons/react/24/solid';
13
+ import React, { useState } from 'react';
14
+ import { buildClassesByJoining } from '../../utils/StyleHelper';
15
+ // Quantity Control Component
16
+ var QuantityControl = function (_a) {
17
+ var quantity = _a.quantity, onIncrement = _a.onIncrement, onDecrement = _a.onDecrement, _b = _a.minQuantity, minQuantity = _b === void 0 ? 0 : _b, _c = _a.maxQuantity, maxQuantity = _c === void 0 ? 99 : _c, _d = _a.controlsClassName, controlsClassName = _d === void 0 ? '' : _d, _e = _a.buttonClassName, buttonClassName = _e === void 0 ? '' : _e, _f = _a.quantityClassName, quantityClassName = _f === void 0 ? '' : _f;
18
+ return (React.createElement("div", { className: buildClassesByJoining('flex items-center gap-2', controlsClassName) },
19
+ React.createElement("button", { onClick: onDecrement, disabled: quantity <= minQuantity, className: buildClassesByJoining('w-8 h-8 flex items-center justify-center rounded-full bg-red-500 text-white hover:bg-red-600 disabled:opacity-50 disabled:bg-red-300 disabled:cursor-not-allowed shadow-sm transition-all duration-200', buttonClassName), "aria-label": "Decrease quantity" },
20
+ React.createElement(MinusIcon, { className: "h-4 w-4" })),
21
+ React.createElement("div", { className: buildClassesByJoining('w-8 h-8 rounded-full bg-white flex items-center justify-center text-sm font-medium shadow-sm transition-all duration-200', quantityClassName) }, quantity),
22
+ React.createElement("button", { onClick: onIncrement, disabled: quantity >= maxQuantity, className: buildClassesByJoining('w-8 h-8 flex items-center justify-center rounded-full bg-green-500 text-white hover:bg-green-600 disabled:opacity-50 disabled:bg-green-300 disabled:cursor-not-allowed shadow-sm transition-all duration-200', buttonClassName), "aria-label": "Increase quantity" },
23
+ React.createElement(PlusIcon, { className: "h-4 w-4" }))));
24
+ };
25
+ export var ProductCard = function (_a) {
26
+ var product = _a.product, className = _a.className, imageClassName = _a.imageClassName, contentClassName = _a.contentClassName, titleClassName = _a.titleClassName, colorClassName = _a.colorClassName, priceClassName = _a.priceClassName, descriptionClassName = _a.descriptionClassName, badgeClassName = _a.badgeClassName, _b = _a.aspectRatio, aspectRatio = _b === void 0 ? 'square' : _b, _c = _a.imagePosition, imagePosition = _c === void 0 ? 'center' : _c, _d = _a.imageObjectFit, imageObjectFit = _d === void 0 ? 'cover' : _d, _e = _a.layout, layout = _e === void 0 ? 'default' : _e, _f = _a.hoverEffect, hoverEffect = _f === void 0 ? 'opacity' : _f, _g = _a.renderBadges, renderBadges = _g === void 0 ? true : _g, _h = _a.renderColor, renderColor = _h === void 0 ? true : _h, _j = _a.renderDescription, renderDescription = _j === void 0 ? false : _j, _k = _a.elevationLevel, elevationLevel = _k === void 0 ? 0 : _k, _l = _a.rounded, rounded = _l === void 0 ? 'md' : _l, _m = _a.titleLines, titleLines = _m === void 0 ? 1 : _m, onCardClick = _a.onCardClick, onImageClick = _a.onImageClick, renderFooter = _a.renderFooter, renderHeader = _a.renderHeader, actionButton = _a.actionButton,
27
+ // Add to cart functionality
28
+ _o = _a.showAddButton,
29
+ // Add to cart functionality
30
+ showAddButton = _o === void 0 ? false : _o, _p = _a.initialQuantity, initialQuantity = _p === void 0 ? 0 : _p, onQuantityChange = _a.onQuantityChange, _q = _a.addButtonIcon, addButtonIcon = _q === void 0 ? React.createElement(PlusIcon, { className: "h-4 w-4" }) : _q, _r = _a.maxQuantity, maxQuantity = _r === void 0 ? 99 : _r, _s = _a.quantityControlProps, quantityControlProps = _s === void 0 ? {} : _s, customAddButton = _a.customAddButton, customQuantityControl = _a.customQuantityControl;
31
+ var _t = useState(initialQuantity), quantity = _t[0], setQuantity = _t[1];
32
+ var _u = useState(initialQuantity > 0), showQuantityControls = _u[0], setShowQuantityControls = _u[1];
33
+ // Create aspect ratio class
34
+ var aspectRatioClass = {
35
+ square: 'aspect-square',
36
+ auto: 'aspect-auto',
37
+ video: 'aspect-video',
38
+ wide: 'aspect-[16/9]',
39
+ }[aspectRatio];
40
+ // Create object-fit class
41
+ var objectFitClass = {
42
+ cover: 'object-cover',
43
+ contain: 'object-contain',
44
+ fill: 'object-fill',
45
+ none: 'object-none',
46
+ }[imageObjectFit];
47
+ // Create object-position class
48
+ var objectPositionClass = {
49
+ top: 'object-top',
50
+ center: 'object-center',
51
+ bottom: 'object-bottom',
52
+ }[imagePosition];
53
+ // Create hover effect class
54
+ var hoverClass = {
55
+ opacity: 'group-hover:opacity-75',
56
+ scale: 'transform transition-transform group-hover:scale-105',
57
+ shadow: 'transition-shadow group-hover:shadow-lg',
58
+ border: 'border border-transparent group-hover:border-primary-500',
59
+ none: '',
60
+ }[hoverEffect];
61
+ // Create shadow elevation class
62
+ var elevationClass = {
63
+ 0: '',
64
+ 1: 'shadow-sm',
65
+ 2: 'shadow',
66
+ 3: 'shadow-md',
67
+ }[elevationLevel];
68
+ // Create rounded class
69
+ var roundedClass = {
70
+ none: 'rounded-none',
71
+ sm: 'rounded-sm',
72
+ md: 'rounded-md',
73
+ lg: 'rounded-lg',
74
+ full: 'rounded-full',
75
+ }[rounded];
76
+ // Create title line clamp class
77
+ var titleLineClampClass = {
78
+ 1: 'line-clamp-1',
79
+ 2: 'line-clamp-2',
80
+ 3: 'line-clamp-3',
81
+ }[titleLines];
82
+ // Create layout class
83
+ var layoutClass = layout === 'horizontal' ? 'flex gap-4' : '';
84
+ var imageLayoutClass = layout === 'horizontal' ? 'w-1/3' : 'w-full';
85
+ var contentLayoutClass = layout === 'horizontal' ? 'w-2/3' : 'w-full';
86
+ var compactClass = layout === 'compact' ? 'space-y-1' : 'space-y-2';
87
+ var handleCardClick = function () {
88
+ onCardClick && onCardClick(product);
89
+ };
90
+ var handleImageClick = function (e) {
91
+ if (onImageClick) {
92
+ e.stopPropagation();
93
+ onImageClick(product);
94
+ }
95
+ };
96
+ var handleAddToCart = function (e) {
97
+ e.stopPropagation(); // Prevent card click
98
+ setShowQuantityControls(true);
99
+ setQuantity(1);
100
+ onQuantityChange && onQuantityChange(product, 1);
101
+ };
102
+ var handleIncrement = function (e) {
103
+ e.stopPropagation(); // Prevent card click
104
+ var newQuantity = Math.min(quantity + 1, maxQuantity);
105
+ setQuantity(newQuantity);
106
+ onQuantityChange && onQuantityChange(product, newQuantity);
107
+ };
108
+ var handleDecrement = function (e) {
109
+ e.stopPropagation(); // Prevent card click
110
+ var newQuantity = Math.max(quantity - 1, 0);
111
+ if (newQuantity === 0) {
112
+ setQuantity(0);
113
+ // Use timeout to allow animation to play before hiding
114
+ setTimeout(function () {
115
+ setShowQuantityControls(false);
116
+ }, 300);
117
+ }
118
+ else {
119
+ setQuantity(newQuantity);
120
+ }
121
+ onQuantityChange && onQuantityChange(product, newQuantity);
122
+ };
123
+ return (React.createElement("div", { key: product.id, className: buildClassesByJoining('group relative', layoutClass, elevationClass, onCardClick ? 'cursor-pointer' : '', className), onClick: handleCardClick },
124
+ renderHeader && renderHeader(product),
125
+ React.createElement("div", { className: buildClassesByJoining(imageLayoutClass, 'relative') },
126
+ product.badges && renderBadges && (React.createElement("div", { className: "absolute top-2 left-2 z-10 flex flex-wrap gap-1" }, product.badges.map(function (badge, index) { return (React.createElement("span", { key: index, className: buildClassesByJoining("inline-flex items-center px-2 py-1 text-xs font-medium ".concat(badge.color), roundedClass, badgeClassName) }, badge.text)); }))),
127
+ React.createElement("img", { alt: product.imageAlt, src: product.imageSrc, className: buildClassesByJoining(aspectRatioClass, objectFitClass, objectPositionClass, hoverEffect !== 'none' ? hoverClass : '', roundedClass, 'bg-gray-200', onImageClick ? 'cursor-pointer' : '', imageClassName), onClick: handleImageClick }),
128
+ (showAddButton || showQuantityControls) && (React.createElement("div", { className: buildClassesByJoining('absolute bottom-2 right-2 z-10'), onClick: function (e) { return e.stopPropagation(); } },
129
+ React.createElement("div", { className: "relative" },
130
+ React.createElement("div", { className: buildClassesByJoining('transition-all duration-300 ease-in-out transform', showQuantityControls
131
+ ? 'scale-0 opacity-0'
132
+ : 'scale-100 opacity-100') }, customAddButton || (React.createElement("button", { onClick: handleAddToCart, className: buildClassesByJoining('p-2 w-10 h-10 flex items-center justify-center rounded-full bg-green-500 text-white shadow-md hover:bg-green-600 transition-colors duration-200'), "aria-label": "Add to cart" }, addButtonIcon))),
133
+ React.createElement("div", { className: buildClassesByJoining('absolute top-0 right-0 transition-all duration-300 ease-in-out transform origin-right', !showQuantityControls
134
+ ? 'scale-0 opacity-0'
135
+ : 'scale-100 opacity-100') }, customQuantityControl || (React.createElement(QuantityControl, __assign({ quantity: quantity, onIncrement: handleIncrement, onDecrement: handleDecrement, minQuantity: 0, maxQuantity: maxQuantity }, quantityControlProps)))))))),
136
+ React.createElement("div", { className: buildClassesByJoining('mt-4', contentLayoutClass, compactClass, contentClassName) },
137
+ React.createElement("div", { className: "flex justify-between" },
138
+ React.createElement("div", null,
139
+ React.createElement("h3", { className: buildClassesByJoining('text-sm text-gray-700', titleLineClampClass, titleClassName) },
140
+ React.createElement("a", { href: product.href },
141
+ !onCardClick && (React.createElement("span", { "aria-hidden": "true", className: "absolute inset-0" })),
142
+ product.name)),
143
+ renderColor && product.color && (React.createElement("p", { className: buildClassesByJoining('mt-1 text-sm text-gray-500', colorClassName) }, product.color)),
144
+ renderDescription && product.description && (React.createElement("p", { className: buildClassesByJoining('mt-1 text-sm text-gray-500 line-clamp-2', descriptionClassName) }, product.description))),
145
+ React.createElement("p", { className: buildClassesByJoining('text-sm font-medium text-gray-900', priceClassName) }, product.price)),
146
+ actionButton && React.createElement("div", { className: "mt-2" }, actionButton),
147
+ renderFooter && renderFooter(product))));
148
+ };
@@ -0,0 +1,132 @@
1
+ 'use client';
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ import { buildClassesByJoining } from '../../utils/StyleHelper';
25
+ import React, { forwardRef, isValidElement, useId } from 'react';
26
+ import ReactSelect from 'react-select';
27
+ import Badge from '../badge/Badge';
28
+ import { CloseIcon } from '../icon/CloseIcon';
29
+ import { InfoIcon } from '../icon/InfoIcon';
30
+ import Label from '../label/Label';
31
+ import Tooltip from '../tooltip/Tooltip';
32
+ import SelectFieldOption from './SelectFieldOption';
33
+ function SelectFieldComponent(_a, ref) {
34
+ var _b;
35
+ var _c, _d;
36
+ var id = _a.id, label = _a.label, isRequired = _a.isRequired, srOnlyLabel = _a.srOnlyLabel, _e = _a.selectFieldType, selectFieldType = _e === void 0 ? 'default' : _e, subtitle = _a.subtitle, _f = _a.size, size = _f === void 0 ? 'md' : _f, _g = _a.color, color = _g === void 0 ? 'primary' : _g, _h = _a.valid, valid = _h === void 0 ? true : _h, className = _a.className, message = _a.message, _j = _a.placeholder, placeholder = _j === void 0 ? selectFieldType === 'table' ? '...' : '' : _j, _k = _a.isSearchable, isSearchable = _k === void 0 ? false : _k, removePaddingTop = _a.removePaddingTop, _l = _a.menuPosition, menuPosition = _l === void 0 ? 'fixed' : _l, renderMessageInTooltip = _a.renderMessageInTooltip, tooltipRef = _a.tooltipRef, disablePortal = _a.disablePortal, tooltipMessage = _a.tooltipMessage, isMulti = _a.isMulti, _m = _a.typeSelect, typeSelect = _m === void 0 ? isMulti ? 'multi' : 'single' : _m, badgeLabelClassName = _a.badgeLabelClassName, customStyles = _a.styles, props = __rest(_a, ["id", "label", "isRequired", "srOnlyLabel", "selectFieldType", "subtitle", "size", "color", "valid", "className", "message", "placeholder", "isSearchable", "removePaddingTop", "menuPosition", "renderMessageInTooltip", "tooltipRef", "disablePortal", "tooltipMessage", "isMulti", "typeSelect", "badgeLabelClassName", "styles"]);
37
+ var randomId = useId();
38
+ var isMultiSelect = typeSelect === 'multi';
39
+ var renderMessage = function () {
40
+ return message && React.createElement("span", { className: "text-xs mt-1 block text-gray-500" }, message);
41
+ };
42
+ var containerClassName = buildClassesByJoining((_b = {
43
+ invalid: !valid
44
+ },
45
+ _b[color] = true,
46
+ _b[size] = true,
47
+ _b.selector = true,
48
+ _b['!pt-0'] = removePaddingTop,
49
+ _b['shadow-sm'] = selectFieldType === 'table',
50
+ _b['font-medium'] = selectFieldType === 'table',
51
+ _b), className, 'flex flex-col gap-2');
52
+ var testAttributes = {
53
+ 'data-test-element': 'select',
54
+ 'data-test-element-type': typeSelect === 'multi' ? 'multi-select' : 'single-select',
55
+ 'data-test-name': props === null || props === void 0 ? void 0 : props.name,
56
+ 'data-test-selected-label': (_c = props === null || props === void 0 ? void 0 : props.value) === null || _c === void 0 ? void 0 : _c.label,
57
+ 'data-test-selected-value': (_d = props === null || props === void 0 ? void 0 : props.value) === null || _d === void 0 ? void 0 : _d.value,
58
+ 'data-test-is-disabled': props === null || props === void 0 ? void 0 : props.isDisabled,
59
+ };
60
+ var renderOptionBadge = function (_a) {
61
+ var children = _a.children, removeProps = _a.removeProps;
62
+ return (React.createElement(Badge, { color: "bg-blue-100 text-blue-800", rightIcon: React.createElement(CloseIcon, { onMouseDown: function (event) {
63
+ event.preventDefault();
64
+ event.stopPropagation();
65
+ }, onClick: function (event) {
66
+ event.preventDefault();
67
+ event.stopPropagation();
68
+ if (removeProps && typeof removeProps.onClick === 'function') {
69
+ removeProps.onClick(event);
70
+ }
71
+ }, className: "w-4 h-4 cursor-pointer" }), className: "m-1", labelClassName: badgeLabelClassName }, children));
72
+ };
73
+ var getMultiValueComponent = function (props) {
74
+ var selectedValues = props.getValue();
75
+ if (selectFieldType === 'table') {
76
+ return (props.index === 0 && (React.createElement(React.Fragment, null,
77
+ renderOptionBadge(props),
78
+ selectedValues.length > 1 && (React.createElement(Badge, { color: "bg-blue-100 text-blue-800", className: "m-1" },
79
+ React.createElement("span", null,
80
+ "+",
81
+ selectedValues.length - 1))))));
82
+ }
83
+ return renderOptionBadge(props);
84
+ };
85
+ var renderInput = function () {
86
+ var _a;
87
+ var getBaseStyles = function () { return (__assign(__assign({}, customStyles), { indicatorSeparator: function (base) { return (__assign(__assign({}, base), { display: 'none' })); }, placeholder: function (base) { return (__assign(__assign({}, base), { opacity: 0.4, fontWeight: 'normal', fontSize: selectFieldType === 'table' ? '1rem' : '0.75rem' })); }, control: function (base) { return (__assign(__assign({}, base), { paddingLeft: selectFieldType === 'table' ? '4px' : '0' })); }, dropdownIndicator: function (base, state) { return (__assign(__assign({}, base), { opacity: state.isFocused || state.selectProps.menuIsOpen ? 1 : 0.4 })); }, singleValue: function (base) {
88
+ if (typeSelect !== 'single-badges') {
89
+ return base;
90
+ }
91
+ return __assign(__assign({}, base), { backgroundColor: '#E5EFFE', border: '0.063rem solid #A0AEC0', color: '#374151 !important', padding: '0.125rem 0.625rem', fontSize: '0.75rem', borderRadius: '6px', width: 'fit-content' });
92
+ } })); };
93
+ var commonProps = {
94
+ id: id || randomId,
95
+ instanceId: id || randomId,
96
+ isSearchable: isSearchable,
97
+ className: buildClassesByJoining((_a = {},
98
+ _a[size] = true,
99
+ _a), 'selector-container'),
100
+ menuPortalTarget: typeof document !== 'undefined' && menuPosition === 'fixed' && !disablePortal
101
+ ? document.body
102
+ : undefined,
103
+ classNamePrefix: 'selector',
104
+ placeholder: placeholder,
105
+ menuPosition: menuPosition,
106
+ openMenuOnFocus: true,
107
+ openMenuOnClick: true,
108
+ noOptionsMessage: function () { return (React.createElement("div", { className: "text-gray-500 text-sm" }, "No options available")); },
109
+ };
110
+ return (React.createElement(React.Fragment, null,
111
+ React.createElement("div", __assign({}, testAttributes), isMultiSelect ? (React.createElement(ReactSelect, __assign({}, props, commonProps, { styles: getBaseStyles(), isMulti: true, ref: ref, components: {
112
+ Option: SelectFieldOption,
113
+ MultiValue: getMultiValueComponent,
114
+ } }))) : (React.createElement(ReactSelect, __assign({}, props, commonProps, { styles: getBaseStyles(), isMulti: false, ref: ref, components: {
115
+ Option: SelectFieldOption,
116
+ MultiValue: getMultiValueComponent,
117
+ } })))),
118
+ !renderMessageInTooltip && renderMessage()));
119
+ };
120
+ var renderTooltip = function () {
121
+ return (React.createElement("span", { className: "flex items-center gap-1 pb-1" },
122
+ React.createElement(Tooltip, { placement: "top", content: tooltipMessage, contentClassName: "max-w-64" },
123
+ React.createElement(InfoIcon, null))));
124
+ };
125
+ return (React.createElement("div", { className: containerClassName },
126
+ (!!(label === null || label === void 0 ? void 0 : label.length) || isValidElement(tooltipMessage)) && (React.createElement("div", { className: "flex gap-1" },
127
+ React.createElement(Label, { text: label, isRequired: isRequired, htmlFor: randomId, subtitle: subtitle, srOnly: srOnlyLabel }),
128
+ tooltipMessage && renderTooltip())),
129
+ React.createElement("div", { className: "flex flex-col relative" }, renderMessageInTooltip ? (React.createElement(Tooltip, { content: message, backgroundColor: !valid ? 'bg-red-500' : 'bg-blue-500', textColor: "text-white", ref: tooltipRef, disabled: !renderMessageInTooltip || !message, lazy: false }, renderInput())) : (renderInput()))));
130
+ }
131
+ var SelectField = forwardRef(SelectFieldComponent);
132
+ export default SelectField;
@@ -0,0 +1,31 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import React from 'react';
24
+ import { components } from 'react-select';
25
+ var SelectFieldOption = function (_a) {
26
+ var children = _a.children, data = _a.data, props = __rest(_a, ["children", "data"]);
27
+ var optionData = data;
28
+ return (React.createElement(components.Option, __assign({}, props, { data: data }),
29
+ React.createElement("span", { "data-test-option": JSON.stringify(optionData), "data-test-option-value": optionData.value, "data-test-option-label": optionData.label }, children)));
30
+ };
31
+ export default SelectFieldOption;