@q2devel/q2-storybook 1.0.12 → 1.0.13

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 (35) hide show
  1. package/dist/components/badge/Badge.js +1 -0
  2. package/dist/components/banner/Banner.d.ts +48 -0
  3. package/dist/components/banner/Banner.js +137 -0
  4. package/dist/components/basket-dialog/BasketDialog.d.ts +55 -0
  5. package/dist/components/basket-dialog/BasketDialog.js +167 -0
  6. package/dist/components/icon/CloseIcon.d.ts +3 -0
  7. package/dist/components/icon/CloseIcon.js +14 -0
  8. package/dist/components/icon/InfoIcon.d.ts +3 -0
  9. package/dist/components/icon/InfoIcon.js +15 -0
  10. package/dist/components/label/Label.d.ts +12 -0
  11. package/dist/components/label/Label.js +11 -0
  12. package/dist/components/nav-bar/NavBar.d.ts +19 -0
  13. package/dist/components/nav-bar/NavBar.js +36 -0
  14. package/dist/components/product-card/ProductCard.d.ts +61 -0
  15. package/dist/components/product-card/ProductCard.js +148 -0
  16. package/dist/components/select-field/SelectField.d.ts +27 -0
  17. package/dist/components/select-field/SelectField.js +132 -0
  18. package/dist/components/select-field/SelectFieldOption.d.ts +5 -0
  19. package/dist/components/select-field/SelectFieldOption.js +31 -0
  20. package/dist/components/text-field/TextField.d.ts +21 -0
  21. package/dist/components/text-field/TextField.js +87 -0
  22. package/dist/components/text-field/TextField.types.d.ts +22 -0
  23. package/dist/components/text-field/TextField.types.js +1 -0
  24. package/dist/components/tooltip/Tooltip.d.ts +18 -0
  25. package/dist/components/tooltip/Tooltip.js +18 -0
  26. package/dist/global.css +1 -0
  27. package/dist/index.d.ts +7 -1
  28. package/dist/index.js +7 -2
  29. package/dist/utils/Helper.d.ts +0 -0
  30. package/dist/utils/Helper.js +1 -0
  31. package/dist/utils/StyleHelper.d.ts +4 -0
  32. package/dist/utils/StyleHelper.js +12 -0
  33. package/package.json +10 -3
  34. package/dist/components/heading/Heading.d.ts +0 -6
  35. package/dist/components/heading/Heading.js +0 -6
@@ -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,27 @@
1
+ import React, { ReactNode, Ref } from 'react';
2
+ import { GroupBase, Props, SelectInstance } from 'react-select';
3
+ import { TooltipRef } from '../tooltip/Tooltip';
4
+ export type SelectFieldSize = 'sm' | 'md' | 'xs' | 'border-sm';
5
+ export type SelectFieldProps<Option, Group extends GroupBase<Option> = GroupBase<Option>, IsMulti extends boolean = false> = Omit<Props<Option, IsMulti, Group>, 'className' | 'classNamePrefix' | 'loadOptions'> & {
6
+ label?: string;
7
+ isRequired?: boolean;
8
+ srOnlyLabel?: boolean;
9
+ subtitle?: string;
10
+ color?: string;
11
+ valid?: boolean;
12
+ size?: SelectFieldSize;
13
+ message?: string;
14
+ className?: string;
15
+ removePaddingTop?: boolean;
16
+ renderMessageInTooltip?: boolean;
17
+ selectFieldType?: 'table' | 'default';
18
+ placeholder?: string;
19
+ tooltipRef?: Ref<TooltipRef>;
20
+ disablePortal?: boolean;
21
+ tooltipMessage?: ReactNode;
22
+ typeSelect?: 'single' | 'multi' | 'single-badges';
23
+ badgeLabelClassName?: string;
24
+ };
25
+ export type SelectFieldRefType<Option, Group extends GroupBase<Option>, IsMulti extends boolean = false> = SelectInstance<Option, IsMulti, Group>;
26
+ declare const SelectField: <Option = unknown, Group extends GroupBase<Option> = GroupBase<Option>, IsMulti extends boolean = false>(props: SelectFieldProps<Option, Group, IsMulti> & React.RefAttributes<SelectFieldRefType<Option, Group, IsMulti>>) => React.JSX.Element;
27
+ export default SelectField;
@@ -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,5 @@
1
+ import React from 'react';
2
+ import { GroupBase, OptionProps } from 'react-select';
3
+ export type SelectFieldOptionProps<Option = unknown, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>> = OptionProps<Option, IsMulti, Group>;
4
+ declare const SelectFieldOption: <Option = unknown, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>({ children, data, ...props }: SelectFieldOptionProps<Option, IsMulti, Group>) => React.JSX.Element;
5
+ export default SelectFieldOption;
@@ -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;
@@ -0,0 +1,21 @@
1
+ import { MouseEvent } from 'react';
2
+ import { TextFieldType } from './TextField.types';
3
+ import React from 'react';
4
+ declare const _default: React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "children" | "type" | "size"> & {
5
+ label?: string | React.ReactNode;
6
+ labelColor?: string;
7
+ variant?: import("./TextField.types").TextFieldVariant;
8
+ labelType?: import("./TextField.types").TextFieldLabelType;
9
+ type?: TextFieldType;
10
+ size?: import("./TextField.types").TextFieldSize;
11
+ valid?: boolean;
12
+ message?: string | React.ReactNode;
13
+ messageColor?: string;
14
+ background?: string;
15
+ leftIcon?: React.ReactNode;
16
+ rightIcon?: React.ReactNode;
17
+ onLeftIconClick?: (event: MouseEvent<HTMLButtonElement>) => void;
18
+ onRightIconClick?: (event: MouseEvent<HTMLButtonElement>) => void;
19
+ showPasswordEyeIcon?: boolean;
20
+ } & React.RefAttributes<HTMLInputElement>>;
21
+ export default _default;
@@ -0,0 +1,87 @@
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 { EyeIcon, EyeSlashIcon } from '@heroicons/react/24/outline';
26
+ import { forwardRef, useCallback, useId, useMemo, useState } from 'react';
27
+ import React from 'react';
28
+ var TextField = function (_a, ref) {
29
+ var idProp = _a.id, _b = _a.type, typeProp = _b === void 0 ? 'text' : _b, label = _a.label, _c = _a.labelColor, labelColor = _c === void 0 ? 'text-gray-700' : _c, _d = _a.labelType, labelType = _d === void 0 ? 'outside' : _d, _e = _a.variant, variant = _e === void 0 ? 'rounded' : _e, _f = _a.size, size = _f === void 0 ? 'md' : _f, _g = _a.color, color = _g === void 0 ? 'primary' : _g, _h = _a.background, background = _h === void 0 ? 'bg-white' : _h, _j = _a.autoComplete, autoComplete = _j === void 0 ? 'off' : _j, _k = _a.valid, valid = _k === void 0 ? true : _k, message = _a.message, _l = _a.messageColor, messageColor = _l === void 0 ? 'text-gray-500' : _l, leftIcon = _a.leftIcon, rightIcon = _a.rightIcon, onLeftIconClick = _a.onLeftIconClick, onRightIconClick = _a.onRightIconClick, _m = _a.showPasswordEyeIcon, showPasswordEyeIcon = _m === void 0 ? true : _m, props = __rest(_a, ["id", "type", "label", "labelColor", "labelType", "variant", "size", "color", "background", "autoComplete", "valid", "message", "messageColor", "leftIcon", "rightIcon", "onLeftIconClick", "onRightIconClick", "showPasswordEyeIcon"]);
30
+ var id = useId();
31
+ var errorColor = 'text-red-500';
32
+ var _o = useState(false), showPassword = _o[0], setShowPassword = _o[1];
33
+ var type = useMemo(function () { return (typeProp === 'password' && showPassword ? 'text' : typeProp); }, [typeProp, showPassword]);
34
+ var toggleShowPassword = useCallback(function (event) {
35
+ setShowPassword(function (prev) { return !prev; });
36
+ if (onRightIconClick)
37
+ onRightIconClick(event);
38
+ }, [onRightIconClick]);
39
+ var variantClasses = {
40
+ normal: 'border',
41
+ rounded: 'border rounded-md',
42
+ flat: 'border-b focus-within:border-b-2 focus-within:ring-0 shadow-none',
43
+ };
44
+ var sizeClasses = {
45
+ sm: 'py-0.5 px-3',
46
+ md: 'py-2 px-3',
47
+ };
48
+ var labelTypeClasses = {
49
+ outside: 'block text-sm font-medium',
50
+ inside: 'block text-xs font-medium text-gray-900',
51
+ overlapping: 'absolute -top-2 left-2 -mt-px inline-block px-1 bg-white text-xs font-medium text-gray-900',
52
+ hidden: 'sr-only',
53
+ };
54
+ var containerClasses = buildClassesByJoining('relative border-gray-300 shadow-sm focus-within:ring-1', !valid
55
+ ? 'border-red-500 focus-within:ring-red-500'
56
+ : "focus-within:ring-".concat(color, "-500 focus-within:border-").concat(color, "-500"), variantClasses[variant], sizeClasses[size], background, labelType === 'outside' && 'mt-1');
57
+ var renderLeftIcon = function () {
58
+ if (!leftIcon)
59
+ return null;
60
+ return (React.createElement("span", { className: buildClassesByJoining('absolute inset-y-0 left-0 pl-3 flex items-center', labelType === 'inside' && 'mt-4'), onClick: onLeftIconClick ? onLeftIconClick : undefined }, leftIcon));
61
+ };
62
+ var renderRightIcon = function () {
63
+ if (!rightIcon && !(typeProp === 'password' && showPasswordEyeIcon))
64
+ return null;
65
+ var icon = rightIcon;
66
+ if (typeProp === 'password' && showPasswordEyeIcon) {
67
+ var IconComponent = showPassword ? EyeIcon : EyeSlashIcon;
68
+ icon = (React.createElement(IconComponent, { className: buildClassesByJoining('h-5 w-5', !valid ? 'text-red-500' : 'text-gray-400') }));
69
+ }
70
+ return (React.createElement("span", { className: "absolute inset-y-0 right-0 pr-3 flex items-center cursor-pointer", onClick: toggleShowPassword }, icon));
71
+ };
72
+ var renderLabel = function () {
73
+ if (!label)
74
+ return null;
75
+ return (React.createElement("label", { htmlFor: id, className: buildClassesByJoining(labelTypeClasses[labelType], !valid ? errorColor : labelColor) }, label));
76
+ };
77
+ return (React.createElement("div", { className: "min-h-[80px]" },
78
+ labelType === 'outside' && renderLabel(),
79
+ React.createElement("div", { className: containerClasses },
80
+ (labelType === 'overlapping' || labelType === 'inside' || labelType === 'hidden') &&
81
+ renderLabel(),
82
+ renderLeftIcon(),
83
+ renderRightIcon(),
84
+ React.createElement("input", __assign({}, props, { ref: ref, id: id, autoComplete: autoComplete, type: type, className: buildClassesByJoining('block w-full border-0 p-0 text-gray-900 placeholder-gray-500 focus:ring-0 sm:text-sm bg-transparent outline-none', !!leftIcon && 'pl-6', !!rightIcon && 'pr-6') }))),
85
+ message && (React.createElement("p", { className: buildClassesByJoining('mt-1.5 text-sm', !valid ? errorColor : messageColor) }, message))));
86
+ };
87
+ export default forwardRef(TextField);
@@ -0,0 +1,22 @@
1
+ import React, { MouseEvent } from 'react';
2
+ export type TextFieldSize = 'sm' | 'md';
3
+ export type TextFieldLabelType = 'outside' | 'inside' | 'overlapping' | 'hidden';
4
+ export type TextFieldVariant = 'normal' | 'rounded' | 'flat';
5
+ export type TextFieldType = 'text' | 'password' | 'email' | 'number' | 'date' | 'file';
6
+ export type TextFieldProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'children' | 'type' | 'size'> & {
7
+ label?: string | React.ReactNode;
8
+ labelColor?: string;
9
+ variant?: TextFieldVariant;
10
+ labelType?: TextFieldLabelType;
11
+ type?: TextFieldType;
12
+ size?: TextFieldSize;
13
+ valid?: boolean;
14
+ message?: string | React.ReactNode;
15
+ messageColor?: string;
16
+ background?: string;
17
+ leftIcon?: React.ReactNode;
18
+ rightIcon?: React.ReactNode;
19
+ onLeftIconClick?: (event: MouseEvent<HTMLButtonElement>) => void;
20
+ onRightIconClick?: (event: MouseEvent<HTMLButtonElement>) => void;
21
+ showPasswordEyeIcon?: boolean;
22
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { ReactNode } from 'react';
3
+ export interface TooltipRef {
4
+ show: () => void;
5
+ hide: () => void;
6
+ }
7
+ interface TooltipProps {
8
+ content?: ReactNode;
9
+ children: ReactNode;
10
+ backgroundColor?: string;
11
+ textColor?: string;
12
+ placement?: 'top' | 'bottom' | 'left' | 'right';
13
+ contentClassName?: string;
14
+ disabled?: boolean;
15
+ lazy?: boolean;
16
+ }
17
+ declare const Tooltip: React.ForwardRefExoticComponent<TooltipProps & React.RefAttributes<TooltipRef>>;
18
+ export default Tooltip;
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { forwardRef } from 'react';
3
+ var Tooltip = forwardRef(function (_a, ref) {
4
+ var content = _a.content, children = _a.children, _b = _a.backgroundColor, backgroundColor = _b === void 0 ? 'bg-black' : _b, _c = _a.textColor, textColor = _c === void 0 ? 'text-white' : _c, _d = _a.placement, placement = _d === void 0 ? 'bottom' : _d, _e = _a.contentClassName, contentClassName = _e === void 0 ? '' : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.lazy, lazy = _g === void 0 ? true : _g;
5
+ if (disabled)
6
+ return React.createElement(React.Fragment, null, children);
7
+ return (React.createElement("span", { className: "relative group cursor-pointer" },
8
+ children,
9
+ content && (React.createElement("span", { className: "absolute z-10 hidden group-hover:block\n ".concat(placement === 'top'
10
+ ? 'bottom-full mb-2'
11
+ : placement === 'bottom'
12
+ ? 'top-full mt-2'
13
+ : placement === 'left'
14
+ ? 'right-full mr-2'
15
+ : 'left-full ml-2', "\n left-1/2 -translate-x-1/2 px-3 py-2 rounded ").concat(backgroundColor, " ").concat(textColor, "\n text-xs whitespace-pre-wrap ").concat(contentClassName) }, content))));
16
+ });
17
+ Tooltip.displayName = 'Tooltip';
18
+ export default Tooltip;
@@ -0,0 +1 @@
1
+ @import "tailwindcss";
package/dist/index.d.ts CHANGED
@@ -1,3 +1,9 @@
1
- export { default as Button } from './components/button/Button';
2
1
  export { default as Badge } from './components/badge/Badge';
2
+ export { Banner } from './components/banner/Banner';
3
+ export { default as Button } from './components/button/Button';
4
+ export { NavBar } from './components/nav-bar/NavBar';
5
+ export { ProductCard } from './components/product-card/ProductCard';
6
+ export { default as SelectField } from './components/select-field/SelectField';
7
+ export { default as TextField } from './components/text-field/TextField';
3
8
  export { default as ImageWithText } from './components/text-with-image/ImageWithText';
9
+ export { buildClassesByJoining } from './utils/StyleHelper';
package/dist/index.js CHANGED
@@ -1,4 +1,9 @@
1
- // src/index.ts
2
- export { default as Button } from './components/button/Button';
3
1
  export { default as Badge } from './components/badge/Badge';
2
+ export { Banner } from './components/banner/Banner';
3
+ export { default as Button } from './components/button/Button';
4
+ export { NavBar } from './components/nav-bar/NavBar';
5
+ export { ProductCard } from './components/product-card/ProductCard';
6
+ export { default as SelectField } from './components/select-field/SelectField';
7
+ export { default as TextField } from './components/text-field/TextField';
4
8
  export { default as ImageWithText } from './components/text-with-image/ImageWithText';
9
+ export { buildClassesByJoining } from './utils/StyleHelper';
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,4 @@
1
+ import { twMerge } from 'tailwind-merge';
2
+ export declare const buildClassesByJoining: (...args: any[]) => string;
3
+ export { twMerge };
4
+ export default buildClassesByJoining;
@@ -0,0 +1,12 @@
1
+ import classNames from 'classnames';
2
+ import { twMerge } from 'tailwind-merge';
3
+ export var buildClassesByJoining = function () {
4
+ var args = [];
5
+ for (var _i = 0; _i < arguments.length; _i++) {
6
+ args[_i] = arguments[_i];
7
+ }
8
+ var combinedClasses = classNames.apply(void 0, args);
9
+ return twMerge(combinedClasses);
10
+ };
11
+ export { twMerge };
12
+ export default buildClassesByJoining;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@q2devel/q2-storybook",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,7 +17,8 @@
17
17
  "test": "echo \"Error: no test specified\" && exit 1",
18
18
  "storybook": "storybook dev -p 6006",
19
19
  "build-storybook": "storybook build",
20
- "build": "tsc"
20
+ "build": "tsc",
21
+ "prepublishOnly": "npm run build"
21
22
  },
22
23
  "keywords": [],
23
24
  "author": "Q2",
@@ -33,6 +34,7 @@
33
34
  "@storybook/react": "^8.6.12",
34
35
  "@storybook/react-vite": "^8.6.12",
35
36
  "@storybook/test": "^8.6.12",
37
+ "@types/classnames": "^2.3.0",
36
38
  "@types/node": "^22.14.1",
37
39
  "@types/react": "^19.1.2",
38
40
  "@types/react-dom": "^19.1.2",
@@ -49,7 +51,12 @@
49
51
  "react-dom": "^19.0.0"
50
52
  },
51
53
  "dependencies": {
54
+ "@headlessui/react": "^2.2.2",
55
+ "@heroicons/react": "^2.2.0",
52
56
  "@tailwindcss/postcss": "^4.1.4",
53
- "html-react-parser": "^5.2.3"
57
+ "classnames": "^2.5.1",
58
+ "html-react-parser": "^5.2.3",
59
+ "react-select": "^5.10.1",
60
+ "tailwind-merge": "^3.2.0"
54
61
  }
55
62
  }
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- interface HeadingProps {
3
- text: string;
4
- }
5
- declare const Heading: React.FC<HeadingProps>;
6
- export default Heading;