krl-alfred 1.84.0 → 2.17.4
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/components/ActionButton/ActionButton.styled.js +2 -1
- package/dist/components/Icon/iconList/Pause.d.ts +2 -0
- package/dist/components/Icon/iconList/Pause.js +40 -0
- package/dist/components/Icon/iconList/Play.js +1 -1
- package/dist/components/Icon/iconList/VolumeOffSm.d.ts +2 -0
- package/dist/components/Icon/iconList/VolumeOffSm.js +40 -0
- package/dist/components/Icon/iconList/VolumeUpSm.d.ts +2 -0
- package/dist/components/Icon/iconList/VolumeUpSm.js +40 -0
- package/dist/components/Icon/iconList/index.d.ts +15 -3
- package/dist/components/Icon/iconList/index.js +24 -6
- package/dist/components/ProductCardHorizontal/props.d.ts +11 -6
- package/dist/components/ReviewBlock/ReviewBlock.styled.js +2 -1
- package/dist/components/ReviewCard/ReviewCard.styled.js +2 -2
- package/dist/components/SearchBox/SearchBox.d.ts +3 -2
- package/dist/components/SearchBox/SearchBox.js +111 -36
- package/dist/components/SearchBox/SearchBox.styled.d.ts +1 -1
- package/dist/components/SearchBox/SearchBox.styled.js +27 -6
- package/dist/components/SearchBox/props.d.ts +35 -13
- package/dist/components/SearchBox/props.js +11 -7
- package/dist/components/SearchBox/stories/SearchBox.stories.d.ts +3 -2
- package/dist/components/Tabs/Tabs.d.ts +1 -1
- package/dist/components/Tabs/Tabs.js +8 -8
- package/dist/components/Tabs/Tabs.styled.d.ts +1 -1
- package/dist/components/Tabs/Tabs.styled.js +2 -2
- package/dist/components/Tabs/props.d.ts +2 -0
- package/dist/components/Tabs/props.js +1 -0
- package/dist/components/VideoCard/VideoCard.d.ts +1 -4
- package/dist/components/VideoCard/VideoCard.js +38 -2
- package/dist/components/VideoCard/VideoCard.styled.d.ts +3 -0
- package/dist/components/VideoCard/VideoCard.styled.js +7 -4
- package/dist/components/VideoCard/props.d.ts +1 -2
- package/dist/components/VideoCard/stories/VideoCard.stories.d.ts +1 -1
- package/dist/components/VideoCard/stories/VideoCard.stories.js +2 -2
- package/dist/hooks/useDebounce.d.ts +2 -0
- package/dist/hooks/useDebounce.js +16 -0
- package/dist/hooks/useVideoPlayer.d.ts +6 -0
- package/dist/hooks/useVideoPlayer.js +63 -0
- package/dist/style/style.min.css +1 -1
- package/dist/style/style.min.css.map +1 -1
- package/package.json +1 -1
|
@@ -10,68 +10,143 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
13
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
38
|
};
|
|
16
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
40
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
|
-
var react_1 = require("react");
|
|
41
|
+
var react_1 = __importStar(require("react"));
|
|
19
42
|
var props_1 = require("./props");
|
|
20
43
|
var SearchBox_styled_1 = require("./SearchBox.styled");
|
|
21
44
|
var Icon_1 = __importDefault(require("../Icon/Icon"));
|
|
22
45
|
var simplebar_react_1 = __importDefault(require("simplebar-react"));
|
|
23
46
|
var react_i18next_1 = require("react-i18next");
|
|
24
47
|
var ProductCardHorizontal_1 = __importDefault(require("../ProductCardHorizontal"));
|
|
25
|
-
var SearchBox = function (_a) {
|
|
26
|
-
var _b
|
|
48
|
+
var SearchBox = react_1.default.forwardRef(function (_a, ref) {
|
|
49
|
+
var _b;
|
|
50
|
+
var _c = _a.onKeyUp, onKeyUp = _c === void 0 ? props_1.SearchBoxDefault.onKeyUp : _c, _d = _a.onBlur, onBlur = _d === void 0 ? props_1.SearchBoxDefault.onBlur : _d, _e = _a.onFocus, onFocus = _e === void 0 ? props_1.SearchBoxDefault.onFocus : _e, _f = _a.onChange, onChange = _f === void 0 ? props_1.SearchBoxDefault.onChange : _f, _g = _a.onButtonClick, onButtonClick = _g === void 0 ? props_1.SearchBoxDefault.onButtonClick : _g, children = _a.children, _h = _a.isLoading, isLoading = _h === void 0 ? props_1.SearchBoxDefault.isLoading : _h, _j = _a.showResultList, showResultList = _j === void 0 ? props_1.SearchBoxDefault.showResultList : _j, _k = _a.placeholder, placeholder = _k === void 0 ? props_1.SearchBoxDefault.placeholder : _k, _l = _a.size, size = _l === void 0 ? props_1.SearchBoxDefault.size : _l, _m = _a.value, value = _m === void 0 ? props_1.SearchBoxDefault.value : _m, _o = _a.maxResultHeight, maxResultHeight = _o === void 0 ? props_1.SearchBoxDefault.maxResultHeight : _o, _p = _a.minSearchLength, minSearchLength = _p === void 0 ? props_1.SearchBoxDefault.minSearchLength : _p, _q = _a.ariaLabel, ariaLabel = _q === void 0 ? props_1.SearchBoxDefault.ariaLabel : _q, _r = _a.id, id = _r === void 0 ? "searchbox" : _r, _s = _a.disabled, disabled = _s === void 0 ? props_1.SearchBoxDefault.disabled : _s, className = _a.className;
|
|
27
51
|
var t = (0, react_i18next_1.useTranslation)().t;
|
|
28
|
-
var resultRef = (0, react_1.useRef)();
|
|
52
|
+
var resultRef = (0, react_1.useRef)(null);
|
|
29
53
|
var simplebarRef = (0, react_1.useRef)(null);
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
54
|
+
var innerRef = (0, react_1.useRef)(null);
|
|
55
|
+
var _t = (0, react_1.useState)(null), selectedIndex = _t[0], setSelectedIndex = _t[1];
|
|
56
|
+
// Forward the ref while maintaining internal ref
|
|
57
|
+
var handleRef = function (element) {
|
|
58
|
+
innerRef.current = element;
|
|
59
|
+
if (typeof ref === 'function') {
|
|
60
|
+
ref(element);
|
|
36
61
|
}
|
|
37
|
-
else {
|
|
38
|
-
|
|
62
|
+
else if (ref) {
|
|
63
|
+
ref.current = element;
|
|
39
64
|
}
|
|
40
65
|
};
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var charCode = e.keyCode || e.which;
|
|
45
|
-
if ([38, 40].includes(charCode)) {
|
|
46
|
-
e.preventDefault();
|
|
47
|
-
// 38 up , 40 down
|
|
48
|
-
var list_1 = (_a = resultRef === null || resultRef === void 0 ? void 0 : resultRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".productCard");
|
|
49
|
-
if (list_1.length > 0) {
|
|
50
|
-
setSelectedIndex(function (prev) { return charCode === 38 ? prev === 0 ? 0 : prev - 1 : prev === list_1.length - 1 ? list_1.length - 1 : prev === null ? 0 : prev + 1; });
|
|
51
|
-
}
|
|
66
|
+
var handleKeyUp = (0, react_1.useCallback)(function (e) {
|
|
67
|
+
if (![38, 40, 13].includes(e.keyCode)) {
|
|
68
|
+
onKeyUp(e);
|
|
52
69
|
}
|
|
53
70
|
else {
|
|
54
|
-
|
|
71
|
+
e.preventDefault();
|
|
55
72
|
}
|
|
56
|
-
};
|
|
73
|
+
}, [onKeyUp]);
|
|
74
|
+
var handleKeyDown = (0, react_1.useCallback)(function (e) {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
if (!showResultList)
|
|
77
|
+
return;
|
|
78
|
+
var list = (_a = resultRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".productCard");
|
|
79
|
+
if (!(list === null || list === void 0 ? void 0 : list.length))
|
|
80
|
+
return;
|
|
81
|
+
switch (e.keyCode) {
|
|
82
|
+
case 38: // up
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
setSelectedIndex(function (prev) {
|
|
85
|
+
return prev === null ? list.length - 1 :
|
|
86
|
+
prev === 0 ? 0 : prev - 1;
|
|
87
|
+
});
|
|
88
|
+
break;
|
|
89
|
+
case 40: // down
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
setSelectedIndex(function (prev) {
|
|
92
|
+
return prev === null ? 0 :
|
|
93
|
+
prev === list.length - 1 ? list.length - 1 : prev + 1;
|
|
94
|
+
});
|
|
95
|
+
break;
|
|
96
|
+
case 13: // enter
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
if (selectedIndex !== null) {
|
|
99
|
+
list[selectedIndex].click();
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
case 27: // escape
|
|
103
|
+
e.preventDefault();
|
|
104
|
+
(_b = innerRef.current) === null || _b === void 0 ? void 0 : _b.blur();
|
|
105
|
+
break;
|
|
106
|
+
default:
|
|
107
|
+
setSelectedIndex(null);
|
|
108
|
+
}
|
|
109
|
+
}, [showResultList, selectedIndex]);
|
|
57
110
|
(0, react_1.useEffect)(function () {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
111
|
+
if (!resultRef.current || selectedIndex === null)
|
|
112
|
+
return;
|
|
113
|
+
var list = resultRef.current.querySelectorAll(".productCard");
|
|
114
|
+
list.forEach(function (el, index) {
|
|
61
115
|
var _a;
|
|
62
116
|
if (index === selectedIndex) {
|
|
63
117
|
el.classList.add("selected");
|
|
64
|
-
(_a = simplebarRef.current
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
118
|
+
var scrollContainer = (_a = simplebarRef.current) === null || _a === void 0 ? void 0 : _a.el.querySelector('.simplebar-content-wrapper');
|
|
119
|
+
if (scrollContainer) {
|
|
120
|
+
var elementTop = el.offsetTop;
|
|
121
|
+
var elementHeight = el.offsetHeight;
|
|
122
|
+
var containerHeight = scrollContainer.clientHeight;
|
|
123
|
+
var scrollTop = scrollContainer.scrollTop;
|
|
124
|
+
if (elementTop < scrollTop) {
|
|
125
|
+
scrollContainer.scrollTo({
|
|
126
|
+
top: elementTop,
|
|
127
|
+
behavior: 'smooth'
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
else if (elementTop + elementHeight > scrollTop + containerHeight) {
|
|
131
|
+
scrollContainer.scrollTo({
|
|
132
|
+
top: elementTop + elementHeight - containerHeight,
|
|
133
|
+
behavior: 'smooth'
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
69
137
|
}
|
|
70
138
|
else {
|
|
71
139
|
el.classList.remove("selected");
|
|
72
140
|
}
|
|
73
141
|
});
|
|
74
142
|
}, [selectedIndex]);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
143
|
+
var shouldShowResults = showResultList &&
|
|
144
|
+
(!minSearchLength || ((_b = value === null || value === void 0 ? void 0 : value.length) !== null && _b !== void 0 ? _b : 0) >= minSearchLength);
|
|
145
|
+
return ((0, jsx_runtime_1.jsxs)(SearchBox_styled_1.SearchBoxStyled, __assign({ "$showResultList": shouldShowResults, "$size": size, "$disabled": disabled, className: className }, { children: [(0, jsx_runtime_1.jsx)("div", { className: "shadowBox" }), (0, jsx_runtime_1.jsxs)("div", __assign({ className: "inputWrapper" }, { children: [(0, jsx_runtime_1.jsx)("input", { ref: handleRef, type: "text", id: id, "aria-label": ariaLabel, "aria-expanded": shouldShowResults, "aria-controls": shouldShowResults ? "".concat(id, "-results") : undefined, "aria-activedescendant": selectedIndex !== null ? "".concat(id, "-result-").concat(selectedIndex) : undefined, role: "combobox", placeholder: placeholder, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onBlur: onBlur, onFocus: onFocus, value: value, onChange: onChange, disabled: disabled, autoComplete: "off" }), (0, jsx_runtime_1.jsx)("button", __assign({ onClick: onButtonClick, className: "icon", "aria-label": t("SEARCH"), disabled: disabled }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: "Searchsmall" }) }))] })), shouldShowResults && ((0, jsx_runtime_1.jsx)("div", __assign({ ref: resultRef, className: "resultList", id: "".concat(id, "-results"), role: "listbox" }, { children: (0, jsx_runtime_1.jsx)("div", __assign({ className: "resultListInner" }, { children: (0, jsx_runtime_1.jsx)(simplebar_react_1.default, __assign({ ref: simplebarRef, autoHide: false, style: { maxHeight: maxResultHeight } }, { children: isLoading ? (Array.from({ length: 4 }, function (_, index) { return ((0, jsx_runtime_1.jsx)("div", __assign({ className: "productCard", "data-id": "".concat(id, "-result-").concat(index), "data-role": "option", "data-selected": selectedIndex === index }, { children: (0, jsx_runtime_1.jsx)(ProductCardHorizontal_1.default, { hasLoading: true }) }), index)); })) : (react_1.default.Children.map(children, function (child, index) {
|
|
146
|
+
if (!react_1.default.isValidElement(child))
|
|
147
|
+
return child;
|
|
148
|
+
return ((0, jsx_runtime_1.jsx)("div", __assign({ className: "productCard", "data-id": "".concat(id, "-result-").concat(index), "data-role": "option", "data-selected": selectedIndex === index, tabIndex: -1 }, { children: child }), index));
|
|
149
|
+
})) })) })) })))] })));
|
|
150
|
+
});
|
|
151
|
+
SearchBox.displayName = 'SearchBox';
|
|
152
|
+
exports.default = react_1.default.memo(SearchBox);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SearchBoxStyledProps } from "./props";
|
|
3
3
|
export declare const SearchBoxStyled: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, SearchBoxStyledProps>> & string;
|
|
4
|
-
export declare const LoadingStyled: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components
|
|
4
|
+
export declare const LoadingStyled: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
@@ -3,13 +3,34 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
3
3
|
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
4
|
return cooked;
|
|
5
5
|
};
|
|
6
|
-
var
|
|
7
|
-
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
+
if (mod && mod.__esModule) return mod;
|
|
24
|
+
var result = {};
|
|
25
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
+
__setModuleDefault(result, mod);
|
|
27
|
+
return result;
|
|
8
28
|
};
|
|
9
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
30
|
exports.LoadingStyled = exports.SearchBoxStyled = void 0;
|
|
11
|
-
var styled_components_1 =
|
|
31
|
+
var styled_components_1 = __importStar(require("styled-components"));
|
|
12
32
|
var devices_1 = require("../../constants/devices");
|
|
13
|
-
|
|
14
|
-
exports.
|
|
15
|
-
|
|
33
|
+
var disabledStyles = (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n opacity: 0.6;\n pointer-events: none;\n cursor: not-allowed;\n"], ["\n opacity: 0.6;\n pointer-events: none;\n cursor: not-allowed;\n"])));
|
|
34
|
+
exports.SearchBoxStyled = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n width: 100%;\n\n .shadowBox {\n height: 48px;\n position: absolute;\n width: calc(100% - 10px);\n left: 50%;\n transform: translateX(-50%);\n border-radius: 0.5rem;\n box-shadow: ", ";\n display: ", ";\n @media only screen and ", " {\n box-shadow: 0 0 16px 0 var(--icon-shadow-color);\n }\n }\n\n .inputWrapper {\n position: relative;\n z-index: 5;\n border-radius: 0.5rem;\n input {\n box-sizing: border-box;\n width: 100%;\n height: 48px;\n background: white;\n border-radius: 0.5rem;\n border: 1px solid var(--dark-opacity-10);\n padding: 8px 54px 8px 24px;\n color: var(--dark);\n font: var(--body-medium-14-17);\n line-height: normal;\n outline: none;\n transition: all 0.2s ease;\n\n &::placeholder {\n color: var(--dark-opacity-50);\n }\n\n &:disabled {\n ", ";\n background-color: var(--dark-opacity-5);\n }\n }\n\n .icon {\n position: absolute;\n right: 1rem;\n top: 50%;\n transform: translateY(-50%);\n width: 32px;\n height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n background: transparent;\n border: 0;\n outline: none;\n cursor: pointer;\n padding: 0;\n color: var(--primary);\n &:hover{\n color: var(--primary-hover);\n }\n }\n }\n\n .resultList {\n padding: 0;\n border-radius: 0.5rem;\n background: white;\n box-sizing: border-box;\n position: absolute;\n top: 100%;\n left: 0;\n right: 0;\n z-index: 4;\n display: grid;\n row-gap: 1.5rem;\n &:before{\n content: \"\";\n height: calc(100% + 48px);\n position: absolute;\n width: calc(100% - 10px);\n left: 50%;\n bottom: 0;\n transform: translateX(-50%);\n border-radius: inherit;\n box-shadow: ", ";\n user-select: none;\n pointer-events: none;\n @media only screen and ", " {\n box-shadow: 0 0 16px 0 var(--icon-shadow-color);\n }\n }\n\n .resultListInner {\n position: relative;\n overflow: hidden;\n border-radius: inherit;\n border: 1px solid var(--dark-opacity-10);\n\n [data-simplebar] {\n height: auto !important;\n max-height: 408px !important;\n padding: 1.5rem !important;\n position: relative;\n z-index: 1;\n background-color: white;\n\n .simplebar-track.simplebar-vertical {\n width: 9px !important;\n }\n }\n\n .productCard {\n border-radius: 0.5rem;\n transition: all 0.2s ease;\n outline: none;\n\n &:is(.selected) {\n background: var(--dark-opacity-3);\n }\n\n &:focus-visible {\n box-shadow: 0 0 0 2px var(--primary-opacity-20);\n }\n }\n\n ", "\n\n @media only screen and ", " {\n row-gap: 0.5rem;\n max-height: 326px;\n [data-simplebar] {\n max-height: 326px !important;\n }\n }\n }\n }\n\n ", "\n"], ["\n position: relative;\n width: 100%;\n\n .shadowBox {\n height: 48px;\n position: absolute;\n width: calc(100% - 10px);\n left: 50%;\n transform: translateX(-50%);\n border-radius: 0.5rem;\n box-shadow: ", ";\n display: ", ";\n @media only screen and ", " {\n box-shadow: 0 0 16px 0 var(--icon-shadow-color);\n }\n }\n\n .inputWrapper {\n position: relative;\n z-index: 5;\n border-radius: 0.5rem;\n input {\n box-sizing: border-box;\n width: 100%;\n height: 48px;\n background: white;\n border-radius: 0.5rem;\n border: 1px solid var(--dark-opacity-10);\n padding: 8px 54px 8px 24px;\n color: var(--dark);\n font: var(--body-medium-14-17);\n line-height: normal;\n outline: none;\n transition: all 0.2s ease;\n\n &::placeholder {\n color: var(--dark-opacity-50);\n }\n\n &:disabled {\n ", ";\n background-color: var(--dark-opacity-5);\n }\n }\n\n .icon {\n position: absolute;\n right: 1rem;\n top: 50%;\n transform: translateY(-50%);\n width: 32px;\n height: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n background: transparent;\n border: 0;\n outline: none;\n cursor: pointer;\n padding: 0;\n color: var(--primary);\n &:hover{\n color: var(--primary-hover);\n }\n }\n }\n\n .resultList {\n padding: 0;\n border-radius: 0.5rem;\n background: white;\n box-sizing: border-box;\n position: absolute;\n top: 100%;\n left: 0;\n right: 0;\n z-index: 4;\n display: grid;\n row-gap: 1.5rem;\n &:before{\n content: \"\";\n height: calc(100% + 48px);\n position: absolute;\n width: calc(100% - 10px);\n left: 50%;\n bottom: 0;\n transform: translateX(-50%);\n border-radius: inherit;\n box-shadow: ", ";\n user-select: none;\n pointer-events: none;\n @media only screen and ", " {\n box-shadow: 0 0 16px 0 var(--icon-shadow-color);\n }\n }\n\n .resultListInner {\n position: relative;\n overflow: hidden;\n border-radius: inherit;\n border: 1px solid var(--dark-opacity-10);\n\n [data-simplebar] {\n height: auto !important;\n max-height: 408px !important;\n padding: 1.5rem !important;\n position: relative;\n z-index: 1;\n background-color: white;\n\n .simplebar-track.simplebar-vertical {\n width: 9px !important;\n }\n }\n\n .productCard {\n border-radius: 0.5rem;\n transition: all 0.2s ease;\n outline: none;\n\n &:is(.selected) {\n background: var(--dark-opacity-3);\n }\n\n &:focus-visible {\n box-shadow: 0 0 0 2px var(--primary-opacity-20);\n }\n }\n\n ", "\n\n @media only screen and ", " {\n row-gap: 0.5rem;\n max-height: 326px;\n [data-simplebar] {\n max-height: 326px !important;\n }\n }\n }\n }\n\n ", "\n"])), function (props) { return props.$size === "small" ? "0 0 16px 0 var(--icon-shadow-color)" : "0 6px 30px 0 var(--icon-shadow-color)"; }, function (props) { return props.$showResultList ? "none" : "block"; }, devices_1.devices.xl, disabledStyles, function (props) { return props.$size === "small" ? "0 0 16px 0 var(--icon-shadow-color)" : "0 6px 30px 0 var(--icon-shadow-color)"; }, devices_1.devices.xl, function (props) { return props.$size === "small" && (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n row-gap: 0.5rem;\n max-height: 326px;\n [data-simplebar] {\n max-height: 326px !important;\n }\n "], ["\n row-gap: 0.5rem;\n max-height: 326px;\n [data-simplebar] {\n max-height: 326px !important;\n }\n "]))); }, devices_1.devices.xl, function (props) { return props.$disabled && disabledStyles; });
|
|
35
|
+
exports.LoadingStyled = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n text-align: center;\n display: flex;\n align-items: center;\n justify-content: flex-start;\n"], ["\n text-align: center;\n display: flex;\n align-items: center;\n justify-content: flex-start;\n"])));
|
|
36
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
@@ -1,23 +1,45 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const sizes:
|
|
3
|
-
type
|
|
4
|
-
export interface
|
|
5
|
-
size
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
export declare const sizes: readonly ["medium", "small"];
|
|
3
|
+
export type Size = typeof sizes[number];
|
|
4
|
+
export interface SearchBoxProps {
|
|
5
|
+
/** The size variant of the search box */
|
|
6
|
+
size?: Size;
|
|
7
|
+
/** Handler for keyup events */
|
|
8
|
+
onKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
9
|
+
/** Handler for blur events */
|
|
10
|
+
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
11
|
+
/** Handler for focus events */
|
|
12
|
+
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
13
|
+
/** Handler for change events */
|
|
14
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
15
|
+
/** Handler for search button click */
|
|
16
|
+
onButtonClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
17
|
+
/** Content to be rendered in the result list */
|
|
11
18
|
children?: React.ReactNode;
|
|
19
|
+
/** Whether the search is currently loading */
|
|
12
20
|
isLoading?: boolean;
|
|
21
|
+
/** Whether to show the result list */
|
|
13
22
|
showResultList?: boolean;
|
|
23
|
+
/** Placeholder text for the input */
|
|
14
24
|
placeholder?: string;
|
|
25
|
+
/** Current value of the input */
|
|
15
26
|
value?: string;
|
|
27
|
+
/** Maximum height of the result list in pixels */
|
|
28
|
+
maxResultHeight?: number;
|
|
29
|
+
/** Minimum characters required before showing results */
|
|
30
|
+
minSearchLength?: number;
|
|
31
|
+
/** ARIA label for the search input */
|
|
32
|
+
ariaLabel?: string;
|
|
33
|
+
/** ID for the search input (for accessibility) */
|
|
34
|
+
id?: string;
|
|
35
|
+
/** Whether the search box is disabled */
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
/** Custom class name for the root element */
|
|
38
|
+
className?: string;
|
|
16
39
|
}
|
|
17
40
|
export interface SearchBoxStyledProps {
|
|
18
41
|
$showResultList?: boolean;
|
|
19
|
-
$size?:
|
|
42
|
+
$size?: Size;
|
|
43
|
+
$disabled?: boolean;
|
|
20
44
|
}
|
|
21
|
-
export declare const SearchBoxDefault:
|
|
22
|
-
export type SearchBoxProps = typeof SearchBoxDefault;
|
|
23
|
-
export {};
|
|
45
|
+
export declare const SearchBoxDefault: Required<Omit<SearchBoxProps, 'children' | 'className' | 'id'>>;
|
|
@@ -4,13 +4,17 @@ exports.SearchBoxDefault = exports.sizes = void 0;
|
|
|
4
4
|
exports.sizes = ['medium', 'small'];
|
|
5
5
|
exports.SearchBoxDefault = {
|
|
6
6
|
size: "medium",
|
|
7
|
-
onKeyUp:
|
|
8
|
-
onBlur:
|
|
9
|
-
onFocus:
|
|
10
|
-
onChange:
|
|
11
|
-
onButtonClick:
|
|
12
|
-
children: null,
|
|
7
|
+
onKeyUp: function () { },
|
|
8
|
+
onBlur: function () { },
|
|
9
|
+
onFocus: function () { },
|
|
10
|
+
onChange: function () { },
|
|
11
|
+
onButtonClick: function () { },
|
|
13
12
|
isLoading: false,
|
|
14
13
|
showResultList: false,
|
|
15
|
-
placeholder: "Teknolojik ürün ara..."
|
|
14
|
+
placeholder: "Teknolojik ürün ara...",
|
|
15
|
+
value: "",
|
|
16
|
+
maxResultHeight: 408,
|
|
17
|
+
minSearchLength: 2,
|
|
18
|
+
ariaLabel: "Search",
|
|
19
|
+
disabled: false
|
|
16
20
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
declare const _default: {
|
|
2
3
|
title: string;
|
|
3
|
-
component:
|
|
4
|
+
component: React.MemoExoticComponent<React.ForwardRefExoticComponent<import("../props").SearchBoxProps & React.RefAttributes<HTMLInputElement>>>;
|
|
4
5
|
tags: string[];
|
|
5
6
|
argTypes: {
|
|
6
7
|
size: {
|
|
7
8
|
control: string;
|
|
8
|
-
options:
|
|
9
|
+
options: readonly ["medium", "small"];
|
|
9
10
|
};
|
|
10
11
|
};
|
|
11
12
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TabsProps } from "./props";
|
|
2
2
|
declare const Tabs: {
|
|
3
|
-
({ activeIndex, children, onActive, hasAutoFlex, size, }: TabsProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
({ activeIndex, children, onActive, hasAutoFlex, isHideTabHeaderOnMobile, size, }: TabsProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
TabItem: ({ isActive, hasAutoFlex, size, isDisabled, title, children, key, onClick, }: import("./props").TabItem) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
};
|
|
6
6
|
export default Tabs;
|
|
@@ -44,9 +44,9 @@ var Tabs_styled_1 = require("./Tabs.styled");
|
|
|
44
44
|
var TabContext_1 = require("./TabContext");
|
|
45
45
|
var TabItem_1 = __importDefault(require("./TabItem"));
|
|
46
46
|
var Tabs = function (_a) {
|
|
47
|
-
var _b = _a.activeIndex, activeIndex = _b === void 0 ? props_1.TabsDefault.activeIndex : _b, _c = _a.children, children = _c === void 0 ? props_1.TabsDefault.children : _c, _d = _a.onActive, onActive = _d === void 0 ? props_1.TabsDefault.onActive : _d, _e = _a.hasAutoFlex, hasAutoFlex = _e === void 0 ? props_1.TabsDefault.hasAutoFlex : _e, _f = _a.size, size =
|
|
48
|
-
var
|
|
49
|
-
var
|
|
47
|
+
var _b = _a.activeIndex, activeIndex = _b === void 0 ? props_1.TabsDefault.activeIndex : _b, _c = _a.children, children = _c === void 0 ? props_1.TabsDefault.children : _c, _d = _a.onActive, onActive = _d === void 0 ? props_1.TabsDefault.onActive : _d, _e = _a.hasAutoFlex, hasAutoFlex = _e === void 0 ? props_1.TabsDefault.hasAutoFlex : _e, _f = _a.isHideTabHeaderOnMobile, isHideTabHeaderOnMobile = _f === void 0 ? props_1.TabsDefault.isHideTabHeaderOnMobile : _f, _g = _a.size, size = _g === void 0 ? props_1.TabsDefault.size : _g;
|
|
48
|
+
var _h = (0, react_1.useState)(activeIndex || 0), tabActiveIndex = _h[0], setTabActiveIndex = _h[1];
|
|
49
|
+
var _j = (0, react_1.useState)(null), activeContent = _j[0], setActiveContent = _j[1];
|
|
50
50
|
(0, react_1.useEffect)(function () {
|
|
51
51
|
setTabActiveIndex(activeIndex);
|
|
52
52
|
}, [activeIndex]);
|
|
@@ -67,21 +67,21 @@ var Tabs = function (_a) {
|
|
|
67
67
|
};
|
|
68
68
|
}, [tabActiveIndex, activeIndex]);
|
|
69
69
|
(0, react_1.useEffect)(function () {
|
|
70
|
-
var _a, _b
|
|
70
|
+
var _a, _b;
|
|
71
71
|
if (window && typeof window !== "undefined") {
|
|
72
72
|
var elem = (_a = window === null || window === void 0 ? void 0 : window.document) === null || _a === void 0 ? void 0 : _a.querySelector(".tabHeader");
|
|
73
73
|
var activeItem = (_b = window === null || window === void 0 ? void 0 : window.document) === null || _b === void 0 ? void 0 : _b.querySelector(".customTabItem.isActive");
|
|
74
74
|
if (activeItem && elem) {
|
|
75
|
-
|
|
76
|
-
elem.scrollLeft =
|
|
75
|
+
activeItem.scrollIntoView({ behavior: 'smooth', inline: 'center', block: 'nearest' });
|
|
76
|
+
//elem.scrollLeft = activeItem?.offsetLeft - (window.innerWidth / 2) + (activeItem?.getBoundingClientRect()?.width / 2);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
|
-
return ((0, jsx_runtime_1.jsxs)(Tabs_styled_1.TabsStyled, { children: [(0, jsx_runtime_1.jsx)(Tabs_styled_1.TabHeaderStyled, __assign({ "$size": size, "$hasAutoFlex": hasAutoFlex, className: "tabHeader" }, { children: children === null || children === void 0 ? void 0 : children.map(function (child, index) { return ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: (0, jsx_runtime_1.jsx)(TabContext_1.TabsContext.Provider, __assign({ value: getTabsContext(index) }, { children: child
|
|
80
|
+
return ((0, jsx_runtime_1.jsxs)(Tabs_styled_1.TabsStyled, { children: [(0, jsx_runtime_1.jsx)(Tabs_styled_1.TabHeaderStyled, __assign({ "$size": size, "$hasAutoFlex": hasAutoFlex, "$isHideTabHeaderOnMobile": isHideTabHeaderOnMobile, className: "tabHeader" }, { children: children === null || children === void 0 ? void 0 : children.map(function (child, index) { return ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: (0, jsx_runtime_1.jsx)(TabContext_1.TabsContext.Provider, __assign({ value: getTabsContext(index) }, { children: child
|
|
81
81
|
? // cloneElement is needed for backward compatibility with custom
|
|
82
82
|
// styled components that rely on active. We should reassess
|
|
83
83
|
// if it is still necessary in our next major release.
|
|
84
|
-
react_1.default.cloneElement(child, { isActive: activeIndex === index, hasAutoFlex: hasAutoFlex, size: size }) : child })) }, index)); }) })), (0, jsx_runtime_1.jsx)(Tabs_styled_1.TabItemContentStyled, __assign({ className: "active-tab-".concat(activeIndex) }, { children: activeContent }))] }));
|
|
84
|
+
react_1.default.cloneElement(child, { isActive: activeIndex === index, hasAutoFlex: hasAutoFlex, size: size }) : child })) }, index)); }) })), (0, jsx_runtime_1.jsx)(Tabs_styled_1.TabItemContentStyled, __assign({ "$size": size, className: "active-tab-".concat(activeIndex) }, { children: activeContent }))] }));
|
|
85
85
|
};
|
|
86
86
|
Tabs.TabItem = TabItem_1.default;
|
|
87
87
|
exports.default = Tabs;
|
|
@@ -4,4 +4,4 @@ export declare const TabsStyled: import("styled-components/dist/types").IStyledC
|
|
|
4
4
|
export declare const TabHeaderStyled: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, TabStyledProps>> & string;
|
|
5
5
|
export declare const TabItemStyled: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, TabItemStyledProps>> & string;
|
|
6
6
|
export declare const TabItemTitleStyled: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, TabItemStyledProps>> & string;
|
|
7
|
-
export declare const TabItemContentStyled: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>,
|
|
7
|
+
export declare const TabItemContentStyled: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, TabItemStyledProps>> & string;
|
|
@@ -11,8 +11,8 @@ exports.TabItemContentStyled = exports.TabItemTitleStyled = exports.TabItemStyle
|
|
|
11
11
|
var styled_components_1 = __importDefault(require("styled-components"));
|
|
12
12
|
var devices_1 = require("../../constants/devices");
|
|
13
13
|
exports.TabsStyled = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\n"], ["\n\n"])));
|
|
14
|
-
exports.TabHeaderStyled = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: ", ";\n column-gap: ", ";\n ", "\n"], ["\n display: flex;\n align-items: center;\n justify-content: ", ";\n column-gap: ", ";\n ", "\n"])), function (props) { return props.$hasAutoFlex ? "center" : "flex-start"; }, function (props) { return props.$size === "large" ? "1.5rem" : "1rem"; }, function (props) { return !props.$hasAutoFlex && "\n scroll-snap-type: x proximity;\n -webkit-overflow-scrolling: touch;\n scrollbar-width: none;\n overflow-x: scroll;\n padding: 2rem;\n margin: -2rem;\n @media only screen and ".concat(devices_1.devices.xl, " {\n padding: 2rem 1rem;\n margin: -2rem -1rem;\n }\n "); });
|
|
14
|
+
exports.TabHeaderStyled = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: ", ";\n column-gap: ", ";\n ", "\n ", "\n @media only screen and ", " {\n column-gap: ", ";\n }\n"], ["\n display: flex;\n align-items: center;\n justify-content: ", ";\n column-gap: ", ";\n ", "\n ", "\n @media only screen and ", " {\n column-gap: ", ";\n }\n"])), function (props) { return props.$hasAutoFlex ? "center" : "flex-start"; }, function (props) { return props.$size === "large" ? "1.5rem" : "1rem"; }, function (props) { return !props.$hasAutoFlex && "\n scroll-snap-type: x proximity;\n -webkit-overflow-scrolling: touch;\n scrollbar-width: none;\n overflow-x: scroll;\n padding: 2rem;\n margin: -2rem;\n @media only screen and ".concat(devices_1.devices.xl, " {\n padding: 2rem 1rem;\n margin: -2rem -1rem;\n column-gap: ").concat(function (props) { return props.$size === "large" ? "1rem" : "1rem"; }, ";\n }\n "); }, function (props) { return props.$isHideTabHeaderOnMobile ? "\n @media only screen and ".concat(devices_1.devices.lg, " {\n display: none;\n }\n ") : ""; }, devices_1.devices.xl, function (props) { return props.$size === "large" ? "1rem" : "1rem"; });
|
|
15
15
|
exports.TabItemStyled = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n flex: ", ";\n ", "\n"], ["\n flex: ", ";\n ", "\n"])), function (props) { return props.$hasAutoFlex ? "1 0" : "auto 0"; }, function (props) { return props.$isDisabled ? "\n cursor: no-drop;\n pointer-events: none;\n user-select: none;\n " : ""; });
|
|
16
16
|
exports.TabItemTitleStyled = styled_components_1.default.button(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n background: transparent;\n color: ", ";\n border: 1px solid ", ";\n width: 100%;\n box-shadow: 0 6px 30px 0 ", ";\n border-radius: 0.5rem;\n transition: all .2s ease;\n padding: ", ";\n height: 40px;\n cursor: pointer;\n font: var(--body-semi-bold-14-17);\n white-space: ", ";\n outline: none !important;\n &:hover {\n color: var(--dark);\n border: 1px solid var(--grey-10);\n box-shadow: 0 6px 30px 0 var(--box-shadow-color);\n }\n"], ["\n background: transparent;\n color: ", ";\n border: 1px solid ", ";\n width: 100%;\n box-shadow: 0 6px 30px 0 ", ";\n border-radius: 0.5rem;\n transition: all .2s ease;\n padding: ", ";\n height: 40px;\n cursor: pointer;\n font: var(--body-semi-bold-14-17);\n white-space: ", ";\n outline: none !important;\n &:hover {\n color: var(--dark);\n border: 1px solid var(--grey-10);\n box-shadow: 0 6px 30px 0 var(--box-shadow-color);\n }\n"])), function (props) { return props.$isActive ? "var(--dark)" : "var(--dark-opacity-75)"; }, function (props) { return props.$isActive ? "var(--grey-10)" : "transparent"; }, function (props) { return props.$isActive ? "var(--box-shadow-color)" : "transparent"; }, function (props) { return props.$hasAutoFlex ? "0" : props.$size === "large" ? "0 1.5rem" : "0 1rem"; }, function (props) { return props.$hasAutoFlex ? "pre-wrap" : "nowrap"; });
|
|
17
|
-
exports.TabItemContentStyled = styled_components_1.default.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n padding-top:
|
|
17
|
+
exports.TabItemContentStyled = styled_components_1.default.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n padding-top: ", ";\n @media only screen and ", " {\n padding-top: ", ";\n }\n"], ["\n padding-top: ", ";\n @media only screen and ", " {\n padding-top: ", ";\n }\n"])), function (props) { return props.$size === "large" ? "1.5rem" : "1rem"; }, devices_1.devices.lg, function (props) { return props.$size === "large" ? "1.5rem" : "1rem"; });
|
|
18
18
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -6,6 +6,7 @@ export interface Tabs {
|
|
|
6
6
|
children?: any;
|
|
7
7
|
onActive?(e: any): void;
|
|
8
8
|
hasAutoFlex?: boolean;
|
|
9
|
+
isHideTabHeaderOnMobile?: boolean;
|
|
9
10
|
size: SIZES;
|
|
10
11
|
}
|
|
11
12
|
export interface TabItem {
|
|
@@ -20,6 +21,7 @@ export interface TabItem {
|
|
|
20
21
|
}
|
|
21
22
|
export interface TabStyledProps {
|
|
22
23
|
$hasAutoFlex?: boolean;
|
|
24
|
+
$isHideTabHeaderOnMobile?: boolean;
|
|
23
25
|
$size?: SIZES;
|
|
24
26
|
}
|
|
25
27
|
export interface TabItemStyledProps {
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import { VideoCardProps } from "./props";
|
|
2
|
-
declare const VideoCard: {
|
|
3
|
-
({ poster, title, videoUrl }: VideoCardProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
-
defaultProps: {};
|
|
5
|
-
};
|
|
2
|
+
declare const VideoCard: ({ poster, title, videoUrl }: VideoCardProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
3
|
export default VideoCard;
|
|
@@ -10,13 +10,49 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
13
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
17
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
|
+
var react_1 = require("react");
|
|
15
19
|
var props_1 = require("./props");
|
|
16
20
|
var VideoCard_styled_1 = require("./VideoCard.styled");
|
|
21
|
+
var Icon_1 = __importDefault(require("../Icon"));
|
|
22
|
+
var useVideoPlayer_1 = require("../../hooks/useVideoPlayer");
|
|
23
|
+
var VideoControlsComponent = function (_a) {
|
|
24
|
+
var videoRef = _a.videoRef, onPlayClick = _a.onPlayClick, onMuteClick = _a.onMuteClick;
|
|
25
|
+
var _b = (0, react_1.useState)({
|
|
26
|
+
isPaused: true,
|
|
27
|
+
isMuted: true
|
|
28
|
+
}), controlState = _b[0], setControlState = _b[1];
|
|
29
|
+
(0, react_1.useEffect)(function () {
|
|
30
|
+
var video = videoRef.current;
|
|
31
|
+
if (!video)
|
|
32
|
+
return;
|
|
33
|
+
var updateControlState = function () {
|
|
34
|
+
setControlState({
|
|
35
|
+
isPaused: video.paused,
|
|
36
|
+
isMuted: video.muted
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
// Initial state
|
|
40
|
+
updateControlState();
|
|
41
|
+
// Event listeners
|
|
42
|
+
video.addEventListener('play', updateControlState);
|
|
43
|
+
video.addEventListener('pause', updateControlState);
|
|
44
|
+
video.addEventListener('volumechange', updateControlState);
|
|
45
|
+
return function () {
|
|
46
|
+
video.removeEventListener('play', updateControlState);
|
|
47
|
+
video.removeEventListener('pause', updateControlState);
|
|
48
|
+
video.removeEventListener('volumechange', updateControlState);
|
|
49
|
+
};
|
|
50
|
+
}, [videoRef]);
|
|
51
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(VideoCard_styled_1.VideoControls, { children: [(0, jsx_runtime_1.jsx)(VideoCard_styled_1.PlayOverlay, __assign({ onClick: onPlayClick }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: controlState.isPaused ? "Play" : "Pause", width: "16", height: "16", color: "white", hasWrapper: false }) })), (0, jsx_runtime_1.jsx)(VideoCard_styled_1.ControlButton, __assign({ onClick: onMuteClick }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: controlState.isMuted ? "VolumeOffSm" : "VolumeUpSm", width: "16", height: "16", color: "white", hasWrapper: false }) }))] }) }));
|
|
52
|
+
};
|
|
17
53
|
var VideoCard = function (_a) {
|
|
18
54
|
var _b = _a.poster, poster = _b === void 0 ? props_1.VideoCardDefault.poster : _b, _c = _a.title, title = _c === void 0 ? props_1.VideoCardDefault.title : _c, _d = _a.videoUrl, videoUrl = _d === void 0 ? props_1.VideoCardDefault.videoUrl : _d;
|
|
19
|
-
|
|
55
|
+
var _e = (0, useVideoPlayer_1.useVideoPlayer)(), videoRef = _e.videoRef, togglePlay = _e.togglePlay, toggleMute = _e.toggleMute;
|
|
56
|
+
return ((0, jsx_runtime_1.jsxs)(VideoCard_styled_1.VideoCardStyled, { children: [(0, jsx_runtime_1.jsxs)(VideoCard_styled_1.VideoWrapper, { children: [(0, jsx_runtime_1.jsxs)("video", __assign({ ref: videoRef, poster: poster, muted: true, onClick: togglePlay }, { children: [(0, jsx_runtime_1.jsx)("source", { src: videoUrl, type: "video/mp4" }), "Your browser does not support the video tag."] })), (0, jsx_runtime_1.jsx)(VideoControlsComponent, { videoRef: videoRef, onPlayClick: togglePlay, onMuteClick: toggleMute })] }), (0, jsx_runtime_1.jsx)(VideoCard_styled_1.Title, { children: title })] }));
|
|
20
57
|
};
|
|
21
|
-
VideoCard.defaultProps = {};
|
|
22
58
|
exports.default = VideoCard;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export declare const VideoCardStyled: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
3
3
|
export declare const VideoWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
4
|
+
export declare const VideoControls: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
5
|
+
export declare const ControlButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
6
|
+
export declare const PlayOverlay: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
4
7
|
export declare const Title: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, never>> & string;
|
|
@@ -7,9 +7,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
8
|
};
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.Title = exports.VideoWrapper = exports.VideoCardStyled = void 0;
|
|
10
|
+
exports.Title = exports.PlayOverlay = exports.ControlButton = exports.VideoControls = exports.VideoWrapper = exports.VideoCardStyled = void 0;
|
|
11
11
|
var styled_components_1 = __importDefault(require("styled-components"));
|
|
12
12
|
exports.VideoCardStyled = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n box-shadow: 0 6px 30px 0 var(--box-shadow-color);\n border-radius: 0.5rem;\n padding: 1.5rem;\n transition: all .2s ease;\n cursor: pointer;\n &:hover{\n box-shadow: 0 4px 15px 0 var(--dark-shadow-color);\n }\n"], ["\n box-shadow: 0 6px 30px 0 var(--box-shadow-color);\n border-radius: 0.5rem;\n padding: 1.5rem;\n transition: all .2s ease;\n cursor: pointer;\n &:hover{\n box-shadow: 0 4px 15px 0 var(--dark-shadow-color);\n }\n"])));
|
|
13
|
-
exports.VideoWrapper = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: flex-start;\n video{\n display: block;\n width: 100%;\n height: 371px;\n object-fit: cover;\n position: relative;\n overflow: hidden;\n border-radius: 0.5rem;\n }\n"], ["\n display: flex;\n align-items: center;\n justify-content: flex-start;\n video{\n display: block;\n width: 100%;\n height: 371px;\n object-fit: cover;\n position: relative;\n overflow: hidden;\n border-radius: 0.5rem;\n }\n"])));
|
|
14
|
-
exports.
|
|
15
|
-
|
|
13
|
+
exports.VideoWrapper = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: flex-start;\n position: relative;\n video{\n display: block;\n width: 100%;\n height: 371px;\n object-fit: cover;\n position: relative;\n overflow: hidden;\n border-radius: 0.5rem;\n }\n"], ["\n display: flex;\n align-items: center;\n justify-content: flex-start;\n position: relative;\n video{\n display: block;\n width: 100%;\n height: 371px;\n object-fit: cover;\n position: relative;\n overflow: hidden;\n border-radius: 0.5rem;\n }\n"])));
|
|
14
|
+
exports.VideoControls = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: absolute;\n bottom: 1rem;\n right: 1rem;\n left: 1rem;\n display: flex;\n gap: 1rem;\n z-index: 2;\n align-items: center;\n justify-content: flex-start;\n"], ["\n position: absolute;\n bottom: 1rem;\n right: 1rem;\n left: 1rem;\n display: flex;\n gap: 1rem;\n z-index: 2;\n align-items: center;\n justify-content: flex-start;\n"])));
|
|
15
|
+
exports.ControlButton = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n cursor: pointer;\n svg{\n display: block;\n }\n"], ["\n cursor: pointer;\n svg{\n display: block;\n }\n"])));
|
|
16
|
+
exports.PlayOverlay = styled_components_1.default.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n cursor: pointer;\n svg{\n display: block;\n }\n"], ["\n cursor: pointer;\n svg{\n display: block;\n }\n"])));
|
|
17
|
+
exports.Title = styled_components_1.default.strong(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n margin-top: 1.5rem;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n font : var(--title-bold-16-19);\n"], ["\n margin-top: 1.5rem;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n font : var(--title-bold-16-19);\n"])));
|
|
18
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|