@edvisor/product-language 0.8.3 → 0.8.5

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/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
2
  import styled, { css, keyframes } from 'styled-components';
3
- import { isFunction, isString, first } from 'lodash';
3
+ import { isFunction, uniqueId, isString, first } from 'lodash';
4
4
  import React, { PureComponent, Children, useState, useEffect, useRef, memo, useMemo, createRef, useCallback, Fragment as Fragment$1 } from 'react';
5
5
  import { areEqual, FixedSizeList } from 'react-window';
6
6
  import { Calendar as Calendar$1, DateObject } from 'react-multi-date-picker';
@@ -8829,6 +8829,23 @@ const ValueComponentSingle = props => {
8829
8829
 
8830
8830
  var ValueComponentSingle$1 = /*#__PURE__*/memo(ValueComponentSingle);
8831
8831
 
8832
+ const valueStyles = ({
8833
+ canSearch
8834
+ }) => ({
8835
+ minWidth: '1px',
8836
+ marginLeft: '-1px',
8837
+ userSelect: 'text',
8838
+ opacity: is(canSearch) ? 1 : 0,
8839
+ position: is(canSearch) ? 'relative' : 'absolute',
8840
+ left: is(canSearch) ? '1px' : '0',
8841
+ outline: 'none',
8842
+ fontFamily: 'Inter',
8843
+ fontWeight: 400,
8844
+ fontSize: '14px',
8845
+ lineHeight: '20px',
8846
+ color: `${Text$1.Default}`
8847
+ });
8848
+
8832
8849
  const ValueContainer = /*#__PURE__*/styled(SpaceBetween).withConfig({
8833
8850
  displayName: "value__ValueContainer",
8834
8851
  componentId: "sc-1aps7dx-0"
@@ -8886,13 +8903,9 @@ const ClearButton = /*#__PURE__*/styled(Button).attrs({
8886
8903
  displayName: "value__ClearButton",
8887
8904
  componentId: "sc-1aps7dx-6"
8888
8905
  })(["padding:", ";margin-right:", ";gap:0;&:focus{outline:none;}&:active{background-color:transparent;}"], Padding.none, Margin.none);
8889
- const Search = /*#__PURE__*/styled.span.withConfig({
8890
- displayName: "value__Search",
8891
- componentId: "sc-1aps7dx-7"
8892
- })(["min-width:1px;margin-left:-1px;user-select:text;", " &:focus{outline:none;}"], props => is(props.canSearch) ? css(["opacity:1;position:relative;left:1px;"]) : css(["position:absolute;opacity:0;"]));
8893
8906
  const ErrorMessage = /*#__PURE__*/styled.div.withConfig({
8894
8907
  displayName: "value__ErrorMessage",
8895
- componentId: "sc-1aps7dx-8"
8908
+ componentId: "sc-1aps7dx-7"
8896
8909
  })(["display:", ";flex-direction:'row';width:100%;padding:", " ", ";& path{fill:", ";}div{color:", ";margin:", " ", "}"], props => is(props.visible) ? 'flex' : 'none', Padding.xxs, Padding.none, Icons.Critical, Text$1.Critical, Margin.none, Margin.xxs);
8897
8910
 
8898
8911
  const Value = props => {
@@ -8934,10 +8947,21 @@ const Value = props => {
8934
8947
  }
8935
8948
 
8936
8949
  const canSearch = open && is(searchable) || !isDefined(value) && is(searchable) || isDefined(search.current);
8937
- return jsx(Search, {
8950
+ /**
8951
+ * @TODO this is a hack to be able to use the ref in react-web-client
8952
+ * RWC uses styled-components < v4 and expects the ref to be passes as
8953
+ * "innerRef" not just "ref", but product-language uses > v4 and wants
8954
+ * to use ref. So for some components that need a ref, like this one
8955
+ * we will have to use a div and style it the old fashioned way until
8956
+ * we upgrade rwc's styled-components or drop rwc
8957
+ */
8958
+
8959
+ return jsx("span", {
8938
8960
  className: "search",
8939
8961
  contentEditable: true,
8940
- canSearch: canSearch,
8962
+ style: Object.assign({}, valueStyles({
8963
+ canSearch
8964
+ })),
8941
8965
  onInput: onSearch,
8942
8966
  onKeyDown: onKeyDown,
8943
8967
  onFocus: onSearchFocus,
@@ -9941,6 +9965,96 @@ const TreeView = props => {
9941
9965
  return maybeRender(!isEmpty(nodes), renderTree());
9942
9966
  };
9943
9967
 
9968
+ var TooltipPosition;
9969
+
9970
+ (function (TooltipPosition) {
9971
+ TooltipPosition[TooltipPosition["TOP"] = 0] = "TOP";
9972
+ TooltipPosition[TooltipPosition["BOTTOM"] = 1] = "BOTTOM";
9973
+ TooltipPosition[TooltipPosition["LEFT"] = 2] = "LEFT";
9974
+ TooltipPosition[TooltipPosition["RIGHT"] = 3] = "RIGHT";
9975
+ })(TooltipPosition || (TooltipPosition = {}));
9976
+
9977
+ const TooltipWrapper = /*#__PURE__*/styled.div.withConfig({
9978
+ displayName: "tooltip__TooltipWrapper",
9979
+ componentId: "sc-1rhmjz7-0"
9980
+ })(["position:relative;display:inline-flex;"]);
9981
+
9982
+ const getContainerPosition = tooltipPosition => {
9983
+ const position = {
9984
+ TOP: css([""]),
9985
+ BOTTOM: css(["top:calc(100% + 5px);"]),
9986
+ LEFT: css(["margin-right:", ";width:100%;left:unset;top:50%;right:calc(100% + 5px);"], Margin.none),
9987
+ RIGHT: css(["margin-left:", ";width:100%;top:50%;left:calc(100% + 5px);"], Margin.none)
9988
+ };
9989
+ const key = TooltipPosition[tooltipPosition];
9990
+ return position[key];
9991
+ };
9992
+
9993
+ const getTooltipBoxPosition = tooltipPosition => {
9994
+ const position = {
9995
+ TOP: css([""]),
9996
+ BOTTOM: css(["&:after{border-color:transparent transparent ", " transparent;top:unset;width:1px;bottom:100%;left:calc(50% - 5px);}"], Surface.Default.Inverse),
9997
+ LEFT: css(["&:after{border-color:transparent transparent transparent ", ";left:100%;top:calc(50% - 5px);}"], Surface.Default.Inverse),
9998
+ RIGHT: css(["&:after{border-color:transparent ", " transparent transparent;right:100%;left:unset;top:calc(50% - 5px);}"], Surface.Default.Inverse)
9999
+ };
10000
+ const key = TooltipPosition[tooltipPosition];
10001
+ return position[key];
10002
+ };
10003
+
10004
+ const CenterContainer = /*#__PURE__*/styled.div.withConfig({
10005
+ displayName: "tooltip__CenterContainer",
10006
+ componentId: "sc-1rhmjz7-1"
10007
+ })(["position:absolute;width:", ";margin-left:", ";display:flex;justify-content:center;align-items:center;left:50%;bottom:", ";pointer-events:none;", ""], ({
10008
+ width
10009
+ }) => isDefined(width) ? `${width}px` : '100%', ({
10010
+ width
10011
+ }) => isDefined(width) ? `-${width / 2}px` : '-50%', ({
10012
+ position
10013
+ }) => position === TooltipPosition.BOTTOM ? 'unset' : 'calc(100% + 5px)', ({
10014
+ position
10015
+ }) => getContainerPosition(position));
10016
+ const fadeIn$1 = /*#__PURE__*/keyframes(["from{opacity:0;}to{opacity:1;}"]);
10017
+ const TooltipBox = /*#__PURE__*/styled.div.withConfig({
10018
+ displayName: "tooltip__TooltipBox",
10019
+ componentId: "sc-1rhmjz7-2"
10020
+ })(["position:relative;background-color:", ";color:", ";text-align:center;border-radius:6px;padding:", " ", ";animation:", " 0.1s linear;&:after{content:\"\";position:absolute;width:1px;height:1px;border-width:5px;border-style:solid;border-color:", " transparent transparent transparent;left:calc(50% - 4.5px);top:100%;}", ""], Surface.Default.Inverse, Surface.Default.Default, Padding.xxs, Padding.xs, fadeIn$1, Surface.Default.Inverse, ({
10021
+ position
10022
+ }) => getTooltipBoxPosition(position));
10023
+ const Tooltip = props => {
10024
+ const {
10025
+ position = TooltipPosition.TOP,
10026
+ content,
10027
+ width,
10028
+ children,
10029
+ style,
10030
+ className
10031
+ } = props;
10032
+ const [isHovered, setIsHovered] = useState(false);
10033
+ const id = uniqueId('tooltip-');
10034
+ return jsxs(TooltipWrapper, {
10035
+ children: [jsx("span", Object.assign({
10036
+ onMouseEnter: () => setIsHovered(true),
10037
+ onMouseLeave: () => setIsHovered(false)
10038
+ }, {
10039
+ children: children
10040
+ })), isHovered && jsx(CenterContainer, Object.assign({
10041
+ role: "tooltip",
10042
+ id: id,
10043
+ position: position,
10044
+ width: width
10045
+ }, {
10046
+ children: jsx(TooltipBox, Object.assign({
10047
+ "aria-describedby": id,
10048
+ style: style,
10049
+ className: className,
10050
+ position: position
10051
+ }, {
10052
+ children: content
10053
+ }))
10054
+ }))]
10055
+ });
10056
+ };
10057
+
9944
10058
  /**
9945
10059
  * For a reasonable description of the class names etc,
9946
10060
  * @see https://shahabyazdi.github.io/react-multi-date-picker/classes-&-styles/
@@ -10641,16 +10755,16 @@ function useKeyDown(targetKey, handler) {
10641
10755
  return;
10642
10756
  }
10643
10757
 
10644
- const fadeIn = /*#__PURE__*/keyframes(["from{opacity:0;}to{opacity:1;}"]);
10758
+ const fadeIn = /*#__PURE__*/keyframes(["from{opacity:.4;}to{opacity:1;}"]);
10645
10759
  const grow = /*#__PURE__*/keyframes(["from{transform:scale(.8)}to{transform:scale(1)}"]);
10646
10760
  const OverlayFrame = /*#__PURE__*/styled(Flex).withConfig({
10647
10761
  displayName: "modal-base__OverlayFrame",
10648
10762
  componentId: "r4sytz-0"
10649
- })(["position:fixed;top:0;left:0;width:100%;height:100vh;z-index:20000;background-color:", ";justify-content:center;animation:", " .1s ease-out;"], Background.Overlay, fadeIn);
10763
+ })(["position:fixed;top:0;left:0;width:100%;height:100%;z-index:20000;background-color:", ";justify-content:center;animation:", " .2s ease-out;"], Background.Overlay, fadeIn);
10650
10764
  const ModalFrame = /*#__PURE__*/styled(Flex).withConfig({
10651
10765
  displayName: "modal-base__ModalFrame",
10652
10766
  componentId: "r4sytz-1"
10653
- })(["background-color:", ";z-index:20010;width:", ";position:fixed;transform:translate(-50%,-50%);", ";border-radius:8px;animation:", " .1s ease-in;"], Surface.Default.Default, ({
10767
+ })(["background-color:", ";z-index:20010;width:", ";", ";border-radius:8px;animation:", " .1s ease-in;"], Surface.Default.Default, ({
10654
10768
  widthValue
10655
10769
  }) => widthValue, shadowXl, grow);
10656
10770
  const modalSizeToPixelSize = {
@@ -11087,4 +11201,4 @@ const ChoiceList = props => {
11087
11201
  });
11088
11202
  };
11089
11203
 
11090
- export { Actions, AlertBanner, Avatar, BODY, BODY_LARGE, Background, Badge, Body, BodyLarge, Borders, Button, CAPTION, Caption, Card, CardFrame$1 as CardFrame, Center, Checkbox, ChoiceList, DatePicker, Display, Divider, Flag, Flex, Focused, Gap, HTMLAnchor, HTMLInput, Heading1, Heading2, Heading3, Heading4, Icon, IconMinor, Icons, InputCheckbox, InputField$1 as InputField, InputNumber, InputText, Interactive, LABEL, Label$1 as Label, LeftRightCard, Link, Margin, MenuList, Modal, ModalBase, ModalDestructive, MultiChoiceList, Padding, Radio, RadioButton$1 as RadioButton, RangeSlider, Select, Slider, SpaceAround, SpaceBetween, Spinner, Surface, Tab$1 as Tab, Tabs, Tag, Text$1 as Text, Thumbnail, TreeView, Typography, _Typography, gridLayoutGenerator, leftRightLayoutGenerator, shadow, shadow2Xl, shadowInner, shadowLg, shadowMd, shadowSm, shadowXl };
11204
+ export { Actions, AlertBanner, Avatar, BODY, BODY_LARGE, Background, Badge, Body, BodyLarge, Borders, Button, CAPTION, Caption, Card, CardFrame$1 as CardFrame, Center, CenterContainer, Checkbox, ChoiceList, DatePicker, Display, Divider, Flag, Flex, Focused, Gap, HTMLAnchor, HTMLInput, Heading1, Heading2, Heading3, Heading4, Icon, IconMinor, Icons, InputCheckbox, InputField$1 as InputField, InputNumber, InputText, Interactive, LABEL, Label$1 as Label, LeftRightCard, Link, Margin, MenuList, Modal, ModalBase, ModalDestructive, MultiChoiceList, Padding, Radio, RadioButton$1 as RadioButton, RangeSlider, Select, Slider, SpaceAround, SpaceBetween, Spinner, Surface, Tab$1 as Tab, Tabs, Tag, Text$1 as Text, Thumbnail, Tooltip, TooltipBox, TooltipPosition, TooltipWrapper, TreeView, Typography, _Typography, gridLayoutGenerator, leftRightLayoutGenerator, shadow, shadow2Xl, shadowInner, shadowLg, shadowMd, shadowSm, shadowXl };
@@ -16,6 +16,7 @@ export * from './flag';
16
16
  export * from './spinner';
17
17
  export * from './select';
18
18
  export * from './tree-view';
19
+ export * from './tooltip';
19
20
  export * from './date-picker';
20
21
  export * from './range-slider';
21
22
  export * from './modal';
@@ -0,0 +1 @@
1
+ export * from './tooltip';
@@ -0,0 +1,26 @@
1
+ import { FC } from '@helpers';
2
+ import { CSSProperties, ReactNode } from 'react';
3
+ export declare enum TooltipPosition {
4
+ TOP = 0,
5
+ BOTTOM = 1,
6
+ LEFT = 2,
7
+ RIGHT = 3
8
+ }
9
+ export declare const TooltipWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
10
+ export declare const CenterContainer: import("styled-components").StyledComponent<"div", any, {
11
+ position: TooltipPosition;
12
+ width?: number | undefined;
13
+ }, never>;
14
+ export declare const TooltipBox: import("styled-components").StyledComponent<"div", any, {
15
+ position: TooltipPosition;
16
+ }, never>;
17
+ interface ITooltip {
18
+ position?: TooltipPosition;
19
+ content: ReactNode;
20
+ children: ReactNode;
21
+ width?: number;
22
+ className?: string;
23
+ style?: CSSProperties;
24
+ }
25
+ export declare const Tooltip: FC<ITooltip>;
26
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edvisor/product-language",
3
- "version": "0.8.3",
3
+ "version": "0.8.5",
4
4
  "license": "MIT",
5
5
  "description": "Edvisor.io product-language components",
6
6
  "repository": "https://github.com/edvisor-io/front-end/",