@scripso-homepad/ui 0.4.5 → 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-66WR57JJ.js';
2
- export { Input, Label, brand, buttonTypography, colors, emeraldGreen, fontSize, fontWeight, fonts, labelTypography, navy, radii, rubyRed, shadows, spacing, stormGray } from './chunk-66WR57JJ.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
  };
@@ -262,7 +264,16 @@ function createOutlineStyle(ringColor) {
262
264
  ...Platform.OS !== "web" ? { overflow: "hidden" } : null
263
265
  };
264
266
  }
265
- var defaultOutline = createOutlineStyle(colors.transparent);
267
+ var defaultOutline = {
268
+ borderRadius: radii.lg,
269
+ borderWidth: 0,
270
+ borderColor: colors.transparent,
271
+ padding: 0,
272
+ backgroundColor: colors.transparent,
273
+ width: "100%",
274
+ alignSelf: "stretch",
275
+ ...Platform.OS !== "web" ? { overflow: "hidden" } : null
276
+ };
266
277
  function getSelectFieldStyles(state) {
267
278
  const containerBase = {
268
279
  borderRadius: radii.lg,
@@ -377,7 +388,7 @@ var selectDropdownMetrics = StyleSheet.create({
377
388
  fontFamily: fonts.sans,
378
389
  fontSize: fontSize.md,
379
390
  fontWeight: fontWeight.regular,
380
- lineHeight: fontSize.md,
391
+ lineHeight: SELECT_TEXT_LINE_HEIGHT,
381
392
  letterSpacing: 0,
382
393
  textAlign: "left",
383
394
  color: colors.slateBlue,
@@ -400,10 +411,13 @@ var selectDropdownMetrics = StyleSheet.create({
400
411
  backgroundColor: colors.stormGray0
401
412
  }
402
413
  });
403
- function resolveSelectDropdownHeight(optionCount) {
404
- 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;
405
416
  return Math.min(contentHeight, SELECT_DROPDOWN_MAX_HEIGHT);
406
417
  }
418
+ function resolveSelectDropdownContentHeight(optionCount, optionHeight = SELECT_OPTION_HEIGHT) {
419
+ return optionCount * optionHeight + Math.max(0, optionCount - 1) * SELECT_OPTION_GAP;
420
+ }
407
421
  function resolveSelectDropdownTop(anchor, dropdownHeight) {
408
422
  const windowHeight = Dimensions.get("window").height;
409
423
  const spaceBelow = windowHeight - (anchor.y + anchor.height + SELECT_DROPDOWN_GAP);
@@ -574,7 +588,8 @@ function Select({
574
588
  menuClassName,
575
589
  labelClassName,
576
590
  errorClassName,
577
- hintClassName
591
+ hintClassName,
592
+ compact = false
578
593
  }) {
579
594
  const wrapperRef = useRef(null);
580
595
  const triggerRef = useRef(null);
@@ -586,10 +601,15 @@ function Select({
586
601
  const [anchor, setAnchor] = useState(null);
587
602
  const [highlightedIndex, setHighlightedIndex] = useState(-1);
588
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
+ );
589
609
  useApplyWebClassName(wrapperRef, className);
590
610
  useApplyWebClassName(triggerRef, fieldClassName);
591
611
  useApplyWebClassName(menuRef, menuClassName);
592
- useApplyWebClassName(scrollRef, SELECT_DROPDOWN_SCROLL_CLASS, open && Boolean(anchor));
612
+ useApplyWebClassName(scrollRef, SELECT_DROPDOWN_SCROLL_CLASS, open && Boolean(anchor) && needsScroll);
593
613
  useApplyWebClassName(helperRef, error ? errorClassName : hintClassName);
594
614
  useIsomorphicLayoutEffect(() => {
595
615
  ensureSelectDropdownScrollStyles();
@@ -645,7 +665,7 @@ function Select({
645
665
  return formatMultiSelectDisplay(selectedLabels, valueContainerWidth);
646
666
  }, [multiple, placeholder, selectedLabels, valueContainerWidth]);
647
667
  const isPlaceholder = selectedLabels.length === 0;
648
- const dropdownHeight = resolveSelectDropdownHeight(options.length);
668
+ const dropdownHeight = resolveSelectDropdownHeight(options.length, optionHeight);
649
669
  const helperMessage = error ?? hint;
650
670
  function closeMenu() {
651
671
  setOpen(false);
@@ -697,7 +717,10 @@ function Select({
697
717
  },
698
718
  style: [
699
719
  selectDropdownMetrics.option,
720
+ compact && styles2.optionCompact,
721
+ { height: optionHeight, minHeight: optionHeight, maxHeight: optionHeight },
700
722
  isSelected && selectDropdownMetrics.optionSelected,
723
+ compact && isSelected && styles2.optionSelectedCompact,
701
724
  isHighlighted && !isSelected && !option.disabled ? selectDropdownMetrics.optionHighlighted : null,
702
725
  !isLast && styles2.optionSpacing,
703
726
  option.disabled && styles2.optionDisabled
@@ -784,7 +807,7 @@ function Select({
784
807
  height: dropdownHeight
785
808
  }
786
809
  ],
787
- children: /* @__PURE__ */ jsx(
810
+ children: needsScroll ? /* @__PURE__ */ jsx(
788
811
  ScrollView,
789
812
  {
790
813
  ref: scrollRef,
@@ -796,7 +819,7 @@ function Select({
796
819
  nestedScrollEnabled: true,
797
820
  children: optionList
798
821
  }
799
- )
822
+ ) : /* @__PURE__ */ jsx(View, { style: styles2.dropdownContent, children: optionList })
800
823
  }
801
824
  ) : null }) })
802
825
  ] });
@@ -837,6 +860,14 @@ var styles2 = StyleSheet.create({
837
860
  optionSpacing: {
838
861
  marginBottom: SELECT_OPTION_GAP
839
862
  },
863
+ optionCompact: {
864
+ paddingTop: 8,
865
+ paddingBottom: 8
866
+ },
867
+ optionSelectedCompact: {
868
+ paddingTop: 8,
869
+ paddingBottom: 8
870
+ },
840
871
  optionDisabled: {
841
872
  opacity: 0.5
842
873
  },