@edvisor/product-language 0.4.2 → 0.4.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
@@ -5987,7 +5987,7 @@ const HelpText = /*#__PURE__*/styled(Body).withConfig({
5987
5987
  const ErrorMessage$1 = /*#__PURE__*/styled(Flex).withConfig({
5988
5988
  displayName: "labeled-input__ErrorMessage",
5989
5989
  componentId: "a0ln2j-3"
5990
- })(["margin-bottom:", ";& path{fill:", ";}"], Margin.xxs, Icons.Warning);
5990
+ })(["margin-bottom:", ";& path{fill:", ";}div{color:", ";}"], Margin.xxs, Icons.Critical, Text$1.Critical);
5991
5991
  const LabeledInput = props => {
5992
5992
  return jsxs(HTMLLabel, {
5993
5993
  children: [jsxs("label", {
@@ -6045,13 +6045,13 @@ const Stepper = props => {
6045
6045
  const FancyBorder = /*#__PURE__*/styled(SpaceBetween).withConfig({
6046
6046
  displayName: "input-field__FancyBorder",
6047
6047
  componentId: "sc-1yq0rb7-0"
6048
- })(["background:", ";border:1px solid ", ";border-radius:6px;box-sizing:border-box;margin-bottom:", ";padding-left:", ";user-select:none;:focus,:focus-within,:active{border:", ";}"], ({
6048
+ })(["background:", ";border:1px solid ", ";border-radius:6px;box-sizing:border-box;margin-bottom:", ";padding-left:", ";user-select:none;outline-offset:-2px;", "}"], ({
6049
6049
  invalid
6050
6050
  }) => is(invalid) ? Surface.Critical.Subdued : Surface.Default.Default, ({
6051
6051
  invalid
6052
6052
  }) => is(invalid) ? Borders.Critical.Default : Borders.Default.Default, Margin.xxs, Padding.s, ({
6053
6053
  invalid
6054
- }) => is(invalid) ? `1px solid ${Borders.Critical.Default}` : `2px solid ${Focused.Default}`);
6054
+ }) => !is(invalid) && css([":focus,:focus-within,:active{outline:2px solid ", "}"], Focused.Default));
6055
6055
  const InputLayout = /*#__PURE__*/styled(Flex).withConfig({
6056
6056
  displayName: "input-field__InputLayout",
6057
6057
  componentId: "sc-1yq0rb7-1"
@@ -7275,6 +7275,11 @@ $$3({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }
7275
7275
  }
7276
7276
  });
7277
7277
 
7278
+ const DEFAULT_ROW_HEIGHT = 44;
7279
+ const DEFAULT_MENU_HEIGHT = 190;
7280
+ const DEFAULT_EMPTY_TEXT = 'No results found';
7281
+ const DEFAULT_PLACEHOLDER = 'Select Something';
7282
+
7278
7283
  var $$2 = _export;
7279
7284
  var call$2 = functionCall;
7280
7285
 
@@ -7553,18 +7558,22 @@ function toKey(value) {
7553
7558
  return JSON.stringify(value);
7554
7559
  }
7555
7560
  const topPosition = props => {
7556
- if (props.menuPosition === 'top' && isDefined(props.menuHeight) && typeof props.menuHeight === 'number') {
7557
- return `${-(props.menuHeight + (isDefined(props.label) && props.labelPosition !== 'side' ? 58 : 38))}px`;
7561
+ if (props.menuPosition === "top"
7562
+ /* menuPositionType.TOP */
7563
+ && isDefined(props.menuHeight) && typeof props.menuHeight === 'number') {
7564
+ return `${-(props.menuHeight + (isDefined(props.label) && !isEmpty(props.label) && props.labelPosition === "top"
7565
+ /* labelPositionType.TOP */
7566
+ ? 64 : 44))}px`;
7558
7567
  }
7559
7568
 
7560
- return '0';
7569
+ return '4px';
7561
7570
  };
7562
7571
 
7563
- const OptionItem = /*#__PURE__*/styled.div.withConfig({
7572
+ const OptionItem = /*#__PURE__*/styled(SpaceBetween).withConfig({
7564
7573
  displayName: "option__OptionItem",
7565
7574
  componentId: "sc-1hb1qjt-0"
7566
- })(["display:flex;align-items:center;justify-content:space-between;flex:1;height:", "px;padding:", " ", ";min-width:0;cursor:pointer;box-sizing:border-box;background-color:", ";&:hover{background-color:", ";}&:active{background-color:", ";}"], props => defaultTo(props.height, 44), Padding.none, Padding.s, props => is(props.active) ? Surface.Selected.Default : is(props.selected) ? Surface.Default.Hover : Surface.Default.Default, props => is(props.active) ? Surface.Selected.Hover : Surface.Default.Hover, props => is(props.active) ? Surface.Selected.Pressed : Surface.Default.Pressed);
7567
- const CheckedIcon = /*#__PURE__*/styled(IconMinor.Check).withConfig({
7575
+ })(["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);
7576
+ const CheckedIcon$1 = /*#__PURE__*/styled(IconMinor.Check).withConfig({
7568
7577
  displayName: "option__CheckedIcon",
7569
7578
  componentId: "sc-1hb1qjt-1"
7570
7579
  })(["svg{path{fill:", "}}"], Icons.Highlight);
@@ -7585,6 +7594,7 @@ const OptionComponent = /*#__PURE__*/memo(props => {
7585
7594
  return jsxs(OptionItem, Object.assign({
7586
7595
  className: className.join(' '),
7587
7596
  "data-role": "option",
7597
+ center: true,
7588
7598
  selected: selected,
7589
7599
  active: active,
7590
7600
  height: height,
@@ -7595,18 +7605,20 @@ const OptionComponent = /*#__PURE__*/memo(props => {
7595
7605
  active: active
7596
7606
  }, option, {
7597
7607
  children: option.label
7598
- })), is(active) && jsx(CheckedIcon, {})]
7608
+ })), is(active) && jsx(CheckedIcon$1, {})]
7599
7609
  }));
7600
7610
  }, areEqual);
7601
7611
 
7602
7612
  const MenuWrapper = /*#__PURE__*/styled.div.withConfig({
7603
7613
  displayName: "menu-container__MenuWrapper",
7604
7614
  componentId: "dadn7s-0"
7605
- })(["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;&:focus{outline:none;}::-webkit-scrollbar{width:6px;height:8px;}::-webkit-scrollbar-thumb{border-radius:4px;background:", ";min-height:50px;}}"], Surface.Default.Default, ({
7615
+ })(["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, ({
7606
7616
  props
7607
7617
  }) => topPosition(props), ({
7608
7618
  props
7609
- }) => props.menuPosition === 'bottom' ? '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, Surface.Neutral.Default);
7619
+ }) => props.menuPosition === "bottom"
7620
+ /* menuPositionType.BOTTOM */
7621
+ ? '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);
7610
7622
  const MenuContainer = props => {
7611
7623
  const {
7612
7624
  onClick,
@@ -7668,7 +7680,7 @@ fixRegExpWellKnownSymbolLogic$1('search', function (SEARCH, nativeSearch, maybeC
7668
7680
  ];
7669
7681
  });
7670
7682
 
7671
- const MenuRow = /*#__PURE__*/memo(({
7683
+ const MenuRow$1 = /*#__PURE__*/memo(({
7672
7684
  index,
7673
7685
  style,
7674
7686
  data
@@ -7707,18 +7719,24 @@ const SelectLabel = /*#__PURE__*/styled(Label).withConfig({
7707
7719
  const EmptyOptionItem = /*#__PURE__*/styled(OptionItem).withConfig({
7708
7720
  displayName: "menu__EmptyOptionItem",
7709
7721
  componentId: "sc-1086ljy-0"
7710
- })(["border:1px solid ", ";background-color:", ";border-radius:6px;position:absolute;top:", ";width:100%;", ""], Borders.Default.Subdued, Surface.Default.Default, ({
7722
+ })(["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, ({
7711
7723
  props
7712
- }) => topPosition(props), shadowSm);
7724
+ }) => props.menuPosition === "bottom"
7725
+ /* menuPositionType.BOTTOM */
7726
+ ? '0px 2px 10px 0px rgba(0, 0, 0, 0.10)' : '0px -2px 10px 0px rgba(0, 0, 0, 0.10)', Surface.Default.Default);
7713
7727
  const Menu = props => {
7714
7728
  const {
7715
- rowHeight = 44,
7729
+ rowHeight = DEFAULT_ROW_HEIGHT,
7716
7730
  selectedIndex,
7717
7731
  open,
7718
7732
  invalid,
7719
- menuHeight,
7720
- menuPosition,
7721
- labelPosition,
7733
+ menuHeight = DEFAULT_MENU_HEIGHT,
7734
+ menuPosition = "bottom"
7735
+ /* menuPositionType.BOTTOM */
7736
+ ,
7737
+ labelPosition = "top"
7738
+ /* labelPositionType.TOP */
7739
+ ,
7722
7740
  label
7723
7741
  } = props;
7724
7742
  const options = safeArray(props.options); // eslint-disable-next-line no-null/no-null
@@ -7726,7 +7744,7 @@ const Menu = props => {
7726
7744
  const list = useRef(null); // eslint-disable-next-line no-null/no-null
7727
7745
 
7728
7746
  const outerRef = useRef(null);
7729
- const height = Math.min(Math.max(options.length * rowHeight, rowHeight) + 2, defaultTo(menuHeight, 185));
7747
+ const height = Math.min(Math.max(options.length * rowHeight, rowHeight) + 10, menuHeight);
7730
7748
  useEffect(() => {
7731
7749
  if (is(open) && isDefined(list.current) && selectedIndex !== undefined && selectedIndex !== -1) {
7732
7750
  list.current.scrollToItem(selectedIndex, 'center');
@@ -7769,7 +7787,7 @@ const Menu = props => {
7769
7787
  }, {
7770
7788
  children: jsx(SelectLabel, {
7771
7789
  children: jsx("span", {
7772
- children: defaultTo(emptyText, 'No results found')
7790
+ children: defaultTo(emptyText, DEFAULT_EMPTY_TEXT)
7773
7791
  })
7774
7792
  })
7775
7793
  }));
@@ -7788,7 +7806,7 @@ const Menu = props => {
7788
7806
  itemCount: itemCount,
7789
7807
  itemData: itemData
7790
7808
  }, {
7791
- children: MenuRow
7809
+ children: MenuRow$1
7792
7810
  }));
7793
7811
  };
7794
7812
 
@@ -7834,7 +7852,7 @@ $({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
7834
7852
  const TagContainer = /*#__PURE__*/styled(Tag).withConfig({
7835
7853
  displayName: "value-component-multi__TagContainer",
7836
7854
  componentId: "sc-1fc9cnm-0"
7837
- })(["&:last-of-type{margin-right:", ";}div:first-child{min-height:auto;padding:", " ", " ", " ", ";}div:last-child{padding:", ";}"], Margin.xs, Padding.none, Padding.none, Padding.none, Padding.xxs, Padding.none);
7855
+ })(["div:first-child{min-height:auto;padding:", " ", " ", " ", ";}div:last-child{padding:", ";}"], Padding.none, Padding.none, Padding.none, Padding.xxs, Padding.none);
7838
7856
 
7839
7857
  const ValueComponentMulti = props => {
7840
7858
  const {
@@ -8414,33 +8432,7 @@ function getButtonType(props) {
8414
8432
  const ButtonFrame = /*#__PURE__*/styled.button.withConfig({
8415
8433
  displayName: "button__ButtonFrame",
8416
8434
  componentId: "v4884z-0"
8417
- })(["padding:", ";border:", ";border-radius:6px;background:", ";cursor:", ";display:flex;flex-direction:row;justify-content:center;gap:8px;align-items:center;position:relative;svg[role='icon']{path{fill:", ";}}", ""], props => props.buttonSize, props => props.buttonBorder, props => props.backgroundColor, props => props.cursor, props => props.iconColor, props => !props.isDisabled ? `
8418
- &:hover {
8419
- background: ${props.backgroundHover};
8420
- text-decoration: ${props.textDecorationHover};
8421
- div {
8422
- color: ${props.textColorHover};
8423
- }
8424
- svg[role='icon'] {
8425
- path {
8426
- fill: ${props.iconColorHover};
8427
- }
8428
- }
8429
- }
8430
-
8431
- &:focus {
8432
- outline: 2px solid ${Focused.Default}
8433
- }
8434
-
8435
- &:focus-visible {
8436
- border: 2px solid ${Focused.Default}
8437
- }
8438
-
8439
- &:active {
8440
- text-decoration: 'none'
8441
- background: ${props.backgroundPressed}
8442
- }
8443
- ` : '');
8435
+ })(["padding:", ";border:", ";border-radius:6px;background:", ";cursor:", ";display:flex;flex-direction:row;justify-content:center;gap:8px;align-items:center;position:relative;svg[role='icon']{path{fill:", ";}}", ""], props => props.buttonSize, props => props.buttonBorder, props => props.backgroundColor, props => props.cursor, props => props.iconColor, props => !props.isDisabled && css(["&:hover{background:", ";text-decoration:", ";div{color:", ";}svg[role='icon']{path{fill:", ";}}}outline-offset:-2px;&:focus,focus-visible{outline:2px solid ", "}&:active{text-decoration:'none' background:", "}"], props.backgroundHover, props.textDecorationHover, props.textColorHover, props.iconColorHover, Focused.Default, props.backgroundPressed));
8444
8436
  const ButtonText = /*#__PURE__*/styled(Label).withConfig({
8445
8437
  displayName: "button__ButtonText",
8446
8438
  componentId: "v4884z-1"
@@ -8539,10 +8531,10 @@ const Button = props => {
8539
8531
  }));
8540
8532
  };
8541
8533
 
8542
- const ValueContainer = /*#__PURE__*/styled.div.withConfig({
8534
+ const ValueContainer = /*#__PURE__*/styled(SpaceBetween).withConfig({
8543
8535
  displayName: "value__ValueContainer",
8544
8536
  componentId: "sc-1aps7dx-0"
8545
- })(["display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;flex:1;pointer-events:", ";padding:", " ", " ", " ", ";background:", ";cursor:default;border:1px solid ", ";z-index:0;box-sizing:border-box;max-width:100%;border-radius:6px;outline-offset:-2px;", " ", " ", ""], props => is(props.disabled) ? 'none' : 'auto', Padding.xs, Padding.xs, Padding.xs, Padding.s, Surface.Default.Default, props => is(props.invalid) ? Borders.Critical.Default : Borders.Default.Default, props => is(props.hasLabel) && css(["& div:first-of-type{align-self:flex-start;}"]), props => is(props.menuIsOpen) && css(["outline:2px solid ", ";"], Focused.Default), props => !is(props.disabled) && !is(props.invalid) && `
8537
+ })(["pointer-events:", ";padding:", " ", ";background:", ";cursor:default;border:1px solid ", ";z-index:0;border-radius:6px;outline-offset:-2px;", " ", " ", ""], props => is(props.disabled) ? 'none' : 'auto', Padding.xs, Padding.none, props => is(props.invalid) ? Surface.Critical.Subdued : Surface.Default.Default, props => is(props.invalid) ? Borders.Critical.Default : Borders.Default.Default, props => is(props.hasLabel) && css(["& div:first-of-type{align-self:flex-start;}"]), props => is(props.menuIsOpen) && css(["outline:2px solid ", ";"], Focused.Default), props => !is(props.disabled) && !is(props.invalid) && `
8546
8538
 
8547
8539
  &:focus {
8548
8540
  outline: 2px solid ${Focused.Default}
@@ -8552,39 +8544,50 @@ const ValueContainer = /*#__PURE__*/styled.div.withConfig({
8552
8544
  outline: 2px solid ${Focused.Default}
8553
8545
  }
8554
8546
  `);
8547
+ const ValueWrapper$1 = /*#__PURE__*/styled(Flex).withConfig({
8548
+ displayName: "value__ValueWrapper",
8549
+ componentId: "sc-1aps7dx-1"
8550
+ })(["width:100%;display:", ";"], ({
8551
+ label,
8552
+ labelPosition
8553
+ }) => isDefined(label) && !isEmpty(label) && labelPosition === "top"
8554
+ /* labelPositionType.TOP */
8555
+ ? 'block' : 'flex');
8555
8556
  const ValueLabel = /*#__PURE__*/styled(Label).withConfig({
8556
8557
  displayName: "value__ValueLabel",
8557
- componentId: "sc-1aps7dx-1"
8558
- })(["margin-right:", ";", ""], Margin.xs, ({
8558
+ componentId: "sc-1aps7dx-2"
8559
+ })(["padding-left:", ";width:fit-content;white-space:pre;", ""], Padding.xs, ({
8559
8560
  labelPosition
8560
- }) => labelPosition !== 'side' && css(["flex-basis:100%;}"]));
8561
- const ValueLeft = /*#__PURE__*/styled.div.withConfig({
8561
+ }) => labelPosition === "top"
8562
+ /* labelPositionType.TOP */
8563
+ && css(["flex-basis:100%;"]));
8564
+ const ValueLeft = /*#__PURE__*/styled(Flex).withConfig({
8562
8565
  displayName: "value__ValueLeft",
8563
- componentId: "sc-1aps7dx-2"
8564
- })(["display:flex;flex:1;align-items:center;flex-wrap:", ";user-select:none;min-width:0;min-height:20px;box-sizing:border-box;gap:", ";"], props => is(props.multi) && is(props.hasValue) ? 'wrap' : 'nowrap', props => is(props.multi) ? '4px' : 0);
8565
- const ValueRight = /*#__PURE__*/styled.div.withConfig({
8566
- displayName: "value__ValueRight",
8567
8566
  componentId: "sc-1aps7dx-3"
8568
- })(["display:flex;position:absolute;right:8px;align-items:center;margin-left:", ";box-sizing:border-box;"], Margin.xxs);
8567
+ })(["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);
8568
+ const ValueRight = /*#__PURE__*/styled(Flex).withConfig({
8569
+ displayName: "value__ValueRight",
8570
+ componentId: "sc-1aps7dx-4"
8571
+ })(["padding-right:", ";pointer-events:none;"], Padding.xxs);
8569
8572
  const Placeholder = /*#__PURE__*/styled(Label).withConfig({
8570
8573
  displayName: "value__Placeholder",
8571
- componentId: "sc-1aps7dx-4"
8572
- })(["pointer-events:none;color:", ";"], Text$1.Default);
8574
+ componentId: "sc-1aps7dx-5"
8575
+ })(["pointer-events:none;color:", ";"], Text$1.Light);
8573
8576
  const ClearButton = /*#__PURE__*/styled(Button).attrs({
8574
8577
  plain: true,
8575
8578
  subtle: true
8576
8579
  }).withConfig({
8577
8580
  displayName: "value__ClearButton",
8578
- componentId: "sc-1aps7dx-5"
8581
+ componentId: "sc-1aps7dx-6"
8579
8582
  })(["padding:", ";margin-right:", ";gap:0;&:focus{outline:none;}&:active{background-color:transparent;}"], Padding.none, Margin.none);
8580
8583
  const Search = /*#__PURE__*/styled.span.withConfig({
8581
8584
  displayName: "value__Search",
8582
- componentId: "sc-1aps7dx-6"
8585
+ componentId: "sc-1aps7dx-7"
8583
8586
  })(["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;"]));
8584
8587
  const ErrorMessage = /*#__PURE__*/styled.div.withConfig({
8585
8588
  displayName: "value__ErrorMessage",
8586
- componentId: "sc-1aps7dx-7"
8587
- })(["display:", ";flex-direction:'row';margin-bottom:", ";width:100%;& path{fill:", ";}"], props => is(props.visible) ? 'flex' : 'none', Margin.xxs, Icons.Warning);
8589
+ componentId: "sc-1aps7dx-8"
8590
+ })(["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);
8588
8591
 
8589
8592
  const Value = props => {
8590
8593
  const search = /*#__PURE__*/createRef();
@@ -8605,7 +8608,9 @@ const Value = props => {
8605
8608
  errors,
8606
8609
  label,
8607
8610
  searchable,
8608
- labelPosition
8611
+ labelPosition = "top"
8612
+ /* labelPositionType.TOP */
8613
+
8609
8614
  } = props;
8610
8615
  const valueOptions = getValueOptions(options, value, multi);
8611
8616
  const showClearer = is(clearable) && valueOptions.length > 0;
@@ -8656,7 +8661,7 @@ const Value = props => {
8656
8661
 
8657
8662
  if (valueOptions.length === 0 && isNil(search === null || search === void 0 ? void 0 : search.current)) {
8658
8663
  return jsx(Placeholder, {
8659
- children: placeholder
8664
+ children: defaultTo(placeholder, DEFAULT_PLACEHOLDER)
8660
8665
  });
8661
8666
  }
8662
8667
 
@@ -8716,16 +8721,24 @@ const Value = props => {
8716
8721
  multi: true,
8717
8722
  menuIsOpen: open,
8718
8723
  tabIndex: 0,
8719
- onClick: onClick
8724
+ onClick: onClick,
8725
+ center: true
8720
8726
  }, {
8721
- children: [renderLabel(), jsxs(ValueLeft, Object.assign({
8722
- className: "value-left",
8723
- multi: multi,
8724
- hasValue: !(valueOptions.length === 0)
8727
+ children: [jsxs(ValueWrapper$1, Object.assign({
8728
+ label: label,
8729
+ labelPosition: labelPosition
8725
8730
  }, {
8726
- children: [searchAtStart && renderSearch(), renderValues(), searchAtEnd && renderSearch()]
8731
+ children: [renderLabel(), jsxs(ValueLeft, Object.assign({
8732
+ className: "value-left",
8733
+ multi: multi,
8734
+ showClearer: showClearer,
8735
+ hasValue: !(valueOptions.length === 0)
8736
+ }, {
8737
+ children: [searchAtStart && renderSearch(), renderValues(), searchAtEnd && renderSearch()]
8738
+ }))]
8727
8739
  })), jsxs(ValueRight, Object.assign({
8728
- className: "value-right"
8740
+ className: "value-right",
8741
+ center: true
8729
8742
  }, {
8730
8743
  children: [showClearer && jsx(ClearButton, {
8731
8744
  tabIndex: -1,
@@ -8746,14 +8759,38 @@ const Value = props => {
8746
8759
 
8747
8760
  var Value$1 = /*#__PURE__*/memo(Value);
8748
8761
 
8749
- const Container$1 = /*#__PURE__*/styled.div.withConfig({
8750
- displayName: "select__Container",
8751
- componentId: "iypjy6-0"
8752
- })(["position:relative;cursor:default;width:100%;box-sizing:border-box;pointer-events:", ";opacity:", ";user-select:none;"], props => is(props.disabled) ? 'none' : 'auto', props => is(props.disabled) ? 0.75 : 1);
8753
- const SelectImpl = (props, ref) => {
8754
- if (isNil(ref)) {
8762
+ /**
8763
+ * @TODO Use this container and remove the ContainerStyles
8764
+ * when we have a solution for RWC styled components, or move away from it.
8765
+ */
8766
+
8767
+ /*const Container = styled.div`
8768
+ position: relative;
8769
+ cursor: default;
8770
+ width: 100%;
8771
+ box-sizing: border-box;
8772
+ pointer-events: ${(props: { disabled?: boolean }) =>
8773
+ is(props.disabled) ? 'none' : 'auto'};
8774
+ opacity: ${(props: { disabled?: boolean }) => (is(props.disabled) ? 0.75 : 1)};
8775
+ user-select: none;
8776
+ `*/
8777
+
8778
+ const ContainerStyles = ({
8779
+ disabled
8780
+ }) => ({
8781
+ position: 'relative',
8782
+ cursor: 'default',
8783
+ width: '100%',
8784
+ boxSizing: 'border-box',
8785
+ pointerEvents: is(disabled) ? 'none' : 'auto',
8786
+ opacity: is(disabled) ? 0.75 : 1,
8787
+ userSelect: 'none'
8788
+ });
8789
+
8790
+ const SelectImpl = (props, selectRef) => {
8791
+ if (isNil(selectRef)) {
8755
8792
  // eslint-disable-next-line no-null/no-null, react-hooks/rules-of-hooks
8756
- ref = useRef(null);
8793
+ selectRef = useRef(null);
8757
8794
  }
8758
8795
 
8759
8796
  const [open, setOpen] = useState(false);
@@ -8774,6 +8811,7 @@ const SelectImpl = (props, ref) => {
8774
8811
  emptyText,
8775
8812
  rowHeight,
8776
8813
  menuHeight,
8814
+ menuTitle,
8777
8815
  menuPosition,
8778
8816
  label,
8779
8817
  labelPosition
@@ -8788,18 +8826,16 @@ const SelectImpl = (props, ref) => {
8788
8826
  return;
8789
8827
  }
8790
8828
 
8791
- if (isDefined(ref) && typeof ref === 'object' && 'current' in ref) {
8829
+ if (isDefined(selectRef) && typeof selectRef === 'object') {
8792
8830
  const {
8793
8831
  current
8794
- } = ref;
8832
+ } = selectRef;
8795
8833
 
8796
- if (isDefined(current) && 'contains' in current && current.contains(target)) {
8797
- return;
8834
+ if (isDefined(current) && !current.contains(target)) {
8835
+ closeMenu(props.value);
8798
8836
  }
8799
-
8800
- closeMenu(props.value);
8801
8837
  }
8802
- }, []);
8838
+ }, [props.value]);
8803
8839
 
8804
8840
  function getOptions() {
8805
8841
  if (isDefined(search)) {
@@ -8977,10 +9013,21 @@ const SelectImpl = (props, ref) => {
8977
9013
  }
8978
9014
 
8979
9015
  const classNames = ['select', className, open && 'open', is(invalid) && 'has-error'].filter(c => Boolean(c));
8980
- return jsxs(Container$1, Object.assign({
9016
+ /**
9017
+ * @TODO this is a hack to be able to use the ref in react-web-client
9018
+ * RWC uses styled-components < v4 and expects the ref to be passes as
9019
+ * "innerRef" not just "ref", but product-language uses > v4 and wants
9020
+ * to use ref. So for some components that need a ref, like this one
9021
+ * we will have to use a div and style it the old fashioned way until
9022
+ * we upgrade rwc's styled-components or drop rwc
9023
+ */
9024
+
9025
+ return jsxs("div", Object.assign({
9026
+ style: ContainerStyles({
9027
+ disabled
9028
+ }),
9029
+ ref: selectRef,
8981
9030
  className: classNames.join(' '),
8982
- disabled: disabled,
8983
- ref: ref,
8984
9031
  onKeyUp: onKeyUp,
8985
9032
  onKeyDown: onKeyDown
8986
9033
  }, {
@@ -9020,14 +9067,102 @@ const SelectImpl = (props, ref) => {
9020
9067
  menuComponent: menuComponent,
9021
9068
  emptyText: emptyText,
9022
9069
  rowHeight: rowHeight,
9070
+ menuTitle: menuTitle,
9023
9071
  menuHeight: menuHeight,
9024
9072
  menuPosition: menuPosition,
9025
9073
  onSelect: onOptionSelect
9026
9074
  })]
9027
9075
  }));
9028
9076
  };
9077
+
9029
9078
  const Select = forwardRef(SelectImpl);
9030
9079
 
9080
+ const MenuListFrame = /*#__PURE__*/styled.div.withConfig({
9081
+ displayName: "menu-list__MenuListFrame",
9082
+ componentId: "sxh4rn-0"
9083
+ })(["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);
9084
+ const MenuRow = /*#__PURE__*/styled(SpaceBetween).withConfig({
9085
+ displayName: "menu-list__MenuRow",
9086
+ componentId: "sxh4rn-1"
9087
+ })([" 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);
9088
+ const OptionLabel = /*#__PURE__*/styled(Label).withConfig({
9089
+ displayName: "menu-list__OptionLabel",
9090
+ componentId: "sxh4rn-2"
9091
+ })(["cursor:pointer;"]);
9092
+ const CheckedIcon = /*#__PURE__*/styled(IconMinor.Check).withConfig({
9093
+ displayName: "menu-list__CheckedIcon",
9094
+ componentId: "sxh4rn-3"
9095
+ })(["svg{path{fill:", "}}"], Icons.Highlight);
9096
+ const ValueWrapper = /*#__PURE__*/styled.div.withConfig({
9097
+ displayName: "menu-list__ValueWrapper",
9098
+ componentId: "sxh4rn-4"
9099
+ })(["width:100%;"]);
9100
+ const TitleRow = /*#__PURE__*/styled(Heading4).withConfig({
9101
+ displayName: "menu-list__TitleRow",
9102
+ componentId: "sxh4rn-5"
9103
+ })(["height:30px;margin:", " ", ";border-bottom:1px solid ", ";padding:", " ", " ", " ", ";"], Margin.none, Margin.xxs, Borders.Default.Subdued, Padding.s, Padding.none, Padding.none, Padding.s);
9104
+
9105
+ const Row = props => {
9106
+ const {
9107
+ index,
9108
+ options = [],
9109
+ handleClick
9110
+ } = props;
9111
+ const hasIcon = safeArray(options).some(option => isDefined(option['icon']));
9112
+ const currentValue = Array.isArray(props.value) && is(props.multi) ? props.value : [props.value];
9113
+ const option = options[index];
9114
+ return jsxs(MenuRow, Object.assign({
9115
+ className: "row",
9116
+ center: true,
9117
+ active: currentValue.some(val => equal(val, option.value)),
9118
+ onClick: () => handleClick(option)
9119
+ }, {
9120
+ children: [maybeRender(hasIcon, option['icon']), jsxs(ValueWrapper, {
9121
+ children: [jsx(OptionLabel, Object.assign({
9122
+ hasIcon: hasIcon
9123
+ }, {
9124
+ children: option.label
9125
+ })), maybeRender(option['helperText'], jsx(OptionLabel, Object.assign({
9126
+ subdued: true,
9127
+ hasIcon: hasIcon
9128
+ }, {
9129
+ children: option['helperText']
9130
+ })))]
9131
+ }), maybeRender(currentValue.some(val => equal(val, option.value)), jsx(CheckedIcon, {}))]
9132
+ }));
9133
+ };
9134
+
9135
+ const MenuList = props => {
9136
+ // eslint-disable-next-line no-null/no-null
9137
+ const list = useRef(null); // const { open, selectedIndex, rowHeight } = props
9138
+
9139
+ const handleClick = option => {
9140
+ const newValue = Array.isArray(props.value) && is(props.multi) ? [...props.value, option.value] : option.value;
9141
+ props.onSelect(newValue);
9142
+ };
9143
+ /**
9144
+ * @TODO
9145
+ * This doesnt work with the styled components that RWC uses, so I'll leave comented for now
9146
+ *useEffect(() => {
9147
+ * if(is(open) && isDefined(list.current) && isDefined(selectedIndex)) {
9148
+ * list.current.scrollTo(0, selectedIndex * (defaultTo(rowHeight, DEFAULT_ROW_HEIGHT)+4))
9149
+ * }
9150
+ *}, [open, list, selectedIndex, rowHeight])
9151
+ */
9152
+
9153
+
9154
+ return jsxs(MenuListFrame, Object.assign({
9155
+ ref: list
9156
+ }, {
9157
+ children: [maybeRender(props.menuTitle, jsx(TitleRow, {
9158
+ children: props.menuTitle
9159
+ })), safeArray(props.options).map((_, index) => jsx(Row, Object.assign({
9160
+ index: index,
9161
+ handleClick: handleClick
9162
+ }, props), index))]
9163
+ }));
9164
+ };
9165
+
9031
9166
  var apply = functionApply;
9032
9167
  var call = functionCall;
9033
9168
  var uncurryThis = functionUncurryThis;
@@ -9373,4 +9508,4 @@ const MultiChoiceList = props => {
9373
9508
  }));
9374
9509
  };
9375
9510
 
9376
- export { Actions, AlertBanner, Avatar, BODY, BODY_LARGE, Background, Badge, Body, BodyLarge, Borders, Button, CAPTION, Caption, Card, Center, Checkbox, Display, Divider, Flag, Flex, Focused, HTMLAnchor, HTMLInput, Heading1, Heading2, Heading3, Heading4, Icon, IconMinor, Icons, InputCheckbox, InputField, InputNumber, InputText, Interactive, LABEL, Label, LeftRightCard, Link, Margin, MultiChoiceList, Padding, Select, SelectImpl, SpaceAround, SpaceBetween, Spinner, Surface, Tab$1 as Tab, Tabs, Tag, Text$1 as Text, Thumbnail, Typography, _Typography, gridLayoutGenerator, leftRightLayoutGenerator, shadow, shadow2Xl, shadowInner, shadowLg, shadowMd, shadowSm, shadowXl };
9511
+ export { Actions, AlertBanner, Avatar, BODY, BODY_LARGE, Background, Badge, Body, BodyLarge, Borders, Button, CAPTION, Caption, Card, Center, Checkbox, Display, Divider, Flag, Flex, Focused, HTMLAnchor, HTMLInput, Heading1, Heading2, Heading3, Heading4, Icon, IconMinor, Icons, InputCheckbox, InputField, InputNumber, InputText, Interactive, LABEL, Label, LeftRightCard, Link, Margin, MenuList, MultiChoiceList, Padding, Select, SpaceAround, SpaceBetween, Spinner, Surface, Tab$1 as Tab, Tabs, Tag, Text$1 as Text, Thumbnail, Typography, _Typography, gridLayoutGenerator, leftRightLayoutGenerator, shadow, shadow2Xl, shadowInner, shadowLg, shadowMd, shadowSm, shadowXl };
@@ -0,0 +1,3 @@
1
+ import { FC } from '@helpers';
2
+ import { IMenuComponentProps } from '../types';
3
+ export declare const MenuList: FC<IMenuComponentProps>;
@@ -5,6 +5,9 @@ interface IOptionItemProps {
5
5
  selected?: IOptionComponentProps['selected'];
6
6
  height?: IOptionComponentProps['height'];
7
7
  }
8
- export declare const OptionItem: import("styled-components").StyledComponent<"div", any, IOptionItemProps, never>;
8
+ export declare const OptionItem: import("styled-components").StyledComponent<"div", any, {
9
+ column?: boolean | undefined;
10
+ center?: boolean | undefined;
11
+ } & IOptionItemProps, never>;
9
12
  export declare const OptionComponent: import("react").MemoExoticComponent<(props: IOptionComponentProps) => JSX.Element>;
10
13
  export {};
@@ -1 +1,2 @@
1
1
  export * from './select';
2
+ export * from './components/menu-list';
@@ -1,9 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { PropsWithChildren } from '@helpers';
3
3
  import { ISelectProps } from './types';
4
- export declare const SelectImpl: <T>(props: ISelectProps<T>, ref: React.ForwardedRef<HTMLDivElement>) => JSX.Element;
4
+ declare const SelectImpl: <T>(props: ISelectProps<T>, selectRef: React.ForwardedRef<HTMLDivElement>) => JSX.Element;
5
5
  export declare const Select: <T>(props: ISelectProps<T> & {
6
6
  children?: import("react").ReactNode;
7
7
  } & {
8
8
  ref?: import("react").ForwardedRef<HTMLDivElement> | undefined;
9
9
  }) => ReturnType<typeof SelectImpl>;
10
+ export {};
@@ -17,6 +17,7 @@ export interface ISelectProps<T = any> {
17
17
  rowHeight?: number;
18
18
  menuHeight?: number;
19
19
  menuPosition?: 'top' | 'bottom';
20
+ menuTitle?: string;
20
21
  label?: string;
21
22
  labelPosition?: 'top' | 'side';
22
23
  labelComponent?: FC<LabelComponentProps<T>>;
@@ -62,12 +63,6 @@ export interface IMenuContainerProps {
62
63
  onClick?(el: React.MouseEvent<HTMLDivElement>): void;
63
64
  }
64
65
  declare type RectSize = number | 'auto';
65
- export interface IRect {
66
- left: number;
67
- top: number;
68
- width: RectSize;
69
- height: RectSize;
70
- }
71
66
  export interface IValueComponentMultiProps<T = any> extends IValueComponentSingleProps<T> {
72
67
  options: IOption<T>[];
73
68
  onRemove(value: T): void;
@@ -113,6 +108,7 @@ export interface IMenuComponentProps<T = any> {
113
108
  search?: string;
114
109
  labelPosition?: string;
115
110
  label?: string;
111
+ menuTitle?: string;
116
112
  onSelect(value: T extends any[] ? T[] : T, option?: T): void;
117
113
  }
118
114
  export interface IPosition {
@@ -121,4 +117,16 @@ export interface IPosition {
121
117
  label?: string;
122
118
  labelPosition?: string;
123
119
  }
120
+ export declare const DEFAULT_ROW_HEIGHT = 44;
121
+ export declare const DEFAULT_MENU_HEIGHT = 190;
122
+ export declare const DEFAULT_EMPTY_TEXT = "No results found";
123
+ export declare const DEFAULT_PLACEHOLDER = "Select Something";
124
+ export declare const enum menuPositionType {
125
+ TOP = "top",
126
+ BOTTOM = "bottom"
127
+ }
128
+ export declare const enum labelPositionType {
129
+ TOP = "top",
130
+ SIDE = "side"
131
+ }
124
132
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edvisor/product-language",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "license": "MIT",
5
5
  "description": "Edvisor.io product-language components",
6
6
  "repository": "https://github.com/edvisor-io/front-end/",