@scripso-homepad/ui 0.4.6 → 0.4.7

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.d.cts CHANGED
@@ -70,6 +70,8 @@ interface SelectBaseProps {
70
70
  labelClassName?: string;
71
71
  errorClassName?: string;
72
72
  hintClassName?: string;
73
+ /** Shorter option rows for compact filter-style dropdowns. */
74
+ compact?: boolean;
73
75
  }
74
76
  interface SingleSelectProps extends SelectBaseProps {
75
77
  multiple?: false;
@@ -82,7 +84,7 @@ interface MultipleSelectProps extends SelectBaseProps {
82
84
  onValueChange?: (value: string[]) => void;
83
85
  }
84
86
  type SelectProps = SingleSelectProps | MultipleSelectProps;
85
- declare function Select({ label, placeholder, value, onValueChange, options, leftIcon, multiple, disabled, error, invalid, hint, containerStyle, fieldStyle, className, fieldClassName, menuClassName, labelClassName, errorClassName, hintClassName, }: SelectProps): react.JSX.Element;
87
+ declare function Select({ label, placeholder, value, onValueChange, options, leftIcon, multiple, disabled, error, invalid, hint, containerStyle, fieldStyle, className, fieldClassName, menuClassName, labelClassName, errorClassName, hintClassName, compact, }: SelectProps): react.JSX.Element;
86
88
 
87
89
  interface PhoneInputProps extends Omit<TextInputProps, "style"> {
88
90
  label?: string;
@@ -441,13 +443,13 @@ declare const labelTypography: {
441
443
  readonly lineHeight: 12;
442
444
  readonly letterSpacing: 0;
443
445
  };
444
- /** Button label typography — SemiBold; line-height slightly above 100% for RN clipping. */
446
+ /** Button label typography — SemiBold. */
445
447
  declare const buttonTypography: {
446
448
  readonly lg: {
447
449
  readonly fontFamily: "Noto Sans Armenian";
448
450
  readonly fontSize: 14;
449
451
  readonly fontWeight: "600";
450
- readonly lineHeight: 18;
452
+ readonly lineHeight: 19;
451
453
  readonly letterSpacing: 0;
452
454
  };
453
455
  readonly sm: {
package/dist/index.d.ts CHANGED
@@ -70,6 +70,8 @@ interface SelectBaseProps {
70
70
  labelClassName?: string;
71
71
  errorClassName?: string;
72
72
  hintClassName?: string;
73
+ /** Shorter option rows for compact filter-style dropdowns. */
74
+ compact?: boolean;
73
75
  }
74
76
  interface SingleSelectProps extends SelectBaseProps {
75
77
  multiple?: false;
@@ -82,7 +84,7 @@ interface MultipleSelectProps extends SelectBaseProps {
82
84
  onValueChange?: (value: string[]) => void;
83
85
  }
84
86
  type SelectProps = SingleSelectProps | MultipleSelectProps;
85
- declare function Select({ label, placeholder, value, onValueChange, options, leftIcon, multiple, disabled, error, invalid, hint, containerStyle, fieldStyle, className, fieldClassName, menuClassName, labelClassName, errorClassName, hintClassName, }: SelectProps): react.JSX.Element;
87
+ declare function Select({ label, placeholder, value, onValueChange, options, leftIcon, multiple, disabled, error, invalid, hint, containerStyle, fieldStyle, className, fieldClassName, menuClassName, labelClassName, errorClassName, hintClassName, compact, }: SelectProps): react.JSX.Element;
86
88
 
87
89
  interface PhoneInputProps extends Omit<TextInputProps, "style"> {
88
90
  label?: string;
@@ -441,13 +443,13 @@ declare const labelTypography: {
441
443
  readonly lineHeight: 12;
442
444
  readonly letterSpacing: 0;
443
445
  };
444
- /** Button label typography — SemiBold; line-height slightly above 100% for RN clipping. */
446
+ /** Button label typography — SemiBold. */
445
447
  declare const buttonTypography: {
446
448
  readonly lg: {
447
449
  readonly fontFamily: "Noto Sans Armenian";
448
450
  readonly fontSize: 14;
449
451
  readonly fontWeight: "600";
450
- readonly lineHeight: 18;
452
+ readonly lineHeight: 19;
451
453
  readonly letterSpacing: 0;
452
454
  };
453
455
  readonly sm: {
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { colors, buttonTypography, spacing, fontSize, fontWeight, fonts, radii, INPUT_ICON_GAP, useApplyWebClassName, resolveInputVisualState, Label, getInputFieldStyles, inputFieldMetrics } from './chunk-Y7I7LA2K.js';
2
- export { Input, Label, brand, buttonTypography, colors, emeraldGreen, fontSize, fontWeight, fonts, labelTypography, navy, radii, rubyRed, shadows, spacing, stormGray } from './chunk-Y7I7LA2K.js';
3
- import { createContext, useRef, useState, useEffect, useMemo, useLayoutEffect, useContext, isValidElement, cloneElement } from 'react';
1
+ import { colors, buttonTypography, spacing, fontSize, fontWeight, fonts, radii, INPUT_ICON_GAP, useApplyWebClassName, resolveInputVisualState, Label, getInputFieldStyles, inputFieldMetrics } from './chunk-7KLVMNDM.js';
2
+ export { Input, Label, brand, buttonTypography, colors, emeraldGreen, fontSize, fontWeight, fonts, labelTypography, navy, radii, rubyRed, shadows, spacing, stormGray } from './chunk-7KLVMNDM.js';
3
+ import { createContext, useRef, useState, useMemo, useEffect, useLayoutEffect, useContext, isValidElement, cloneElement } from 'react';
4
4
  import { StyleSheet, Platform, TouchableOpacity, Text, View, Animated, Easing, Pressable, Modal, ScrollView, TextInput, Dimensions } from 'react-native';
5
5
  import Svg3, { Path } from 'react-native-svg';
6
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -229,10 +229,12 @@ var SELECT_DROPDOWN_GAP = spacing.sm;
229
229
  var SELECT_DROPDOWN_PADDING = spacing.sm;
230
230
  var SELECT_DROPDOWN_MAX_HEIGHT = 317;
231
231
  var SELECT_OPTION_HEIGHT = 43;
232
+ var SELECT_OPTION_HEIGHT_COMPACT = 36;
232
233
  var SELECT_OPTION_GAP = spacing.sm;
233
234
  var SELECT_CHEVRON_SIZE = 20;
234
235
  var SELECT_CHEVRON_COLOR = colors.stormGray150;
235
236
  var SELECT_CHEVRON_ROTATION_MS = 200;
237
+ var SELECT_TEXT_LINE_HEIGHT = 19;
236
238
  var selectLabelTypography = {
237
239
  fontFamily: fonts.sans,
238
240
  fontSize: fontSize.sm,
@@ -245,7 +247,7 @@ var selectValueTypography = {
245
247
  fontFamily: fonts.sans,
246
248
  fontSize: fontSize.md,
247
249
  fontWeight: fontWeight.regular,
248
- lineHeight: fontSize.md,
250
+ lineHeight: SELECT_TEXT_LINE_HEIGHT,
249
251
  letterSpacing: 0,
250
252
  textAlign: "left"
251
253
  };
@@ -386,7 +388,7 @@ var selectDropdownMetrics = StyleSheet.create({
386
388
  fontFamily: fonts.sans,
387
389
  fontSize: fontSize.md,
388
390
  fontWeight: fontWeight.regular,
389
- lineHeight: fontSize.md,
391
+ lineHeight: SELECT_TEXT_LINE_HEIGHT,
390
392
  letterSpacing: 0,
391
393
  textAlign: "left",
392
394
  color: colors.slateBlue,
@@ -409,10 +411,13 @@ var selectDropdownMetrics = StyleSheet.create({
409
411
  backgroundColor: colors.stormGray0
410
412
  }
411
413
  });
412
- function resolveSelectDropdownHeight(optionCount) {
413
- const contentHeight = optionCount * SELECT_OPTION_HEIGHT + Math.max(0, optionCount - 1) * SELECT_OPTION_GAP + SELECT_DROPDOWN_PADDING * 2;
414
+ function resolveSelectDropdownHeight(optionCount, optionHeight = SELECT_OPTION_HEIGHT) {
415
+ const contentHeight = optionCount * optionHeight + Math.max(0, optionCount - 1) * SELECT_OPTION_GAP + SELECT_DROPDOWN_PADDING * 2;
414
416
  return Math.min(contentHeight, SELECT_DROPDOWN_MAX_HEIGHT);
415
417
  }
418
+ function resolveSelectDropdownContentHeight(optionCount, optionHeight = SELECT_OPTION_HEIGHT) {
419
+ return optionCount * optionHeight + Math.max(0, optionCount - 1) * SELECT_OPTION_GAP;
420
+ }
416
421
  function resolveSelectDropdownTop(anchor, dropdownHeight) {
417
422
  const windowHeight = Dimensions.get("window").height;
418
423
  const spaceBelow = windowHeight - (anchor.y + anchor.height + SELECT_DROPDOWN_GAP);
@@ -583,7 +588,8 @@ function Select({
583
588
  menuClassName,
584
589
  labelClassName,
585
590
  errorClassName,
586
- hintClassName
591
+ hintClassName,
592
+ compact = false
587
593
  }) {
588
594
  const wrapperRef = useRef(null);
589
595
  const triggerRef = useRef(null);
@@ -595,10 +601,15 @@ function Select({
595
601
  const [anchor, setAnchor] = useState(null);
596
602
  const [highlightedIndex, setHighlightedIndex] = useState(-1);
597
603
  const [valueContainerWidth, setValueContainerWidth] = useState(0);
604
+ const optionHeight = compact ? SELECT_OPTION_HEIGHT_COMPACT : SELECT_OPTION_HEIGHT;
605
+ const needsScroll = useMemo(
606
+ () => resolveSelectDropdownContentHeight(options.length, optionHeight) > SELECT_DROPDOWN_MAX_HEIGHT - SELECT_DROPDOWN_PADDING * 2,
607
+ [compact, optionHeight, options.length]
608
+ );
598
609
  useApplyWebClassName(wrapperRef, className);
599
610
  useApplyWebClassName(triggerRef, fieldClassName);
600
611
  useApplyWebClassName(menuRef, menuClassName);
601
- useApplyWebClassName(scrollRef, SELECT_DROPDOWN_SCROLL_CLASS, open && Boolean(anchor));
612
+ useApplyWebClassName(scrollRef, SELECT_DROPDOWN_SCROLL_CLASS, open && Boolean(anchor) && needsScroll);
602
613
  useApplyWebClassName(helperRef, error ? errorClassName : hintClassName);
603
614
  useIsomorphicLayoutEffect(() => {
604
615
  ensureSelectDropdownScrollStyles();
@@ -654,7 +665,7 @@ function Select({
654
665
  return formatMultiSelectDisplay(selectedLabels, valueContainerWidth);
655
666
  }, [multiple, placeholder, selectedLabels, valueContainerWidth]);
656
667
  const isPlaceholder = selectedLabels.length === 0;
657
- const dropdownHeight = resolveSelectDropdownHeight(options.length);
668
+ const dropdownHeight = resolveSelectDropdownHeight(options.length, optionHeight);
658
669
  const helperMessage = error ?? hint;
659
670
  function closeMenu() {
660
671
  setOpen(false);
@@ -706,7 +717,10 @@ function Select({
706
717
  },
707
718
  style: [
708
719
  selectDropdownMetrics.option,
720
+ compact && styles2.optionCompact,
721
+ { height: optionHeight, minHeight: optionHeight, maxHeight: optionHeight },
709
722
  isSelected && selectDropdownMetrics.optionSelected,
723
+ compact && isSelected && styles2.optionSelectedCompact,
710
724
  isHighlighted && !isSelected && !option.disabled ? selectDropdownMetrics.optionHighlighted : null,
711
725
  !isLast && styles2.optionSpacing,
712
726
  option.disabled && styles2.optionDisabled
@@ -793,7 +807,7 @@ function Select({
793
807
  height: dropdownHeight
794
808
  }
795
809
  ],
796
- children: /* @__PURE__ */ jsx(
810
+ children: needsScroll ? /* @__PURE__ */ jsx(
797
811
  ScrollView,
798
812
  {
799
813
  ref: scrollRef,
@@ -805,7 +819,7 @@ function Select({
805
819
  nestedScrollEnabled: true,
806
820
  children: optionList
807
821
  }
808
- )
822
+ ) : /* @__PURE__ */ jsx(View, { style: styles2.dropdownContent, children: optionList })
809
823
  }
810
824
  ) : null }) })
811
825
  ] });
@@ -846,6 +860,14 @@ var styles2 = StyleSheet.create({
846
860
  optionSpacing: {
847
861
  marginBottom: SELECT_OPTION_GAP
848
862
  },
863
+ optionCompact: {
864
+ paddingTop: 8,
865
+ paddingBottom: 8
866
+ },
867
+ optionSelectedCompact: {
868
+ paddingTop: 8,
869
+ paddingBottom: 8
870
+ },
849
871
  optionDisabled: {
850
872
  opacity: 0.5
851
873
  },