@edvisor/product-language 0.10.0 → 0.10.3

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
@@ -8548,50 +8548,10 @@ const topPosition = props => {
8548
8548
  return '4px';
8549
8549
  };
8550
8550
 
8551
- const OptionItem = /*#__PURE__*/styled(SpaceBetween).withConfig({
8552
- displayName: "option__OptionItem",
8553
- componentId: "sc-1hb1qjt-0"
8554
- })(["flex:1;height:", "px;min-width:0;cursor:pointer;box-sizing:border-box;margin:", ";border-radius:6px;background-clip:content-box;background-color:", ";& div{padding:", " ", ";}& i:last-child{right:8px;}&:hover{background-color:", ";}&:active{background-color:", ";}"], props => defaultTo(props.height, DEFAULT_ROW_HEIGHT), Margin.xxs, props => is(props.active) ? Surface.Selected.Default : is(props.selected) ? Surface.Default.Hover : Surface.Default.Default, Padding.none, Padding.xs, props => is(props.active) ? Surface.Selected.Hover : Surface.Default.Hover, props => is(props.active) ? Surface.Selected.Pressed : Surface.Default.Pressed);
8555
- const CheckedIcon$1 = /*#__PURE__*/styled(IconMinor.Check).withConfig({
8556
- displayName: "option__CheckedIcon",
8557
- componentId: "sc-1hb1qjt-1"
8558
- })(["svg{path{fill:", "}}"], Icons.Highlight);
8559
- const OptionComponent = /*#__PURE__*/memo(props => {
8560
- const onClick = () => {
8561
- props.onSelect(props.option.value, props.option);
8562
- };
8563
-
8564
- const {
8565
- active,
8566
- selected,
8567
- labelComponent,
8568
- option,
8569
- height
8570
- } = props;
8571
- const SelectLabel = isDefined(labelComponent) ? labelComponent : Label$1;
8572
- const className = ['option', props.className, is(selected) ? 'selected' : '', is(active) ? 'active' : ''].filter(v => Boolean(v));
8573
- return jsxs(OptionItem, Object.assign({
8574
- className: className.join(' '),
8575
- "data-role": "option",
8576
- center: true,
8577
- selected: selected,
8578
- active: active,
8579
- height: height,
8580
- onClick: onClick
8581
- }, {
8582
- children: [jsx(SelectLabel, Object.assign({
8583
- type: "option",
8584
- active: active
8585
- }, option, {
8586
- children: option.label
8587
- })), is(active) && jsx(CheckedIcon$1, {})]
8588
- }));
8589
- }, areEqual);
8590
-
8591
8551
  const MenuWrapper = /*#__PURE__*/styled.div.withConfig({
8592
8552
  displayName: "menu-container__MenuWrapper",
8593
8553
  componentId: "dadn7s-0"
8594
- })(["z-index:1;position:relative;background:", ";top:", ";box-sizing:border-box;.menu-list{box-sizing:border-box;box-shadow:", ";border:1px solid ", ";background-color:", ";border-radius:6px;opacity:0;transition:opacity 0.1s ease;padding:", ";&:focus{outline:none;}::-webkit-scrollbar{width:6px;height:8px;}::-webkit-scrollbar-thumb{border-radius:4px;background:", ";min-height:50px;}}"], Surface.Default.Default, props => topPosition(props), props => props.menuPosition === "bottom"
8554
+ })(["z-index:1;position:relative;background:", ";top:", ";box-sizing:border-box;.menu-list{box-sizing:border-box;box-shadow:", ";border:1px solid ", ";background-color:", ";border-radius:6px;opacity:0;transition:opacity 0.1s ease;padding:", ";&:focus{outline:none;}::-webkit-scrollbar{width:10px;height:0;}::-webkit-scrollbar-thumb{min-height:50px;border:2px solid rgba(0,0,0,0);background-clip:padding-box;border-radius:1em;background-color:", ";}::-webkit-scrollbar-corner{background-color:transparent;}}"], Surface.Default.Default, props => topPosition(props), props => props.menuPosition === "bottom"
8595
8555
  /* menuPositionType.BOTTOM */
8596
8556
  ? '0px 2px 10px 0px rgba(0, 0, 0, 0.10)' : '0px -2px 10px 0px rgba(0, 0, 0, 0.10)', Borders.Default.Subdued, Surface.Default.Default, Padding.xxs, Surface.Neutral.Default);
8597
8557
  const MenuContainer = props => {
@@ -8655,6 +8615,55 @@ fixRegExpWellKnownSymbolLogic('search', function (SEARCH, nativeSearch, maybeCal
8655
8615
  ];
8656
8616
  });
8657
8617
 
8618
+ const OptionItem = /*#__PURE__*/styled(SpaceBetween).withConfig({
8619
+ displayName: "helpers__OptionItem",
8620
+ componentId: "sc-15t2iwx-0"
8621
+ })(["flex:1;height:", "px;min-width:0;cursor:pointer;box-sizing:border-box;margin:", ";border-radius:6px;background-clip:content-box;background-color:", ";& div{padding:", " ", ";}& i:last-child{right:8px;}&:hover{background-color:", ";}&:active{background-color:", ";}"], props => defaultTo(props.height, DEFAULT_ROW_HEIGHT), Margin.xxs, props => is(props.active) ? Surface.Selected.Default : is(props.selected) ? Surface.Default.Hover : Surface.Default.Default, Padding.none, Padding.xs, props => is(props.active) ? Surface.Selected.Hover : Surface.Default.Hover, props => is(props.active) ? Surface.Selected.Pressed : Surface.Default.Pressed);
8622
+ const EmptyOptionItem = /*#__PURE__*/styled(OptionItem).withConfig({
8623
+ displayName: "helpers__EmptyOptionItem",
8624
+ componentId: "sc-15t2iwx-1"
8625
+ })(["border:1px solid ", ";background-color:", ";position:absolute;margin:", ";width:100%;height:54px;box-shadow:", ";&:hover{background-color:", ";}"], Borders.Default.Subdued, Surface.Default.Default, Margin.none, ({
8626
+ props
8627
+ }) => props.menuPosition === "bottom"
8628
+ /* menuPositionType.BOTTOM */
8629
+ ? '0px 2px 10px 0px rgba(0, 0, 0, 0.10)' : '0px -2px 10px 0px rgba(0, 0, 0, 0.10)', Surface.Default.Default);
8630
+
8631
+ const CheckedIcon$1 = /*#__PURE__*/styled(IconMinor.Check).withConfig({
8632
+ displayName: "option__CheckedIcon",
8633
+ componentId: "sc-1hb1qjt-0"
8634
+ })(["svg{path{fill:", "}}"], Icons.Highlight);
8635
+ const OptionComponent = /*#__PURE__*/memo(props => {
8636
+ const onClick = () => {
8637
+ props.onSelect(props.option.value, props.option);
8638
+ };
8639
+
8640
+ const {
8641
+ active,
8642
+ selected,
8643
+ labelComponent,
8644
+ option,
8645
+ height
8646
+ } = props;
8647
+ const SelectLabel = isDefined(labelComponent) ? labelComponent : Label$1;
8648
+ const className = ['option', props.className, is(selected) ? 'selected' : '', is(active) ? 'active' : ''].filter(v => Boolean(v));
8649
+ return jsxs(OptionItem, Object.assign({
8650
+ className: className.join(' '),
8651
+ "data-role": "option",
8652
+ center: true,
8653
+ selected: selected,
8654
+ active: active,
8655
+ height: height,
8656
+ onClick: onClick
8657
+ }, {
8658
+ children: [jsx(SelectLabel, Object.assign({
8659
+ type: "option",
8660
+ active: active
8661
+ }, option, {
8662
+ children: option.label
8663
+ })), is(active) && jsx(CheckedIcon$1, {})]
8664
+ }));
8665
+ }, areEqual);
8666
+
8658
8667
  const MenuRow$1 = /*#__PURE__*/memo(({
8659
8668
  index,
8660
8669
  style,
@@ -8691,14 +8700,6 @@ const SelectLabel = /*#__PURE__*/styled(Label$1).withConfig({
8691
8700
  componentId: "j60pki-0"
8692
8701
  })(["overflow:hidden;white-space:nowrap;text-overflow:ellipsis;user-select:none;box-sizing:border-box;"]);
8693
8702
 
8694
- const EmptyOptionItem = /*#__PURE__*/styled(OptionItem).withConfig({
8695
- displayName: "menu__EmptyOptionItem",
8696
- componentId: "sc-1086ljy-0"
8697
- })(["border:1px solid ", ";background-color:", ";position:absolute;margin:", ";width:100%;height:54px;box-shadow:", ";&:hover{background-color:", ";}"], Borders.Default.Subdued, Surface.Default.Default, Margin.none, ({
8698
- props
8699
- }) => props.menuPosition === "bottom"
8700
- /* menuPositionType.BOTTOM */
8701
- ? '0px 2px 10px 0px rgba(0, 0, 0, 0.10)' : '0px -2px 10px 0px rgba(0, 0, 0, 0.10)', Surface.Default.Default);
8702
8703
  const Menu = props => {
8703
8704
  const {
8704
8705
  rowHeight = DEFAULT_ROW_HEIGHT,
@@ -8913,7 +8914,7 @@ const ValueWrapper$1 = /*#__PURE__*/styled(Flex).withConfig({
8913
8914
  const ValueLabel = /*#__PURE__*/styled(Label$1).withConfig({
8914
8915
  displayName: "value__ValueLabel",
8915
8916
  componentId: "sc-1aps7dx-2"
8916
- })(["padding-left:", ";margin-bottom:", ";display:flex;align-self:", ";width:fit-content;white-space:pre;", ""], Padding.xs, ({
8917
+ })(["padding-left:", ";margin-bottom:", ";display:flex;align-self:", ";width:fit-content;white-space:pre;", ""], Padding.s, ({
8917
8918
  labelPosition
8918
8919
  }) => labelPosition === "top"
8919
8920
  /* labelPositionType.TOP */
@@ -8929,7 +8930,7 @@ const ValueLabel = /*#__PURE__*/styled(Label$1).withConfig({
8929
8930
  const ValueLeft = /*#__PURE__*/styled(Flex).withConfig({
8930
8931
  displayName: "value__ValueLeft",
8931
8932
  componentId: "sc-1aps7dx-3"
8932
- })(["padding-left:", ";width:100%;flex-wrap:", ";user-select:none;min-width:0;min-height:20px;box-sizing:border-box;gap:", ";"], Padding.xs, props => is(props.multi) && is(props.hasValue) ? 'wrap' : 'nowrap', props => is(props.multi) ? '4px' : 0);
8933
+ })(["padding-left:", ";width:100%;flex-wrap:", ";user-select:none;min-width:0;min-height:20px;box-sizing:border-box;gap:", ";"], Padding.s, props => is(props.multi) && is(props.hasValue) ? 'wrap' : 'nowrap', props => is(props.multi) ? '4px' : 0);
8933
8934
  const ValueRight = /*#__PURE__*/styled(Flex).withConfig({
8934
8935
  displayName: "value__ValueRight",
8935
8936
  componentId: "sc-1aps7dx-4"
@@ -9458,11 +9459,11 @@ const Select = forwardRef(SelectImpl);
9458
9459
  const MenuListFrame = /*#__PURE__*/styled.div.withConfig({
9459
9460
  displayName: "menu-list__MenuListFrame",
9460
9461
  componentId: "sxh4rn-0"
9461
- })(["border:1px solid ", ";background-color:", ";position:absolute;width:100%;width:-moz-available;width:-webkit-fill-available;max-height:184px;overflow-y:auto;overflow-x:hidden;::-webkit-scrollbar{width:6px;height:8px;}::-webkit-scrollbar-thumb{border-radius:4px;background:", ";min-height:50px;}", ";"], Borders.Default.Subdued, Surface.Default.Default, Surface.Neutral.Default, shadowMd);
9462
+ })(["border:1px solid ", ";background-color:", ";position:absolute;height:", "px;max-height:", "px;width:100%;width:-moz-available;width:-webkit-fill-available;overflow-y:auto;overflow-x:hidden;::-webkit-scrollbar{width:10px;height:0;}::-webkit-scrollbar-thumb{min-height:50px;border:2px solid rgba(0,0,0,0);background-clip:padding-box;border-radius:1em;background-color:", ";}::-webkit-scrollbar-corner{background-color:transparent;}", ";"], Borders.Default.Subdued, Surface.Default.Default, props => props.height, props => props.height, Surface.Neutral.Default, shadowMd);
9462
9463
  const MenuRow = /*#__PURE__*/styled(SpaceBetween).withConfig({
9463
9464
  displayName: "menu-list__MenuRow",
9464
9465
  componentId: "sxh4rn-1"
9465
- })([" border:none;text-align:left;padding:", ";margin:", " ", ";background-color:", ";border-radius:6px;i:first-child{align-self:start;margin-right:", ";}i:last-child{align-self:center;}&:first-of-type{margin-top:", ";}&:last-of-type{margin-bottom:", ";}&:hover{background-color:", ";}&:hover{background-color:", ";}&:active{background-color:", ";}"], Padding.s, Margin.none, Margin.xxs, props => is(props.active) ? Surface.Selected.Default : Surface.Default.Default, Margin.xs, Margin.xxs, Margin.xxs, Surface.Default.Hover, props => is(props.active) ? Surface.Selected.Hover : Surface.Default.Hover, props => is(props.active) ? Surface.Selected.Pressed : Surface.Default.Pressed);
9466
+ })([" border:none;text-align:left;padding:", ";margin:", " ", ";background-color:", ";border-radius:6px;i:first-child{align-self:start;margin-right:", ";}i:last-child{align-self:center;}&:first-of-type{margin-top:", ";}&:last-of-type{margin-bottom:", ";}&:hover{background-color:", ";}&:hover{background-color:", ";}&:active{background-color:", ";}"], Padding.s, Margin.none, Margin.xxs, props => is(props.active) ? Surface.Selected.Default : Surface.Default.Default, Margin.s, Margin.xxs, Margin.xxs, Surface.Default.Hover, props => is(props.active) ? Surface.Selected.Hover : Surface.Default.Hover, props => is(props.active) ? Surface.Selected.Pressed : Surface.Default.Pressed);
9466
9467
  const OptionLabel = /*#__PURE__*/styled(Label$1).withConfig({
9467
9468
  displayName: "menu-list__OptionLabel",
9468
9469
  componentId: "sxh4rn-2"
@@ -9478,7 +9479,7 @@ const ValueWrapper = /*#__PURE__*/styled.div.withConfig({
9478
9479
  const TitleRow = /*#__PURE__*/styled(Heading4).withConfig({
9479
9480
  displayName: "menu-list__TitleRow",
9480
9481
  componentId: "sxh4rn-5"
9481
- })(["height:30px;margin:", " ", ";border-bottom:1px solid ", ";padding:", " ", " ", " ", ";"], Margin.none, Margin.xxs, Borders.Default.Subdued, Padding.s, Padding.none, Padding.none, Padding.s);
9482
+ })(["height:44px;margin:", " ", ";border-bottom:1px solid ", ";display:flex;align-items:center;padding-left:", ";"], Margin.none, Margin.xxs, Borders.Default.Subdued, Padding.s);
9482
9483
 
9483
9484
  const Row = props => {
9484
9485
  const {
@@ -9511,7 +9512,15 @@ const Row = props => {
9511
9512
  };
9512
9513
 
9513
9514
  const MenuList = props => {
9514
- // eslint-disable-next-line no-null/no-null
9515
+ const {
9516
+ menuHeight = 184
9517
+ } = props;
9518
+ const options = safeArray(props.options);
9519
+ const optionsHeight = options.reduce(function (acc, obj) {
9520
+ return acc + (isDefined(obj['helperText']) ? 72 : 52);
9521
+ }, 0);
9522
+ const height = Math.min(Math.max(optionsHeight, 40), menuHeight); // eslint-disable-next-line no-null/no-null
9523
+
9515
9524
  const list = useRef(null); // const { open, selectedIndex, rowHeight } = props
9516
9525
 
9517
9526
  const handleClick = option => {
@@ -9529,10 +9538,26 @@ const MenuList = props => {
9529
9538
  */
9530
9539
 
9531
9540
 
9541
+ if (options.length === 0) {
9542
+ const {
9543
+ emptyText
9544
+ } = props;
9545
+ return jsx(EmptyOptionItem, Object.assign({
9546
+ props: props
9547
+ }, {
9548
+ children: jsx(SelectLabel, {
9549
+ children: jsx("span", {
9550
+ children: defaultTo(emptyText, DEFAULT_EMPTY_TEXT)
9551
+ })
9552
+ })
9553
+ }));
9554
+ }
9555
+
9532
9556
  return jsxs(MenuListFrame, Object.assign({
9557
+ height: height,
9533
9558
  ref: list
9534
9559
  }, {
9535
- children: [maybeRender(props.menuTitle, jsx(TitleRow, {
9560
+ children: [maybeRender(isDefined(props.menuTitle) && (isNil(props.search) || isEmpty(props.search)), jsx(TitleRow, {
9536
9561
  children: props.menuTitle
9537
9562
  })), safeArray(props.options).map((_, index) => jsx(Row, Object.assign({
9538
9563
  index: index,
@@ -0,0 +1,17 @@
1
+ import { IMenuComponentProps, IOptionComponentProps } from '../types';
2
+ interface IOptionItemProps {
3
+ active?: IOptionComponentProps['active'];
4
+ selected?: IOptionComponentProps['selected'];
5
+ height?: IOptionComponentProps['height'];
6
+ }
7
+ export declare const OptionItem: import("styled-components").StyledComponent<"div", any, {
8
+ column?: boolean | undefined;
9
+ center?: boolean | undefined;
10
+ } & IOptionItemProps, never>;
11
+ export declare const EmptyOptionItem: import("styled-components").StyledComponent<"div", any, {
12
+ column?: boolean | undefined;
13
+ center?: boolean | undefined;
14
+ } & IOptionItemProps & {
15
+ props: IMenuComponentProps;
16
+ }, never>;
17
+ export {};
@@ -1,13 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { IOptionComponentProps } from '../types';
3
- interface IOptionItemProps {
4
- active?: IOptionComponentProps['active'];
5
- selected?: IOptionComponentProps['selected'];
6
- height?: IOptionComponentProps['height'];
7
- }
8
- export declare const OptionItem: import("styled-components").StyledComponent<"div", any, {
9
- column?: boolean | undefined;
10
- center?: boolean | undefined;
11
- } & IOptionItemProps, never>;
12
3
  export declare const OptionComponent: import("react").MemoExoticComponent<(props: IOptionComponentProps) => JSX.Element>;
13
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edvisor/product-language",
3
- "version": "0.10.0",
3
+ "version": "0.10.3",
4
4
  "license": "MIT",
5
5
  "description": "Edvisor.io product-language components",
6
6
  "repository": "https://github.com/edvisor-io/front-end/",