@scripso-homepad/ui 0.4.13 → 0.4.14
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/README.md +2 -1
- package/dist/{chunk-WFMQYYH6.js → chunk-ANDWP4YU.js} +12 -3
- package/dist/chunk-ANDWP4YU.js.map +1 -0
- package/dist/index.cjs +51 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +43 -40
- package/dist/index.js.map +1 -1
- package/dist/web/index.cjs +30 -10
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.d.cts +7 -2
- package/dist/web/index.d.ts +7 -2
- package/dist/web/index.js +21 -10
- package/dist/web/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Input.tsx +8 -1
- package/src/components/PhoneInput.tsx +37 -34
- package/src/web/components/TableActionsMenu.tsx +25 -6
- package/src/web/layout/AppHeader.tsx +15 -11
- package/dist/chunk-WFMQYYH6.js.map +0 -1
package/dist/web/index.d.cts
CHANGED
|
@@ -50,6 +50,7 @@ type AppHeaderProps = {
|
|
|
50
50
|
title: string;
|
|
51
51
|
labels: AdminHeaderLabels;
|
|
52
52
|
hasBuildingSelect?: boolean;
|
|
53
|
+
showSearch?: boolean;
|
|
53
54
|
buildingOptions?: AdminBuildingOption[];
|
|
54
55
|
selectedBuildingId?: string;
|
|
55
56
|
className?: string;
|
|
@@ -69,7 +70,7 @@ type AppHeaderProps = {
|
|
|
69
70
|
onNotificationsClick?: () => void;
|
|
70
71
|
onSearchChange?: (value: string) => void;
|
|
71
72
|
};
|
|
72
|
-
declare function AppHeader({ title, labels, hasBuildingSelect, buildingOptions, selectedBuildingId, className, buildingSelectClassName, searchClassName, notificationsButtonClassName, searchValue, searchFieldStyle, buildingIcon, notificationsIcon, searchIcon, buildingChevronIcon, buildingSelectDisabled, searchDisabled, notificationsDisabled, onBuildingChange, onNotificationsClick, onSearchChange, }: AppHeaderProps): react.JSX.Element;
|
|
73
|
+
declare function AppHeader({ title, labels, hasBuildingSelect, showSearch, buildingOptions, selectedBuildingId, className, buildingSelectClassName, searchClassName, notificationsButtonClassName, searchValue, searchFieldStyle, buildingIcon, notificationsIcon, searchIcon, buildingChevronIcon, buildingSelectDisabled, searchDisabled, notificationsDisabled, onBuildingChange, onNotificationsClick, onSearchChange, }: AppHeaderProps): react.JSX.Element;
|
|
73
74
|
|
|
74
75
|
type BuildingSelectProps = {
|
|
75
76
|
options: AdminBuildingOption[];
|
|
@@ -251,8 +252,12 @@ type TableActionsMenuProps = {
|
|
|
251
252
|
triggerAriaLabel: string;
|
|
252
253
|
className?: string;
|
|
253
254
|
menuClassName?: string;
|
|
255
|
+
/** Dropdown menu width in pixels. Defaults to 231. Ignored when menuFitContent is true. */
|
|
256
|
+
menuWidth?: number;
|
|
257
|
+
/** Size the menu to its content width instead of a fixed pixel width. */
|
|
258
|
+
menuFitContent?: boolean;
|
|
254
259
|
};
|
|
255
|
-
declare function TableActionsMenu({ items, triggerAriaLabel, className, menuClassName, }: TableActionsMenuProps): react.JSX.Element | null;
|
|
260
|
+
declare function TableActionsMenu({ items, triggerAriaLabel, className, menuClassName, menuWidth, menuFitContent, }: TableActionsMenuProps): react.JSX.Element | null;
|
|
256
261
|
|
|
257
262
|
type TableRowActionsConfig = {
|
|
258
263
|
status: ReactNode;
|
package/dist/web/index.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ type AppHeaderProps = {
|
|
|
50
50
|
title: string;
|
|
51
51
|
labels: AdminHeaderLabels;
|
|
52
52
|
hasBuildingSelect?: boolean;
|
|
53
|
+
showSearch?: boolean;
|
|
53
54
|
buildingOptions?: AdminBuildingOption[];
|
|
54
55
|
selectedBuildingId?: string;
|
|
55
56
|
className?: string;
|
|
@@ -69,7 +70,7 @@ type AppHeaderProps = {
|
|
|
69
70
|
onNotificationsClick?: () => void;
|
|
70
71
|
onSearchChange?: (value: string) => void;
|
|
71
72
|
};
|
|
72
|
-
declare function AppHeader({ title, labels, hasBuildingSelect, buildingOptions, selectedBuildingId, className, buildingSelectClassName, searchClassName, notificationsButtonClassName, searchValue, searchFieldStyle, buildingIcon, notificationsIcon, searchIcon, buildingChevronIcon, buildingSelectDisabled, searchDisabled, notificationsDisabled, onBuildingChange, onNotificationsClick, onSearchChange, }: AppHeaderProps): react.JSX.Element;
|
|
73
|
+
declare function AppHeader({ title, labels, hasBuildingSelect, showSearch, buildingOptions, selectedBuildingId, className, buildingSelectClassName, searchClassName, notificationsButtonClassName, searchValue, searchFieldStyle, buildingIcon, notificationsIcon, searchIcon, buildingChevronIcon, buildingSelectDisabled, searchDisabled, notificationsDisabled, onBuildingChange, onNotificationsClick, onSearchChange, }: AppHeaderProps): react.JSX.Element;
|
|
73
74
|
|
|
74
75
|
type BuildingSelectProps = {
|
|
75
76
|
options: AdminBuildingOption[];
|
|
@@ -251,8 +252,12 @@ type TableActionsMenuProps = {
|
|
|
251
252
|
triggerAriaLabel: string;
|
|
252
253
|
className?: string;
|
|
253
254
|
menuClassName?: string;
|
|
255
|
+
/** Dropdown menu width in pixels. Defaults to 231. Ignored when menuFitContent is true. */
|
|
256
|
+
menuWidth?: number;
|
|
257
|
+
/** Size the menu to its content width instead of a fixed pixel width. */
|
|
258
|
+
menuFitContent?: boolean;
|
|
254
259
|
};
|
|
255
|
-
declare function TableActionsMenu({ items, triggerAriaLabel, className, menuClassName, }: TableActionsMenuProps): react.JSX.Element | null;
|
|
260
|
+
declare function TableActionsMenu({ items, triggerAriaLabel, className, menuClassName, menuWidth, menuFitContent, }: TableActionsMenuProps): react.JSX.Element | null;
|
|
256
261
|
|
|
257
262
|
type TableRowActionsConfig = {
|
|
258
263
|
status: ReactNode;
|
package/dist/web/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __commonJS, __require, __toESM, Input, Button } from '../chunk-
|
|
1
|
+
import { __commonJS, __require, __toESM, Input, Button } from '../chunk-ANDWP4YU.js';
|
|
2
2
|
import { ChevronsUpDown, Search, LogOut, PanelLeftClose, PanelLeftOpen, X, Menu, ChevronLeft, ChevronRight } from 'lucide-react';
|
|
3
3
|
import { clsx } from 'clsx';
|
|
4
4
|
import { twMerge } from 'tailwind-merge';
|
|
@@ -28782,6 +28782,7 @@ function AppHeader({
|
|
|
28782
28782
|
title,
|
|
28783
28783
|
labels,
|
|
28784
28784
|
hasBuildingSelect = false,
|
|
28785
|
+
showSearch = true,
|
|
28785
28786
|
buildingOptions = [],
|
|
28786
28787
|
selectedBuildingId = "",
|
|
28787
28788
|
className,
|
|
@@ -28824,7 +28825,7 @@ function AppHeader({
|
|
|
28824
28825
|
chevronIcon: buildingChevronIcon
|
|
28825
28826
|
}
|
|
28826
28827
|
) : null,
|
|
28827
|
-
/* @__PURE__ */ jsx(
|
|
28828
|
+
showSearch ? /* @__PURE__ */ jsx(
|
|
28828
28829
|
Input,
|
|
28829
28830
|
{
|
|
28830
28831
|
leftIcon: searchIcon ?? /* @__PURE__ */ jsx(Search, { strokeWidth: 1.75 }),
|
|
@@ -28837,7 +28838,7 @@ function AppHeader({
|
|
|
28837
28838
|
fieldStyle: searchFieldStyle ?? defaultSearchFieldStyle,
|
|
28838
28839
|
accessibilityLabel: labels.searchPlaceholder
|
|
28839
28840
|
}
|
|
28840
|
-
),
|
|
28841
|
+
) : null,
|
|
28841
28842
|
/* @__PURE__ */ jsx(
|
|
28842
28843
|
"button",
|
|
28843
28844
|
{
|
|
@@ -29876,12 +29877,12 @@ var MENU_WIDTH_PX = 231;
|
|
|
29876
29877
|
var MENU_OFFSET_PX = 4;
|
|
29877
29878
|
var MENU_VIEWPORT_MARGIN_PX = 8;
|
|
29878
29879
|
var useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
29879
|
-
function clampMenuLeft(left) {
|
|
29880
|
+
function clampMenuLeft(left, menuWidth) {
|
|
29880
29881
|
if (typeof window === "undefined") {
|
|
29881
29882
|
return left;
|
|
29882
29883
|
}
|
|
29883
29884
|
const minLeft = MENU_VIEWPORT_MARGIN_PX;
|
|
29884
|
-
const maxLeft = Math.max(minLeft, window.innerWidth -
|
|
29885
|
+
const maxLeft = Math.max(minLeft, window.innerWidth - menuWidth - MENU_VIEWPORT_MARGIN_PX);
|
|
29885
29886
|
return Math.min(Math.max(left, minLeft), maxLeft);
|
|
29886
29887
|
}
|
|
29887
29888
|
function resolveMenuItemIcon(item) {
|
|
@@ -29901,7 +29902,9 @@ function TableActionsMenu({
|
|
|
29901
29902
|
items,
|
|
29902
29903
|
triggerAriaLabel,
|
|
29903
29904
|
className,
|
|
29904
|
-
menuClassName
|
|
29905
|
+
menuClassName,
|
|
29906
|
+
menuWidth = MENU_WIDTH_PX,
|
|
29907
|
+
menuFitContent = false
|
|
29905
29908
|
}) {
|
|
29906
29909
|
const [open, setOpen] = useState(false);
|
|
29907
29910
|
const [menuPosition, setMenuPosition] = useState(null);
|
|
@@ -29918,11 +29921,12 @@ function TableActionsMenu({
|
|
|
29918
29921
|
return;
|
|
29919
29922
|
}
|
|
29920
29923
|
const rect = trigger.getBoundingClientRect();
|
|
29924
|
+
const resolvedMenuWidth = menuFitContent ? menuRef.current?.getBoundingClientRect().width ?? menuWidth : menuWidth;
|
|
29921
29925
|
setMenuPosition({
|
|
29922
29926
|
top: rect.bottom + MENU_OFFSET_PX,
|
|
29923
|
-
left: clampMenuLeft(rect.right -
|
|
29927
|
+
left: clampMenuLeft(rect.right - resolvedMenuWidth, resolvedMenuWidth)
|
|
29924
29928
|
});
|
|
29925
|
-
}, []);
|
|
29929
|
+
}, [menuFitContent, menuWidth]);
|
|
29926
29930
|
useOnClickOutside([rootRef, menuRef], closeMenu, open);
|
|
29927
29931
|
useIsomorphicLayoutEffect(() => {
|
|
29928
29932
|
if (!open) {
|
|
@@ -29931,6 +29935,12 @@ function TableActionsMenu({
|
|
|
29931
29935
|
}
|
|
29932
29936
|
updateMenuPosition();
|
|
29933
29937
|
}, [open, updateMenuPosition]);
|
|
29938
|
+
useIsomorphicLayoutEffect(() => {
|
|
29939
|
+
if (!open || !menuFitContent) {
|
|
29940
|
+
return;
|
|
29941
|
+
}
|
|
29942
|
+
updateMenuPosition();
|
|
29943
|
+
}, [items, menuFitContent, open, updateMenuPosition]);
|
|
29934
29944
|
useEffect(() => {
|
|
29935
29945
|
if (!open) {
|
|
29936
29946
|
return;
|
|
@@ -29966,7 +29976,7 @@ function TableActionsMenu({
|
|
|
29966
29976
|
position: "fixed",
|
|
29967
29977
|
top: menuPosition.top,
|
|
29968
29978
|
left: menuPosition.left,
|
|
29969
|
-
width:
|
|
29979
|
+
...menuFitContent ? { width: "max-content" } : { width: menuWidth }
|
|
29970
29980
|
},
|
|
29971
29981
|
className: cn(
|
|
29972
29982
|
"z-50 overflow-hidden rounded-2xl border border-storm-gray-50 bg-white shadow-[0_4px_20px_0_rgba(0,0,0,0.05)]",
|
|
@@ -29988,7 +29998,8 @@ function TableActionsMenu({
|
|
|
29988
29998
|
item.onSelect();
|
|
29989
29999
|
},
|
|
29990
30000
|
className: cn(
|
|
29991
|
-
"flex h-[51px]
|
|
30001
|
+
"flex h-[51px] cursor-pointer items-center gap-2.5 px-3 text-left typography-14 font-medium text-storm-gray-900 transition-colors hover:bg-storm-gray-0",
|
|
30002
|
+
menuFitContent ? "w-auto" : "w-full",
|
|
29992
30003
|
index > 0 && "border-t border-storm-gray-50",
|
|
29993
30004
|
item.disabled && "cursor-not-allowed opacity-50"
|
|
29994
30005
|
),
|