react-better-html 1.1.40 → 1.1.42

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.
@@ -141,7 +141,7 @@ const DropdownComponent = (0, react_1.forwardRef)(function Dropdown({ label, err
141
141
  }, [withDebounce, onChangeSearch, debouncedSearchQuery]);
142
142
  const displayValue = withSearch && isFocused ? searchQuery : selectedOption?.label ?? "";
143
143
  const withClearButton = isOpen && selectedOption;
144
- return ((0, jsx_runtime_1.jsx)(Div_1.default.column, { width: "100%", position: "relative", userSelect: "none", ...props, ref: dropdownHolderRef, children: (0, jsx_runtime_1.jsxs)(Div_1.default.row, { position: "relative", width: "100%", children: [(0, jsx_runtime_1.jsx)(InputField_1.default, { label: label, errorText: errorText, infoText: infoText, required: required, disabled: disabled, readOnly: !withSearch, value: displayValue, placeholder: withSearch ? (selectedOption ? selectedOption.label : placeholder) : placeholder, leftIcon: leftIcon, className: `react-better-html-dropdown${isOpen ? " react-better-html-dropdown-open" : ""}${isOpenLate ? " react-better-html-dropdown-open-late" : ""}${inputFieldClassName ? ` ${inputFieldClassName}` : ""}`, onClick: !disabled ? setIsOpen.toggle : undefined, onFocus: setIsFocused.setTrue, onBlur: setIsFocused.setFalse, onKeyDown: onKeyDownInputField, onChangeValue: withSearch ? onChangeValue : undefined, insideInputFieldComponent: (0, jsx_runtime_1.jsx)(Div_1.default, { position: "absolute", top: "100%", left: 0, width: "100%", maxHeight: 300, backgroundColor: theme.colors.backgroundContent, border: `1px solid ${isFocused ? theme.colors.primary : theme.colors.border}`, borderTop: "none", borderBottomLeftRadius: theme.styles.borderRadius, borderBottomRightRadius: theme.styles.borderRadius, boxShadow: "0px 10px 20px #00000020", zIndex: 1000, overflowY: "auto", opacity: !isOpen ? 0 : undefined, pointerEvents: !isOpen ? "none" : undefined, transform: `translateY(${!isOpen ? -10 : 0}px)`, transition: theme.styles.transition, role: "listbox", "aria-label": label, children: isLoadingDebouncedSearchQuery || debounceIsLoading ? ((0, jsx_runtime_1.jsx)(Div_1.default, { padding: `${theme.styles.space / 2}px ${theme.styles.space + theme.styles.gap}px`, children: (0, jsx_runtime_1.jsx)(Loader_1.default.text, {}) })) : filteredOptions.length ? (filteredOptions.map((option, index) => {
144
+ return ((0, jsx_runtime_1.jsx)(Div_1.default.column, { width: "100%", position: "relative", userSelect: "none", ...props, ref: dropdownHolderRef, children: (0, jsx_runtime_1.jsxs)(Div_1.default.row, { position: "relative", width: "100%", children: [(0, jsx_runtime_1.jsx)(InputField_1.default, { label: label, errorText: errorText, infoText: infoText, required: required, disabled: disabled, readOnly: !withSearch, value: displayValue, cursor: !withSearch ? "pointer" : undefined, placeholder: withSearch ? (selectedOption ? selectedOption.label : placeholder) : placeholder, leftIcon: leftIcon, className: `react-better-html-dropdown${isOpen ? " react-better-html-dropdown-open" : ""}${isOpenLate ? " react-better-html-dropdown-open-late" : ""}${inputFieldClassName ? ` ${inputFieldClassName}` : ""}`, onClick: !disabled ? setIsOpen.toggle : undefined, onFocus: setIsFocused.setTrue, onBlur: setIsFocused.setFalse, onKeyDown: onKeyDownInputField, onChangeValue: withSearch ? onChangeValue : undefined, insideInputFieldComponent: (0, jsx_runtime_1.jsx)(Div_1.default, { position: "absolute", top: "100%", left: 0, width: "100%", maxHeight: 300, backgroundColor: theme.colors.backgroundContent, border: `1px solid ${isFocused ? theme.colors.primary : theme.colors.border}`, borderTop: "none", borderBottomLeftRadius: theme.styles.borderRadius, borderBottomRightRadius: theme.styles.borderRadius, boxShadow: "0px 10px 20px #00000020", zIndex: 1000, overflowY: "auto", opacity: !isOpen ? 0 : undefined, pointerEvents: !isOpen ? "none" : undefined, transform: `translateY(${!isOpen ? -10 : 0}px)`, transition: theme.styles.transition, role: "listbox", "aria-label": label, children: isLoadingDebouncedSearchQuery || debounceIsLoading ? ((0, jsx_runtime_1.jsx)(Div_1.default, { padding: `${theme.styles.space / 2}px ${theme.styles.space + theme.styles.gap}px`, children: (0, jsx_runtime_1.jsx)(Loader_1.default.text, {}) })) : filteredOptions.length ? (filteredOptions.map((option, index) => {
145
145
  const isSelected = option.value === value;
146
146
  const isDisabled = option.disabled;
147
147
  const isFocused = index === focusedOptionIndex;
@@ -6,11 +6,12 @@ type PageHeaderProps = {
6
6
  imageSize?: number;
7
7
  title?: string;
8
8
  titleAs?: TextAs;
9
+ titleRightElement?: React.ReactNode;
9
10
  description?: string;
10
11
  textAlign?: React.CSSProperties["textAlign"];
11
12
  rightElement?: React.ReactNode;
12
13
  lightMode?: boolean;
13
14
  } & Pick<ComponentMarginProps, "marginBottom">;
14
- declare function PageHeader({ imageUrl, imageSize, title, titleAs, description, textAlign, rightElement, lightMode, marginBottom, }: PageHeaderProps): import("react/jsx-runtime").JSX.Element;
15
+ declare function PageHeader({ imageUrl, imageSize, title, titleAs, titleRightElement, description, textAlign, rightElement, lightMode, marginBottom, }: PageHeaderProps): import("react/jsx-runtime").JSX.Element;
15
16
  declare const _default: React.MemoExoticComponent<typeof PageHeader>;
16
17
  export default _default;
@@ -10,9 +10,9 @@ const Div_1 = __importDefault(require("./Div"));
10
10
  const Text_1 = __importDefault(require("./Text"));
11
11
  const Image_1 = __importDefault(require("./Image"));
12
12
  const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
13
- function PageHeader({ imageUrl, imageSize = 60, title, titleAs, description, textAlign, rightElement, lightMode, marginBottom, }) {
13
+ function PageHeader({ imageUrl, imageSize = 60, title, titleAs, titleRightElement, description, textAlign, rightElement, lightMode, marginBottom, }) {
14
14
  const theme = (0, BetterHtmlProvider_1.useTheme)();
15
15
  const mediaQuery = (0, hooks_1.useMediaQuery)();
16
- return ((0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", gap: theme.styles.space, marginBottom: marginBottom ?? theme.styles.space * 2, children: [imageUrl && (0, jsx_runtime_1.jsx)(Image_1.default.profileImage, { src: imageUrl, size: imageSize ?? (mediaQuery.size600 ? 46 : 60) }), (0, jsx_runtime_1.jsxs)(Div_1.default.column, { flex: 1, gap: theme.styles.gap / 2, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { as: titleAs ?? "h1", textAlign: textAlign, color: lightMode ? theme.colors.base : theme.colors.textPrimary, children: title }), (0, jsx_runtime_1.jsx)(Text_1.default, { textAlign: textAlign, color: lightMode ? theme.colors.base : theme.colors.textSecondary, opacity: lightMode ? 0.7 : undefined, children: description })] }), rightElement] }));
16
+ return ((0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", gap: theme.styles.space, marginBottom: marginBottom ?? theme.styles.space * 2, children: [imageUrl && (0, jsx_runtime_1.jsx)(Image_1.default.profileImage, { src: imageUrl, size: imageSize ?? (mediaQuery.size600 ? 46 : 60) }), (0, jsx_runtime_1.jsxs)(Div_1.default.column, { flex: 1, gap: theme.styles.gap / 2, children: [(0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", gap: theme.styles.space, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { as: titleAs ?? "h1", textAlign: textAlign, color: lightMode ? theme.colors.base : theme.colors.textPrimary, children: title }), titleRightElement] }), (0, jsx_runtime_1.jsx)(Text_1.default, { textAlign: textAlign, color: lightMode ? theme.colors.base : theme.colors.textSecondary, opacity: lightMode ? 0.7 : undefined, children: description })] }), rightElement] }));
17
17
  }
18
18
  exports.default = (0, react_1.memo)(PageHeader);
@@ -17,6 +17,10 @@ export declare function usePageResize(): {
17
17
  width: number;
18
18
  height: number;
19
19
  };
20
+ export declare function usePageScroll(): {
21
+ scrollX: number;
22
+ scrollY: number;
23
+ };
20
24
  export declare function useMediaQuery(): {
21
25
  size320: boolean;
22
26
  size400: boolean;
@@ -5,6 +5,7 @@ exports.useComponentPropsWithPrefix = useComponentPropsWithPrefix;
5
5
  exports.useComponentPropsWithExcludedStyle = useComponentPropsWithExcludedStyle;
6
6
  exports.useComponentPropsWithoutStyle = useComponentPropsWithoutStyle;
7
7
  exports.usePageResize = usePageResize;
8
+ exports.usePageScroll = usePageScroll;
8
9
  exports.useMediaQuery = useMediaQuery;
9
10
  exports.useBooleanState = useBooleanState;
10
11
  exports.useDebounceState = useDebounceState;
@@ -114,6 +115,24 @@ function usePageResize() {
114
115
  height,
115
116
  };
116
117
  }
118
+ function usePageScroll() {
119
+ const [scrollX, setScrollX] = (0, react_1.useState)(window.scrollX ?? 0);
120
+ const [scrollY, setScrollY] = (0, react_1.useState)(window.scrollY ?? 0);
121
+ (0, react_1.useEffect)(() => {
122
+ const onScroll = () => {
123
+ setScrollX(window.scrollX);
124
+ setScrollY(window.scrollY);
125
+ };
126
+ window.addEventListener("scroll", onScroll);
127
+ return () => {
128
+ window.removeEventListener("scroll", onScroll);
129
+ };
130
+ }, []);
131
+ return {
132
+ scrollX,
133
+ scrollY,
134
+ };
135
+ }
117
136
  function useMediaQuery() {
118
137
  const { width } = usePageResize();
119
138
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-better-html",
3
- "version": "1.1.40",
3
+ "version": "1.1.42",
4
4
  "description": "A component library for react that is as close to plane html as possible",
5
5
  "main": "dist/index.js",
6
6
  "files": [