@telia-ace/widget-ui 1.0.13 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -29,9 +29,9 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- import styled, { css } from "styled-components";
32
+ import styled, { css, keyframes } from "styled-components";
33
33
  import { kebabCase, appendClassNames, uuid, removeNullAndUndefinedValues } from "@telia-ace/widget-utilities";
34
- import React, { forwardRef, createContext, useContext as useContext$1, useState, useEffect, useRef, useCallback, useImperativeHandle, Component, lazy } from "react";
34
+ import React, { forwardRef, createContext, useContext as useContext$1, useState, useEffect, useRef, useCallback, useImperativeHandle, useMemo, Component, lazy } from "react";
35
35
  import { CSSTransition, Transition } from "react-transition-group";
36
36
  import { Container, WidgetState } from "@webprovisions/platform";
37
37
  import { ComponentPlatform, asDescriptor, createEventSubscriber, ComponentQuery, WidgetRenderState, extendComponent } from "@telia-ace/widget-core";
@@ -343,14 +343,14 @@ const AnchorLink = (props) => {
343
343
  };
344
344
  var Button = forwardRef((_a, ref) => {
345
345
  var _b = _a, { className, children } = _b, other = __objRest(_b, ["className", "children"]);
346
- return /* @__PURE__ */ React.createElement(StyledButton, __spreadProps(__spreadValues({
346
+ return /* @__PURE__ */ React.createElement(StyledButton$2, __spreadProps(__spreadValues({
347
347
  type: "button",
348
348
  className: appendClassNames(className, "humany-button")
349
349
  }, convertToStringAttributes(other)), {
350
350
  ref
351
351
  }), children);
352
352
  });
353
- const StyledButton = styled.button`
353
+ const StyledButton$2 = styled.button`
354
354
  -webkit-appearance: button;
355
355
  text-transform: none;
356
356
  overflow: visible;
@@ -1168,17 +1168,21 @@ const genericHtml = css`
1168
1168
  margin: 0;
1169
1169
  }
1170
1170
  `;
1171
- const Portal = ({ elementId = "humany-portal-elements", children }) => {
1172
- const [container] = React.useState(() => {
1171
+ const Portal = ({
1172
+ elementId = "humany-portal-elements",
1173
+ parent = document.body,
1174
+ children
1175
+ }) => {
1176
+ const [container] = useState(() => {
1173
1177
  const el = document.getElementById(elementId) || document.createElement("div");
1174
1178
  el.id = elementId;
1175
1179
  return el;
1176
1180
  });
1177
1181
  useEffect(() => {
1178
- document.body.appendChild(container);
1182
+ parent.appendChild(container);
1179
1183
  return () => {
1180
1184
  if (container.childElementCount <= 1) {
1181
- document.body.removeChild(container);
1185
+ parent.removeChild(container);
1182
1186
  }
1183
1187
  };
1184
1188
  }, [container]);
@@ -1597,6 +1601,30 @@ const SymbolBadge = (_g) => {
1597
1601
  fill: "white"
1598
1602
  }));
1599
1603
  }
1604
+ case "video": {
1605
+ if (style.minWidth && typeof style.minWidth === "number") {
1606
+ style.minWidth = `${style.minWidth}px`;
1607
+ }
1608
+ return /* @__PURE__ */ React.createElement("svg", __spreadProps(__spreadValues({
1609
+ viewBox: "0 0 25 25"
1610
+ }, svgProps), {
1611
+ style
1612
+ }), /* @__PURE__ */ React.createElement("path", {
1613
+ d: "M16.8245 10.0758C18.7392 8.55799 21.3085 7.08973 21.7947 7.61552C22.5982 8.47863 22.5288 16.6929 21.7947 17.4766C21.3482 17.9627 18.7589 16.4945 16.8245 14.9866",
1614
+ stroke: "currentColor",
1615
+ strokeWidth: "1.5",
1616
+ strokeLinecap: "round",
1617
+ strokeLinejoin: "round"
1618
+ }), /* @__PURE__ */ React.createElement("path", {
1619
+ fillRule: "evenodd",
1620
+ clipRule: "evenodd",
1621
+ d: "M2.61914 12.5385C2.61914 7.12973 4.41578 5.32715 9.80764 5.32715C15.1985 5.32715 16.9952 7.12973 16.9952 12.5385C16.9952 17.9462 15.1985 19.7497 9.80764 19.7497C4.41578 19.7497 2.61914 17.9462 2.61914 12.5385Z",
1622
+ stroke: "currentColor",
1623
+ strokeWidth: "1.5",
1624
+ strokeLinecap: "round",
1625
+ strokeLinejoin: "round"
1626
+ }));
1627
+ }
1600
1628
  case "star-empty": {
1601
1629
  return /* @__PURE__ */ React.createElement("svg", __spreadValues({
1602
1630
  viewBox: "0 0 13 12"
@@ -1624,6 +1652,62 @@ const SymbolBadge = (_g) => {
1624
1652
  fill: "black"
1625
1653
  }));
1626
1654
  }
1655
+ case "zoom-in": {
1656
+ return /* @__PURE__ */ React.createElement("svg", __spreadValues({
1657
+ viewBox: "0 0 24 24"
1658
+ }, svgProps), /* @__PURE__ */ React.createElement("path", {
1659
+ fillRule: "evenodd",
1660
+ clipRule: "evenodd",
1661
+ d: "M21.9774 20.8287L17.9149 16.7662C17.8437 16.6957 17.76 16.639 17.668 16.5992C20.7612 12.9331 20.415 7.48045 16.883 4.23507C13.3509 0.989694 7.88848 1.10517 4.49673 4.49691C1.10499 7.88866 0.98951 13.3511 4.23489 16.8831C7.48027 20.4152 12.9329 20.7614 16.599 17.6682C16.6388 17.7601 16.6955 17.8439 16.766 17.9151L20.8285 21.9776C21.1457 22.2948 21.6601 22.2948 21.9774 21.9776C22.2947 21.6603 22.2947 21.1459 21.9774 20.8287ZM10.8404 18.1531C6.80186 18.1531 3.52794 14.8792 3.52794 10.8406C3.52794 6.80204 6.80186 3.52813 10.8404 3.52813C14.879 3.52813 18.1529 6.80204 18.1529 10.8406C18.1483 14.8773 14.8771 18.1484 10.8404 18.1531Z",
1662
+ fill: "white"
1663
+ }), /* @__PURE__ */ React.createElement("path", {
1664
+ fillRule: "evenodd",
1665
+ clipRule: "evenodd",
1666
+ d: "M10.8749 6.75003C11.2892 6.75003 11.6249 7.08581 11.6249 7.50003V14.25C11.6249 14.6642 11.2892 15 10.8749 15C10.4607 15 10.1249 14.6642 10.1249 14.25V7.50003C10.1249 7.08581 10.4607 6.75003 10.8749 6.75003Z",
1667
+ fill: "white"
1668
+ }), /* @__PURE__ */ React.createElement("path", {
1669
+ fillRule: "evenodd",
1670
+ clipRule: "evenodd",
1671
+ d: "M6.74994 10.875C6.74994 10.4608 7.08573 10.125 7.49994 10.125H14.2499C14.6642 10.125 14.9999 10.4608 14.9999 10.875C14.9999 11.2892 14.6642 11.625 14.2499 11.625H7.49994C7.08573 11.625 6.74994 11.2892 6.74994 10.875Z",
1672
+ fill: "white"
1673
+ }));
1674
+ }
1675
+ case "zoom-out": {
1676
+ return /* @__PURE__ */ React.createElement("svg", __spreadValues({
1677
+ viewBox: "0 0 24 24"
1678
+ }, svgProps), /* @__PURE__ */ React.createElement("path", {
1679
+ fillRule: "evenodd",
1680
+ clipRule: "evenodd",
1681
+ d: "M22.1025 20.9536L18.04 16.8911C17.9688 16.8206 17.8851 16.764 17.7931 16.7241C20.8864 13.0581 20.5401 7.60539 17.0081 4.36001C13.476 1.11463 8.0136 1.23011 4.62185 4.62185C1.23011 8.0136 1.11463 13.476 4.36001 17.0081C7.60539 20.5401 13.0581 20.8864 16.7241 17.7931C16.764 17.8851 16.8206 17.9688 16.8911 18.04L20.9536 22.1025C21.2709 22.4198 21.7853 22.4198 22.1025 22.1025C22.4198 21.7853 22.4198 21.2709 22.1025 20.9536ZM10.9656 18.2781C6.92698 18.2781 3.65306 15.0041 3.65306 10.9656C3.65306 6.92698 6.92698 3.65306 10.9656 3.65306C15.0041 3.65306 18.2781 6.92698 18.2781 10.9656C18.2734 15.0022 15.0022 18.2734 10.9656 18.2781Z",
1682
+ fill: "white"
1683
+ }), /* @__PURE__ */ React.createElement("path", {
1684
+ fillRule: "evenodd",
1685
+ clipRule: "evenodd",
1686
+ d: "M6.87506 11C6.87506 10.5858 7.21085 10.25 7.62506 10.25H14.3751C14.7893 10.25 15.1251 10.5858 15.1251 11C15.1251 11.4142 14.7893 11.75 14.3751 11.75H7.62506C7.21085 11.75 6.87506 11.4142 6.87506 11Z",
1687
+ fill: "white"
1688
+ }));
1689
+ }
1690
+ case "download": {
1691
+ return /* @__PURE__ */ React.createElement("svg", __spreadValues({
1692
+ viewBox: "0 0 24 24"
1693
+ }, svgProps), /* @__PURE__ */ React.createElement("path", {
1694
+ fillRule: "evenodd",
1695
+ clipRule: "evenodd",
1696
+ d: "M22.5 11.1346V18.4038C22.498 20.1873 21.0527 21.6326 19.2692 21.6346H4.73077C2.94731 21.6326 1.50204 20.1873 1.5 18.4038V11.1346C1.5 10.6885 1.86162 10.3269 2.30769 10.3269C2.75377 10.3269 3.11538 10.6885 3.11538 11.1346V18.4038C3.1164 19.2956 3.83904 20.0182 4.73077 20.0192H19.2692C20.161 20.0182 20.8836 19.2956 20.8846 18.4038V11.1346C20.8846 10.6885 21.2462 10.3269 21.6923 10.3269C22.1384 10.3269 22.5 10.6885 22.5 11.1346ZM11.1434 16.2663C11.6167 16.7388 12.3832 16.7388 12.8565 16.2663L17.4172 11.7057C17.7326 11.3903 17.7326 10.8789 17.4172 10.5635C17.1018 10.2481 16.5904 10.2481 16.275 10.5635L12.8076 14.0308V3.05769C12.8076 2.61162 12.446 2.25 11.9999 2.25C11.5539 2.25 11.1923 2.61162 11.1923 3.05769V14.0308L7.72485 10.5636C7.40946 10.2482 6.89812 10.2482 6.58273 10.5636C6.26734 10.8789 6.26734 11.3903 6.58273 11.7057L11.1434 16.2663Z",
1697
+ fill: "white"
1698
+ }));
1699
+ }
1700
+ case "lightbox-close": {
1701
+ return /* @__PURE__ */ React.createElement("svg", __spreadValues({
1702
+ viewBox: "0 0 24 24"
1703
+ }, svgProps), /* @__PURE__ */ React.createElement("path", {
1704
+ xmlns: "http://www.w3.org/2000/svg",
1705
+ fillRule: "evenodd",
1706
+ clipRule: "evenodd",
1707
+ d: "M19.2621 18.1129C19.4674 18.3182 19.5475 18.6173 19.4724 18.8977C19.3973 19.178 19.1783 19.397 18.8979 19.4721C18.6176 19.5472 18.3184 19.4671 18.1132 19.2619L12.1877 13.3363L6.26214 19.2619C6.0569 19.4671 5.75776 19.5472 5.47741 19.4721C5.19705 19.397 4.97807 19.178 4.90294 18.8977C4.82782 18.6173 4.90798 18.3182 5.11321 18.1129L11.0388 12.1874L5.11321 6.26186C4.90798 6.05663 4.82782 5.75749 4.90294 5.47713C4.97807 5.19678 5.19705 4.97779 5.47741 4.90267C5.75776 4.82755 6.0569 4.9077 6.26214 5.11294L12.1877 11.0385L18.1132 5.11294C18.4305 4.79567 18.9449 4.79567 19.2621 5.11294C19.5794 5.4302 19.5794 5.9446 19.2621 6.26186L13.3366 12.1874L19.2621 18.1129Z",
1708
+ fill: "white"
1709
+ }));
1710
+ }
1627
1711
  }
1628
1712
  return null;
1629
1713
  }
@@ -1760,7 +1844,7 @@ const Drawer = ({
1760
1844
  "aria-expanded": visible
1761
1845
  }));
1762
1846
  };
1763
- const Wrapper$4 = styled.div`
1847
+ const Wrapper$7 = styled.div`
1764
1848
  font-family: ${(p) => {
1765
1849
  var _a;
1766
1850
  return (_a = p.theme.fonts) == null ? void 0 : _a.type;
@@ -1802,7 +1886,7 @@ const Header$1 = styled(Typography)`
1802
1886
  const AnimationBase = css`
1803
1887
  transition: ${(p) => p.duration}ms;
1804
1888
  `;
1805
- const WrapperWithSlideInBottom = styled(Wrapper$4)`
1889
+ const WrapperWithSlideInBottom = styled(Wrapper$7)`
1806
1890
  max-height: 0;
1807
1891
  ${AnimationBase}
1808
1892
 
@@ -1820,7 +1904,7 @@ const WrapperWithSlideInBottom = styled(Wrapper$4)`
1820
1904
  max-height: 0;
1821
1905
  }
1822
1906
  `;
1823
- const WrapperWithSlideInRight = styled(Wrapper$4)`
1907
+ const WrapperWithSlideInRight = styled(Wrapper$7)`
1824
1908
  ${AnimationBase}
1825
1909
  transform: translateX(100%);
1826
1910
  height: ${(p) => p.fullScreen ? "100%" : "auto"};
@@ -1839,7 +1923,7 @@ const WrapperWithSlideInRight = styled(Wrapper$4)`
1839
1923
  transform: translateX(100%);
1840
1924
  }
1841
1925
  `;
1842
- const WrapperWithSlideInLeft = styled(Wrapper$4)`
1926
+ const WrapperWithSlideInLeft = styled(Wrapper$7)`
1843
1927
  ${AnimationBase}
1844
1928
  transform: translateX(-100%);
1845
1929
  height: ${(p) => p.fullScreen ? "100%" : "auto"};
@@ -1858,7 +1942,7 @@ const WrapperWithSlideInLeft = styled(Wrapper$4)`
1858
1942
  transform: translateX(-100%);
1859
1943
  }
1860
1944
  `;
1861
- const WrapperWithSlideInTop = styled(Wrapper$4)`
1945
+ const WrapperWithSlideInTop = styled(Wrapper$7)`
1862
1946
  ${AnimationBase}
1863
1947
  bottom: unset;
1864
1948
  top: 0;
@@ -2011,9 +2095,9 @@ const StyledDropdown = styled.div`
2011
2095
  `;
2012
2096
  const Empty = (_k) => {
2013
2097
  var other = __objRest(_k, []);
2014
- return /* @__PURE__ */ React.createElement(Wrapper$3, __spreadValues({}, other));
2098
+ return /* @__PURE__ */ React.createElement(Wrapper$6, __spreadValues({}, other));
2015
2099
  };
2016
- const Wrapper$3 = styled.div`
2100
+ const Wrapper$6 = styled.div`
2017
2101
  display: none;
2018
2102
  `;
2019
2103
  var grid = forwardRef((_l, ref) => {
@@ -2268,14 +2352,14 @@ const Overlay = (_z) => {
2268
2352
  classNames: "humany-overlay-transition",
2269
2353
  unmountOnExit: true,
2270
2354
  timeout: duration
2271
- }, /* @__PURE__ */ React.createElement(Portal, null, /* @__PURE__ */ React.createElement(Wrapper$2, __spreadValues({
2355
+ }, /* @__PURE__ */ React.createElement(Portal, null, /* @__PURE__ */ React.createElement(Wrapper$5, __spreadValues({
2272
2356
  className: "humany-overlay",
2273
2357
  duration,
2274
2358
  ref,
2275
2359
  onClick: onOverlayClick
2276
2360
  }, other), children)));
2277
2361
  };
2278
- const Wrapper$2 = styled.div`
2362
+ const Wrapper$5 = styled.div`
2279
2363
  background: rgba(0, 0, 0, 0.6);
2280
2364
  min-width: 100%;
2281
2365
  min-height: 100%;
@@ -2306,9 +2390,240 @@ const Wrapper$2 = styled.div`
2306
2390
  opacity: 0;
2307
2391
  }
2308
2392
  `;
2393
+ const ZoomButtons = ({ zoom, zoomLevel }) => {
2394
+ return /* @__PURE__ */ React.createElement(Wrapper$4, null, /* @__PURE__ */ React.createElement(Buttons, null, /* @__PURE__ */ React.createElement(StyledButton$1, {
2395
+ "aria-label": "Zoom out",
2396
+ onClick: () => {
2397
+ zoom(false);
2398
+ }
2399
+ }, /* @__PURE__ */ React.createElement(StyledSymbolBadge$1, {
2400
+ size: 24,
2401
+ symbol: { type: "Svg", content: "zoom-out" }
2402
+ })), /* @__PURE__ */ React.createElement(StyledButton$1, {
2403
+ "aria-label": "Zoom in",
2404
+ onClick: () => {
2405
+ zoom(true);
2406
+ }
2407
+ }, /* @__PURE__ */ React.createElement(StyledSymbolBadge$1, {
2408
+ size: 24,
2409
+ symbol: { type: "Svg", content: "zoom-in" }
2410
+ }))), /* @__PURE__ */ React.createElement(ZoomLevel, null, /* @__PURE__ */ React.createElement(Typography, {
2411
+ variant: "p"
2412
+ }, zoomLevel, "%")));
2413
+ };
2414
+ const Wrapper$4 = styled.div`
2415
+ width: 100vw;
2416
+ display: flex;
2417
+ position: absolute;
2418
+ bottom: 0;
2419
+ margin-bottom: ${(p) => {
2420
+ var _a;
2421
+ return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
2422
+ }};
2423
+ justify-content: center;
2424
+ flex-direction: row;
2425
+ `;
2426
+ const ZoomLevel = styled.div`
2427
+ right: 45px;
2428
+ position: absolute;
2429
+ color: #fff;
2430
+ font-size: ${(p) => {
2431
+ var _a;
2432
+ return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
2433
+ }};
2434
+ line-height: 1.5em;
2435
+ ${(p) => {
2436
+ var _a, _b;
2437
+ return ((_a = p.theme.fonts) == null ? void 0 : _a.type) && `
2438
+ font-family: ${(_b = p.theme.fonts) == null ? void 0 : _b.type};
2439
+ `;
2440
+ }}
2441
+ `;
2442
+ const Buttons = styled.div`
2443
+ position: relative;
2444
+ margin: ${(p) => {
2445
+ var _a;
2446
+ return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
2447
+ }};
2448
+ `;
2449
+ const StyledSymbolBadge$1 = styled(SymbolBadge)`
2450
+ path {
2451
+ stroke: #ffffff;
2452
+ }
2453
+ `;
2454
+ const StyledButton$1 = styled(Button)`
2455
+ transition: opacity 300ms ease-in-out;
2456
+ opacity: 0.7;
2457
+ &:hover {
2458
+ opacity: 1;
2459
+ }
2460
+ margin: ${(p) => {
2461
+ var _a;
2462
+ return (_a = p.theme.sizes) == null ? void 0 : _a.small;
2463
+ }};
2464
+ `;
2465
+ const spin = keyframes`
2466
+ 100% {
2467
+ transform: rotate(360deg);
2468
+ }
2469
+ `;
2470
+ const dash = keyframes`
2471
+ 0% {
2472
+ stroke-dasharray: 1, 200;
2473
+ stroke-dashoffset: 0;
2474
+ }
2475
+ 50% {
2476
+ stroke-dasharray: 89, 200;
2477
+ stroke-dashoffset: -35px;
2478
+ }
2479
+ 100% {
2480
+ stroke-dasharray: 89, 200;
2481
+ stroke-dashoffset: -124px;
2482
+ }
2483
+ `;
2484
+ const SpinnerSvg = styled.svg`
2485
+ animation: ${spin} 2s linear infinite;
2486
+ height: 100%;
2487
+ transform-origin: center center;
2488
+ width: 100%;
2489
+ position: absolute;
2490
+ top: 0;
2491
+ bottom: 0;
2492
+ left: 0;
2493
+ right: 0;
2494
+ margin: auto;
2495
+ transition: 200ms ease-out opacity;
2496
+ `;
2497
+ const Wrapper$3 = styled.div`
2498
+ position: absolute;
2499
+ top: 0;
2500
+ bottom: 0;
2501
+ left: 0;
2502
+ right: 0;
2503
+ height: 100%;
2504
+ width: 100%;
2505
+ pointer-events: ${(p) => p["data-loading"] ? "all" : "none"}
2506
+ display: flex;
2507
+ flex-direction: column;
2508
+ justify-content: center;
2509
+ transition: 200ms ease-out opacity;
2510
+ box-sizing: border-box;
2511
+ overflow: hidden;
2512
+ ${SpinnerSvg} {
2513
+ opacity: ${(p) => p["data-loading"] ? "1" : "0"}
2514
+ }
2515
+ `;
2516
+ const Spinner = styled.div`
2517
+ position: relative;
2518
+ margin: 0 auto;
2519
+ width: 100px;
2520
+ &:before {
2521
+ content: '';
2522
+ display: block;
2523
+ padding-top: 100%;
2524
+ }
2525
+ `;
2526
+ const SpinnerCircle = styled.circle`
2527
+ stroke-dasharray: 1, 200;
2528
+ stroke-dashoffset: 0;
2529
+ animation: ${dash} 1.5s ease-in-out infinite;
2530
+ stroke-linecap: round;
2531
+ stroke: ${(p) => {
2532
+ var _a;
2533
+ return (_a = p.theme.colors) == null ? void 0 : _a.primary;
2534
+ }};
2535
+ stroke-width: 2px;
2536
+ `;
2537
+ const Loader = ({ loading = false }) => {
2538
+ return /* @__PURE__ */ React.createElement(Wrapper$3, {
2539
+ className: "humany-loader",
2540
+ "data-loading": loading
2541
+ }, /* @__PURE__ */ React.createElement(Spinner, {
2542
+ className: "humany-spinner"
2543
+ }, /* @__PURE__ */ React.createElement(SpinnerSvg, {
2544
+ viewBox: "25 25 50 50"
2545
+ }, /* @__PURE__ */ React.createElement(SpinnerCircle, {
2546
+ cx: "50",
2547
+ cy: "50",
2548
+ r: "20",
2549
+ fill: "none",
2550
+ "stroke-width": "2",
2551
+ "stroke-miterlimit": "10"
2552
+ }))));
2553
+ };
2554
+ const ZoomImg = (_B) => {
2555
+ var _C = _B, { zoomState } = _C, attrs = __objRest(_C, ["zoomState"]);
2556
+ const ref = useRef(null);
2557
+ const [loaded, setLoaded] = useState(false);
2558
+ const _a = attrs.style || {}, { width, height } = _a, restStyle = __objRest(_a, ["width", "height"]);
2559
+ const imageSize = useMemo(() => {
2560
+ const img = ref.current;
2561
+ if (img) {
2562
+ if (img.width >= img.height) {
2563
+ return [`${zoomState}vw`, "auto"];
2564
+ } else {
2565
+ return ["auto", `${zoomState}vh`];
2566
+ }
2567
+ }
2568
+ return null;
2569
+ }, [zoomState, ref, loaded]);
2570
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Loader, {
2571
+ loading: !loaded
2572
+ }), /* @__PURE__ */ React.createElement(Img, __spreadProps(__spreadValues({
2573
+ onLoad: () => {
2574
+ setLoaded(true);
2575
+ },
2576
+ ref,
2577
+ imageSize,
2578
+ draggable: "false"
2579
+ }, attrs), {
2580
+ style: restStyle
2581
+ })), /* @__PURE__ */ React.createElement(EmptyDiv, null));
2582
+ };
2583
+ const Img = styled.img`
2584
+ transform: none;
2585
+
2586
+ ${(props) => props.imageSize ? css`
2587
+ width: ${props.imageSize[0]};
2588
+ height: ${props.imageSize[1]};
2589
+ display: inline-block;
2590
+ ` : "display:none;"}
2591
+ vertical-align: middle;
2592
+ position: relative;
2593
+ `;
2594
+ const EmptyDiv = styled.div`
2595
+ height: 100%;
2596
+ display: inline-block;
2597
+ vertical-align: middle;
2598
+ `;
2599
+ const useFadeOut = () => {
2600
+ const timeOut = useRef();
2601
+ const [show, setShow] = useState(true);
2602
+ const triggerChange = useCallback(() => {
2603
+ if (!show)
2604
+ setShow(true);
2605
+ if (timeOut.current) {
2606
+ clearTimeout(timeOut.current);
2607
+ }
2608
+ timeOut.current = setTimeout(() => {
2609
+ setShow(false);
2610
+ }, 3e3);
2611
+ return () => {
2612
+ if (timeOut.current) {
2613
+ clearTimeout(timeOut.current);
2614
+ }
2615
+ };
2616
+ }, [show, timeOut]);
2617
+ return [show, triggerChange];
2618
+ };
2309
2619
  const Lightbox = ({ attrs }) => {
2310
2620
  const [visible, toggleVisible] = useToggle(false);
2311
2621
  const esc = useKeyPress("Escape");
2622
+ const [zoomState, setZoomState] = useState(80);
2623
+ const [scroll, setScroll] = useState({ top: 0, left: 0, x: 0, y: 0 });
2624
+ const [scrolling, setScrolling] = useState(false);
2625
+ const [show, triggerFadeOut] = useFadeOut();
2626
+ const ref = useRef(null);
2312
2627
  useEffect(() => {
2313
2628
  if (esc) {
2314
2629
  toggleVisible(false);
@@ -2317,44 +2632,134 @@ const Lightbox = ({ attrs }) => {
2317
2632
  const overlayClick = useCallback((e) => {
2318
2633
  toggleVisible(false);
2319
2634
  }, [toggleVisible]);
2635
+ const changeZoomState = useCallback((zoomIn) => {
2636
+ if (zoomIn) {
2637
+ setZoomState(zoomState + 10);
2638
+ } else {
2639
+ setZoomState(zoomState - 10);
2640
+ }
2641
+ }, [setZoomState, zoomState]);
2642
+ const downloadImage = useCallback(() => {
2643
+ const { src } = attrs;
2644
+ if (src) {
2645
+ window.open(src, "_blank");
2646
+ }
2647
+ }, [attrs]);
2648
+ const mouseDownHandler = useCallback((e) => {
2649
+ const ele = ref.current;
2650
+ if (ele) {
2651
+ setScroll({ top: ele.scrollTop, left: ele.scrollLeft, x: e.clientX, y: e.clientY });
2652
+ setScrolling(true);
2653
+ }
2654
+ }, [ref]);
2655
+ const mouseDragHandler = useCallback((e) => {
2656
+ const ele = ref.current;
2657
+ if (ele && scrolling) {
2658
+ const dx = e.clientX - scroll.x;
2659
+ const dy = e.clientY - scroll.y;
2660
+ ele.scrollTop = scroll.top - dy;
2661
+ ele.scrollLeft = scroll.left - dx;
2662
+ }
2663
+ }, [scrolling, scroll]);
2664
+ const mouseStopDragHandler = (e) => {
2665
+ e.preventDefault();
2666
+ setScrolling(false);
2667
+ };
2668
+ const isDraggable = useMemo(() => {
2669
+ if (ref.current) {
2670
+ const image = ref.current.getElementsByTagName("img");
2671
+ if (image) {
2672
+ const img = image[0];
2673
+ return img.width > window.innerWidth || img.height > window.innerHeight;
2674
+ }
2675
+ }
2676
+ return false;
2677
+ }, [ref, zoomState]);
2320
2678
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Overlay, {
2321
2679
  visible,
2322
2680
  onClick: overlayClick
2323
- }, /* @__PURE__ */ React.createElement(CloseButton, {
2681
+ }, /* @__PURE__ */ React.createElement(DraggableArea, {
2682
+ onMouseDown: () => triggerFadeOut(),
2683
+ onMouseMove: () => triggerFadeOut(),
2684
+ onTouchStart: () => triggerFadeOut()
2685
+ }, /* @__PURE__ */ React.createElement(TransparentBarTop, {
2686
+ show
2687
+ }, /* @__PURE__ */ React.createElement(DownloadButton, {
2688
+ onClick: () => downloadImage()
2689
+ }, /* @__PURE__ */ React.createElement(StyledSymbolBadge, {
2690
+ size: 20,
2691
+ symbol: { type: "Svg", content: "download" }
2692
+ })), /* @__PURE__ */ React.createElement(CloseButton, {
2324
2693
  onClick: () => toggleVisible(false)
2325
2694
  }, /* @__PURE__ */ React.createElement(StyledSymbolBadge, {
2326
- size: 24,
2327
- symbol: { type: "Svg", content: "close" }
2328
- })), /* @__PURE__ */ React.createElement(Content$1, null, /* @__PURE__ */ React.createElement("img", __spreadValues({}, attrs)))), /* @__PURE__ */ React.createElement("a", {
2695
+ size: 20,
2696
+ symbol: { type: "Svg", content: "lightbox-close" }
2697
+ }))), /* @__PURE__ */ React.createElement(Content$1, {
2698
+ scrolling,
2699
+ isDraggable,
2700
+ ref,
2701
+ onMouseMove: mouseDragHandler,
2702
+ onMouseDown: mouseDownHandler,
2703
+ onMouseUp: mouseStopDragHandler
2704
+ }, /* @__PURE__ */ React.createElement(ZoomImg, __spreadValues({
2705
+ zoomState
2706
+ }, attrs))), /* @__PURE__ */ React.createElement(TransparentBarBottom, {
2707
+ show
2708
+ }, /* @__PURE__ */ React.createElement(ZoomButtons, {
2709
+ zoom: changeZoomState,
2710
+ zoomLevel: zoomState
2711
+ })))), /* @__PURE__ */ React.createElement("a", {
2329
2712
  onClick: () => toggleVisible()
2330
2713
  }, /* @__PURE__ */ React.createElement(Thumbnail, __spreadValues({}, attrs))));
2331
2714
  };
2715
+ const TransparentBar = styled.div`
2716
+ position: absolute;
2717
+ width: 100vw;
2718
+ height: 88px;
2719
+ left: 0px;
2720
+ transition: opacity 0.3s ease 0s;
2721
+ z-index: 5;
2722
+ ${(p) => p.show ? "opacity: 1;" : css`
2723
+ opacity: 0;
2724
+ pointer-events: none;
2725
+ `}
2726
+ `;
2727
+ const DraggableArea = styled.div`
2728
+ width: 100%;
2729
+ `;
2730
+ const TransparentBarTop = styled(TransparentBar)`
2731
+ top: 0px;
2732
+ background-image: linear-gradient(to bottom, rgb(15, 15, 15, 0.8), rgba(30, 30, 30, 0));
2733
+ `;
2734
+ const TransparentBarBottom = styled(TransparentBar)`
2735
+ bottom: 0px;
2736
+ background-image: linear-gradient(to top, rgb(15, 15, 15, 0.8), rgba(30, 30, 30, 0));
2737
+ `;
2332
2738
  const Content$1 = styled.div`
2333
- padding: ${(p) => {
2334
- var _a;
2335
- return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
2336
- }};
2337
- max-width: 80%;
2338
- max-height: 80%;
2339
-
2340
- img {
2341
- width: auto !important;
2342
- height: auto !important;
2343
- max-width: 100%;
2344
- max-height: 100%;
2345
- }
2739
+ width: 100%;
2740
+ height: 100vh;
2741
+ overflow: auto;
2742
+ text-align: center;
2743
+ vertical-align: middle;
2744
+ white-space: nowrap;
2745
+ justify-content: center;
2746
+ cursor: ${(props) => props.isDraggable ? props.scrolling ? "grabbing" : "grab" : "auto"};
2346
2747
  `;
2347
- const CloseButton = styled(Button)`
2748
+ const StyledButton = styled(Button)`
2348
2749
  position: fixed;
2349
- top: 50px;
2350
- right: 50px;
2750
+ top: 34px;
2351
2751
  transition: opacity 300ms ease-in-out;
2352
2752
  opacity: 0.7;
2353
-
2354
2753
  &:hover {
2355
2754
  opacity: 1;
2356
2755
  }
2357
2756
  `;
2757
+ const CloseButton = styled(StyledButton)`
2758
+ right: 32px;
2759
+ `;
2760
+ const DownloadButton = styled(StyledButton)`
2761
+ right: 80px;
2762
+ `;
2358
2763
  const StyledSymbolBadge = styled(SymbolBadge)`
2359
2764
  path {
2360
2765
  stroke: #ffffff;
@@ -2363,9 +2768,9 @@ const StyledSymbolBadge = styled(SymbolBadge)`
2363
2768
  const Thumbnail = styled.img`
2364
2769
  cursor: pointer;
2365
2770
  `;
2366
- var RouteLink = forwardRef((_B, forwardedRef) => {
2367
- var _C = _B, { className, onClick = () => {
2368
- }, name = "", to = "", params = {}, children } = _C, other = __objRest(_C, ["className", "onClick", "name", "to", "params", "children"]);
2771
+ var RouteLink = forwardRef((_D, forwardedRef) => {
2772
+ var _E = _D, { className, onClick = () => {
2773
+ }, name = "", to = "", params = {}, children } = _E, other = __objRest(_E, ["className", "onClick", "name", "to", "params", "children"]);
2369
2774
  const router = useRouter();
2370
2775
  const container = useContainer();
2371
2776
  if (!router) {
@@ -2421,8 +2826,8 @@ var RouteLink = forwardRef((_B, forwardedRef) => {
2421
2826
  to: path
2422
2827
  }), children);
2423
2828
  });
2424
- var Link = forwardRef((_D, ref) => {
2425
- var _E = _D, {
2829
+ var Link = forwardRef((_F, ref) => {
2830
+ var _G = _F, {
2426
2831
  className,
2427
2832
  disabled = false,
2428
2833
  role = "link",
@@ -2437,7 +2842,7 @@ var Link = forwardRef((_D, ref) => {
2437
2842
  target,
2438
2843
  routeName,
2439
2844
  params
2440
- } = _E, other = __objRest(_E, [
2845
+ } = _G, other = __objRest(_G, [
2441
2846
  "className",
2442
2847
  "disabled",
2443
2848
  "role",
@@ -2500,9 +2905,9 @@ const StyledLink = styled.a`
2500
2905
  opacity: .7;
2501
2906
  ` : "cursor: pointer;"}
2502
2907
  `;
2503
- const Modal = forwardRef((_F, ref) => {
2504
- var _G = _F, { className, children, trigger, onOverlayClick = () => {
2505
- }, close = false } = _G, other = __objRest(_G, ["className", "children", "trigger", "onOverlayClick", "close"]);
2908
+ const Modal = forwardRef((_H, ref) => {
2909
+ var _I = _H, { className, children, trigger, onOverlayClick = () => {
2910
+ }, close = false } = _I, other = __objRest(_I, ["className", "children", "trigger", "onOverlayClick", "close"]);
2506
2911
  const [visible, toggleVisible] = useToggle();
2507
2912
  const [css2, innerRef] = useScroll(true);
2508
2913
  const closeButtonRef = useRef();
@@ -2538,7 +2943,7 @@ const Modal = forwardRef((_F, ref) => {
2538
2943
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Overlay, {
2539
2944
  visible,
2540
2945
  onClick: overlayClick
2541
- }, /* @__PURE__ */ React.createElement(Wrapper$1, __spreadProps(__spreadValues({
2946
+ }, /* @__PURE__ */ React.createElement(Wrapper$2, __spreadProps(__spreadValues({
2542
2947
  className: appendClassNames(className, "humany-modal", `humany-modal-${id.current}`),
2543
2948
  css: css2,
2544
2949
  tabIndex: -1
@@ -2557,7 +2962,7 @@ const Modal = forwardRef((_F, ref) => {
2557
2962
  }
2558
2963
  }));
2559
2964
  });
2560
- const Wrapper$1 = styled.div`
2965
+ const Wrapper$2 = styled.div`
2561
2966
  font-family: ${(p) => {
2562
2967
  var _a;
2563
2968
  return (_a = p.theme.fonts) == null ? void 0 : _a.type;
@@ -2692,7 +3097,7 @@ const NotFound = ({
2692
3097
  suggestionHeader = "",
2693
3098
  suggestion = ""
2694
3099
  }) => {
2695
- return /* @__PURE__ */ React.createElement(Wrapper, null, /* @__PURE__ */ React.createElement(Status, null, /* @__PURE__ */ React.createElement(Typography, {
3100
+ return /* @__PURE__ */ React.createElement(Wrapper$1, null, /* @__PURE__ */ React.createElement(Status, null, /* @__PURE__ */ React.createElement(Typography, {
2696
3101
  variant: "h2"
2697
3102
  }, "404")), /* @__PURE__ */ React.createElement(Header, null, /* @__PURE__ */ React.createElement(Typography, {
2698
3103
  variant: "h3"
@@ -2702,7 +3107,7 @@ const NotFound = ({
2702
3107
  text: link
2703
3108
  })), /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement("span", null, suggestionHeader), /* @__PURE__ */ React.createElement("ul", null, /* @__PURE__ */ React.createElement("li", null, suggestion))));
2704
3109
  };
2705
- const Wrapper = styled.div`
3110
+ const Wrapper$1 = styled.div`
2706
3111
  display: flex;
2707
3112
  flex-wrap: wrap;
2708
3113
  `;
@@ -2808,8 +3213,8 @@ class TabStop extends Component {
2808
3213
  });
2809
3214
  }
2810
3215
  }
2811
- var TextLink = forwardRef((_H, ref) => {
2812
- var _I = _H, { className, description, text, children } = _I, other = __objRest(_I, ["className", "description", "text", "children"]);
3216
+ var TextLink = forwardRef((_J, ref) => {
3217
+ var _K = _J, { className, description, text, children } = _K, other = __objRest(_K, ["className", "description", "text", "children"]);
2813
3218
  return /* @__PURE__ */ React.createElement(Link, __spreadProps(__spreadValues({
2814
3219
  className: appendClassNames(className, "humany-text-link")
2815
3220
  }, other), {
@@ -2849,8 +3254,8 @@ function formatDate(unformattedDate, format) {
2849
3254
  }
2850
3255
  return `${dateString} ${timeString}`;
2851
3256
  }
2852
- const Tooltip = (_J) => {
2853
- var _K = _J, { className, children, content, sticky = false } = _K, other = __objRest(_K, ["className", "children", "content", "sticky"]);
3257
+ const Tooltip = (_L) => {
3258
+ var _M = _L, { className, children, content, sticky = false } = _M, other = __objRest(_M, ["className", "children", "content", "sticky"]);
2854
3259
  const [open, setOpen] = useState(false);
2855
3260
  const id = useRef(uuid());
2856
3261
  const ref = useRef();
@@ -2995,9 +3400,9 @@ const TransitionComponent = (props) => {
2995
3400
  onEnter: (node) => node.clientHeight
2996
3401
  }, (state) => children && children(state, def && transitionComposer.compose(state, def)));
2997
3402
  };
2998
- var WidgetLink = forwardRef((_L, ref) => {
2999
- var _M = _L, { className, children, onClick = () => {
3000
- }, widgetName, activationOptions } = _M, other = __objRest(_M, ["className", "children", "onClick", "widgetName", "activationOptions"]);
3403
+ var WidgetLink = forwardRef((_N, ref) => {
3404
+ var _O = _N, { className, children, onClick = () => {
3405
+ }, widgetName, activationOptions } = _O, other = __objRest(_O, ["className", "children", "onClick", "widgetName", "activationOptions"]);
3001
3406
  const container = useContainer();
3002
3407
  const getWidget = () => {
3003
3408
  const { implementation } = container.get("$widget");
@@ -3051,6 +3456,38 @@ var WidgetLink = forwardRef((_L, ref) => {
3051
3456
  ref
3052
3457
  }), children);
3053
3458
  });
3459
+ const WidgetOverlayOutlet = forwardRef(({ portalId = "humany-widget-overlay-portal", className, children }, ref) => {
3460
+ const container = useContainer();
3461
+ const parentElement = useMemo(() => {
3462
+ if (!container)
3463
+ return null;
3464
+ const widgetDOMElement = container.get("widgetDOMElement");
3465
+ if (!widgetDOMElement || !widgetDOMElement.childElementCount)
3466
+ return null;
3467
+ return widgetDOMElement.children[0];
3468
+ }, [container]);
3469
+ if (!parentElement) {
3470
+ return null;
3471
+ }
3472
+ return /* @__PURE__ */ React.createElement(Portal, {
3473
+ elementId: portalId,
3474
+ parent: parentElement
3475
+ }, /* @__PURE__ */ React.createElement(Wrapper, {
3476
+ className: appendClassNames("humany-widget-overlay-outlet", className),
3477
+ ref
3478
+ }, children));
3479
+ });
3480
+ const Wrapper = styled.div`
3481
+ background-color: #ffffff;
3482
+ position: absolute;
3483
+ top: 0;
3484
+ left: 0;
3485
+ bottom: 0;
3486
+ right: 0;
3487
+ z-index: 10;
3488
+ width: 100%;
3489
+ height: 100%;
3490
+ `;
3054
3491
  const createReactComponent = (container, type, reactComponent, fn, options) => {
3055
3492
  return container.getAsync("componentResolver").then((componentResolver) => {
3056
3493
  componentResolver.registerComponent(type, lazy(() => reactComponent));
@@ -3058,5 +3495,5 @@ const createReactComponent = (container, type, reactComponent, fn, options) => {
3058
3495
  }), type, options);
3059
3496
  });
3060
3497
  };
3061
- export { AnchorLink, Button, Checkbox, ColumnContext, ComponentNodeContext, ComponentPropertyContext, Confirm, ContainerContext, DateFormats, Drawer, AnimationType as DrawerAnimationType, Dropdown, Empty, grid as Grid, Html, Icon, input as Input, ItemList, ItemTree, Lightbox, Link, List, Modal, NotFound, Overlay, Paragraph, Portal, RouteLink, RoutingContext, StyledText, SymbolBadge, TabStop, Text, TextLink, Timestamp, Tooltip, TransitionComponent, Typography, WidgetLink, borderTabStyle, browser, buttonCss, contentBox, convertToStringAttributes, createEmptyComponent, createReactComponent, defaultRenderInstructions, embeddedLinkMapper, filterCssProps, filterCssPropsStyle, genericHashLink, genericHtml, headingElement, invertedHoverButton, itemList, linkTabStyle, list, paddedBorderTabStyle, parseHtmlString as processHtmlString, transitionComposer, useAction, useChildren, useColumns, useComponent, useComponentDescriptor, useComponentNode, useComponentPlatform, useContainer, useContext, useDispatch, useEventListener, useEvents, useIsMounted, useKeyPress, useLayout, usePrevious, useProperties, useRenderState, useRouteData, useRouter, useScroll, useSettings, useToggle, useTransitionEnd, useUniqueMenu, useWidgetEvent };
3498
+ export { AnchorLink, Button, Checkbox, ColumnContext, ComponentNodeContext, ComponentPropertyContext, Confirm, ContainerContext, DateFormats, Drawer, AnimationType as DrawerAnimationType, Dropdown, Empty, grid as Grid, Html, Icon, input as Input, ItemList, ItemTree, Lightbox, Link, List, Modal, NotFound, Overlay, Paragraph, Portal, RouteLink, RoutingContext, StyledText, SymbolBadge, TabStop, Text, TextLink, Timestamp, Tooltip, TransitionComponent, Typography, WidgetLink, WidgetOverlayOutlet, borderTabStyle, browser, buttonCss, contentBox, convertToStringAttributes, createEmptyComponent, createReactComponent, defaultRenderInstructions, embeddedLinkMapper, filterCssProps, filterCssPropsStyle, genericHashLink, genericHtml, headingElement, invertedHoverButton, itemList, linkTabStyle, list, paddedBorderTabStyle, parseHtmlString as processHtmlString, transitionComposer, useAction, useChildren, useColumns, useComponent, useComponentDescriptor, useComponentNode, useComponentPlatform, useContainer, useContext, useDispatch, useEventListener, useEvents, useIsMounted, useKeyPress, useLayout, usePrevious, useProperties, useRenderState, useRouteData, useRouter, useScroll, useSettings, useToggle, useTransitionEnd, useUniqueMenu, useWidgetEvent };
3062
3499
  //# sourceMappingURL=index.js.map