@0xsquid/ui 0.9.3 → 0.9.4

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/cjs/index.js CHANGED
@@ -3191,13 +3191,14 @@ const dropdownPositionClassMap = {
3191
3191
  bottom: 'tw-right-[calc(100%-10px)] tw-top-7',
3192
3192
  center: 'tw-right-[40px] -tw-top-[55px]',
3193
3193
  };
3194
- function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel = 'Pending', dropdownMenuItems, }) {
3194
+ function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel = 'Pending', dropdownMenuItems, itemsContainerRef, }) {
3195
3195
  const { isDropdownOpen, dropdownRef, openDropdownButtonRef, openDropdown } = useDropdownMenu();
3196
3196
  const [dropdownPosition, setDropdownPosition] = react.useState(null);
3197
3197
  const itemRef = react.useRef(null);
3198
3198
  const menuRef = react.useRef(null);
3199
3199
  // Effect to find the best position for the dropdown menu, so it's always visible for the user
3200
3200
  react.useEffect(() => {
3201
+ var _a;
3201
3202
  if (!isDropdownOpen) {
3202
3203
  // when the dropdown is closed, we want to reset its position
3203
3204
  // because user may scroll, and the old position may be out of view, so we'll need to recalculate it
@@ -3205,7 +3206,7 @@ function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted,
3205
3206
  return;
3206
3207
  }
3207
3208
  const item = itemRef.current;
3208
- const itemsContainer = item === null || item === void 0 ? void 0 : item.parentElement;
3209
+ const itemsContainer = (_a = itemsContainerRef === null || itemsContainerRef === void 0 ? void 0 : itemsContainerRef.current) !== null && _a !== void 0 ? _a : item === null || item === void 0 ? void 0 : item.parentElement;
3209
3210
  const dropdownMenu = menuRef.current;
3210
3211
  if (!item || !dropdownRef.current || !itemsContainer || !dropdownMenu) {
3211
3212
  return;
@@ -3240,7 +3241,7 @@ function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted,
3240
3241
  }
3241
3242
  }, [isDropdownOpen, menuRef, dropdownPosition, itemRef]);
3242
3243
  return (jsxRuntime.jsx("li", { ref: itemRef, className: "tw-h-list-item-large tw-min-w-list-item-small tw-self-stretch tw-bg-grey-900 tw-px-squid-xs tw-text-grey-300", children: jsxRuntime.jsxs("div", { className: "tw-group/history-item tw-relative tw-flex tw-flex-shrink-0 tw-cursor-pointer tw-items-center tw-gap-squid-xs tw-self-stretch tw-rounded-squid-s tw-px-squid-xs tw-py-squid-xxs hover:tw-bg-material-light-thin", children: [jsxRuntime.jsxs("div", { className: "tw-relative tw-h-10 tw-w-[60px]", children: [isPending ? (jsxRuntime.jsx("span", { className: "tw-absolute -tw-left-[5px] tw-bottom-0 tw-z-30 tw-flex tw-h-squid-m tw-w-squid-m tw-items-center tw-justify-center tw-rounded-full tw-border tw-border-grey-900 tw-bg-royal-400 tw-p-0.5", children: jsxRuntime.jsx(DotGrid1x3HorizontalIcon, {}) })) : null, jsxRuntime.jsx("img", { src: firstImageUrl, className: "tw-absolute tw-h-10 tw-w-10 tw-rounded-full tw-border tw-border-grey-900" }), jsxRuntime.jsx("img", { src: secondImageUrl, className: "tw-absolute tw-left-5 tw-h-10 tw-w-10 tw-rounded-full tw-border tw-border-grey-900" })] }), jsxRuntime.jsxs("div", { className: "tw-flex tw-h-10 tw-flex-1 tw-flex-col tw-self-stretch", children: [jsxRuntime.jsxs("div", { className: "tw-flex tw-h-5 tw-items-center tw-justify-between tw-text-grey-500", children: [jsxRuntime.jsxs("div", { className: "tw-flex tw-items-center", children: [jsxRuntime.jsx(CaptionText, { children: fromLabel }), jsxRuntime.jsx("span", { className: "tw-text-grey-600", children: jsxRuntime.jsx(ChevronRightSmallIcon, {}) }), jsxRuntime.jsx(CaptionText, { children: toLabel })] }), !!dropdownMenuItems && (jsxRuntime.jsx("button", { className: "tw-peer tw-absolute tw-right-squid-xxs tw-top-squid-xxs tw-flex tw-h-squid-xl tw-w-squid-xl tw-items-center tw-justify-center tw-rounded-squid-xs tw-bg-material-light-thin tw-p-2 tw-text-grey-300 tw-opacity-0 tw-transition-opacity focus:tw-opacity-100 group-hover/history-item:tw-opacity-100", onClick: openDropdown, ref: openDropdownButtonRef, children: jsxRuntime.jsx(DotGrid1x3HorizontalIcon, { size: "24" }) })), jsxRuntime.jsx("div", { className: cn(!!dropdownMenuItems &&
3243
- 'tw-transition-opacity group-hover/history-item:tw-opacity-0 peer-focus:tw-opacity-0'), children: isPending ? (jsxRuntime.jsx(CaptionText, { className: "tw-text-royal-400", children: pendingLabel })) : (jsxRuntime.jsx(CaptionText, { children: dateCompleted })) })] }), jsxRuntime.jsxs("div", { className: "tw-flex tw-h-5 tw-items-center tw-gap-squid-xxs tw-text-grey-300", children: [jsxRuntime.jsx(BodyText, { size: "small", children: fromAmount }), jsxRuntime.jsx("span", { className: "tw-text-grey-600", children: jsxRuntime.jsx(ChevronLargeRightIcon, {}) }), jsxRuntime.jsx(BodyText, { size: "small", children: toAmount })] })] }), isDropdownOpen && !!dropdownMenuItems ? (jsxRuntime.jsx(DropdownMenu, { menuRef: menuRef,
3244
+ 'tw-transition-opacity group-hover/history-item:tw-hidden group-hover/history-item:tw-opacity-0 peer-focus:tw-hidden peer-focus:tw-opacity-0'), children: isPending ? (jsxRuntime.jsx(CaptionText, { className: "tw-text-royal-400", children: pendingLabel })) : (jsxRuntime.jsx(CaptionText, { children: dateCompleted })) })] }), jsxRuntime.jsxs("div", { className: "tw-flex tw-h-5 tw-items-center tw-gap-squid-xxs tw-text-grey-300", children: [jsxRuntime.jsx(BodyText, { size: "small", children: fromAmount }), jsxRuntime.jsx("span", { className: "tw-text-grey-600", children: jsxRuntime.jsx(ChevronLargeRightIcon, {}) }), jsxRuntime.jsx(BodyText, { size: "small", children: toAmount })] })] }), isDropdownOpen && !!dropdownMenuItems ? (jsxRuntime.jsx(DropdownMenu, { menuRef: menuRef,
3244
3245
  // only show dropdown menu if there is a position defined for it
3245
3246
  isHidden: !dropdownPosition, className: cn(!!dropdownPosition && dropdownPositionClassMap[dropdownPosition]), dropdownRef: dropdownRef, items: dropdownMenuItems })) : null] }) }));
3246
3247
  }
@@ -3290,7 +3291,7 @@ function SettingsItem({ icon, label, controls = [], link, transparent = false, h
3290
3291
  return (jsxRuntime.jsx("li", { className: cn('tw-h-[50px] tw-self-stretch tw-px-squid-xs', transparent ? 'tw-bg-transparent' : 'tw-bg-grey-800'), children: jsxRuntime.jsxs(ContentTag, Object.assign({ className: cn('tw-flex tw-items-center tw-justify-center tw-gap-squid-xs tw-rounded-squid-s tw-px-squid-xs tw-py-squid-xs tw-text-grey-300', link && 'hover:tw-bg-material-light-thin') }, contentTagProps, { children: [icon, jsxRuntime.jsxs("div", { className: "tw-flex tw-flex-1 tw-items-center tw-gap-squid-xxs tw-self-stretch", children: [jsxRuntime.jsx(BodyText, { size: "small", children: label }), helpTooltip ? (jsxRuntime.jsx(Tooltip, Object.assign({}, helpTooltip, { children: helpIcon }))) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: helpIcon }))] }), jsxRuntime.jsx("div", { className: cn('tw-flex tw-h-squid-l tw-items-center tw-justify-center tw-rounded-squid-xs', showDetailsBorder &&
3291
3292
  'tw-rounded-squid-xs tw-border tw-border-solid tw-border-material-light-thin tw-bg-material-dark-thin'), children: !!link ? (jsxRuntime.jsx(SquareArrowTopRight2Icon, { className: "tw-text-material-light-average" })) : (controls.map((control, index) => {
3292
3293
  if (control.type === 'switch') {
3293
- const switchControl = (jsxRuntime.jsx(Switch, { size: "large", checked: control.checked, onChange: control.onChange }, index));
3294
+ const switchControl = (jsxRuntime.jsx(Switch, { size: "large", checked: control.checked, onChange: control.onChange, disabled: control.disabled }, index));
3294
3295
  if (control.tooltip) {
3295
3296
  return jsxRuntime.jsx(Tooltip, Object.assign({}, control.tooltip, { children: switchControl }));
3296
3297
  }
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { DropdownMenuItemProps } from './DropdownMenuItem';
2
3
  interface HistoryItemProps {
3
4
  firstImageUrl: string;
@@ -10,6 +11,7 @@ interface HistoryItemProps {
10
11
  fromAmount: string;
11
12
  toAmount: string;
12
13
  dropdownMenuItems?: DropdownMenuItemProps[];
14
+ itemsContainerRef?: React.RefObject<HTMLElement>;
13
15
  }
14
- export declare function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel, dropdownMenuItems, }: HistoryItemProps): import("react/jsx-runtime").JSX.Element;
16
+ export declare function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel, dropdownMenuItems, itemsContainerRef, }: HistoryItemProps): import("react/jsx-runtime").JSX.Element;
15
17
  export {};
@@ -26,6 +26,7 @@ export type SettingsControl = {
26
26
  checked: boolean;
27
27
  onChange: (checked: boolean) => void;
28
28
  tooltip?: Omit<TooltipProps, 'children'>;
29
+ disabled?: boolean;
29
30
  };
30
31
  export interface SettingsItemProps {
31
32
  icon: React.ReactNode;
package/dist/esm/index.js CHANGED
@@ -3189,13 +3189,14 @@ const dropdownPositionClassMap = {
3189
3189
  bottom: 'tw-right-[calc(100%-10px)] tw-top-7',
3190
3190
  center: 'tw-right-[40px] -tw-top-[55px]',
3191
3191
  };
3192
- function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel = 'Pending', dropdownMenuItems, }) {
3192
+ function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel = 'Pending', dropdownMenuItems, itemsContainerRef, }) {
3193
3193
  const { isDropdownOpen, dropdownRef, openDropdownButtonRef, openDropdown } = useDropdownMenu();
3194
3194
  const [dropdownPosition, setDropdownPosition] = useState(null);
3195
3195
  const itemRef = useRef(null);
3196
3196
  const menuRef = useRef(null);
3197
3197
  // Effect to find the best position for the dropdown menu, so it's always visible for the user
3198
3198
  useEffect(() => {
3199
+ var _a;
3199
3200
  if (!isDropdownOpen) {
3200
3201
  // when the dropdown is closed, we want to reset its position
3201
3202
  // because user may scroll, and the old position may be out of view, so we'll need to recalculate it
@@ -3203,7 +3204,7 @@ function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted,
3203
3204
  return;
3204
3205
  }
3205
3206
  const item = itemRef.current;
3206
- const itemsContainer = item === null || item === void 0 ? void 0 : item.parentElement;
3207
+ const itemsContainer = (_a = itemsContainerRef === null || itemsContainerRef === void 0 ? void 0 : itemsContainerRef.current) !== null && _a !== void 0 ? _a : item === null || item === void 0 ? void 0 : item.parentElement;
3207
3208
  const dropdownMenu = menuRef.current;
3208
3209
  if (!item || !dropdownRef.current || !itemsContainer || !dropdownMenu) {
3209
3210
  return;
@@ -3238,7 +3239,7 @@ function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted,
3238
3239
  }
3239
3240
  }, [isDropdownOpen, menuRef, dropdownPosition, itemRef]);
3240
3241
  return (jsx("li", { ref: itemRef, className: "tw-h-list-item-large tw-min-w-list-item-small tw-self-stretch tw-bg-grey-900 tw-px-squid-xs tw-text-grey-300", children: jsxs("div", { className: "tw-group/history-item tw-relative tw-flex tw-flex-shrink-0 tw-cursor-pointer tw-items-center tw-gap-squid-xs tw-self-stretch tw-rounded-squid-s tw-px-squid-xs tw-py-squid-xxs hover:tw-bg-material-light-thin", children: [jsxs("div", { className: "tw-relative tw-h-10 tw-w-[60px]", children: [isPending ? (jsx("span", { className: "tw-absolute -tw-left-[5px] tw-bottom-0 tw-z-30 tw-flex tw-h-squid-m tw-w-squid-m tw-items-center tw-justify-center tw-rounded-full tw-border tw-border-grey-900 tw-bg-royal-400 tw-p-0.5", children: jsx(DotGrid1x3HorizontalIcon, {}) })) : null, jsx("img", { src: firstImageUrl, className: "tw-absolute tw-h-10 tw-w-10 tw-rounded-full tw-border tw-border-grey-900" }), jsx("img", { src: secondImageUrl, className: "tw-absolute tw-left-5 tw-h-10 tw-w-10 tw-rounded-full tw-border tw-border-grey-900" })] }), jsxs("div", { className: "tw-flex tw-h-10 tw-flex-1 tw-flex-col tw-self-stretch", children: [jsxs("div", { className: "tw-flex tw-h-5 tw-items-center tw-justify-between tw-text-grey-500", children: [jsxs("div", { className: "tw-flex tw-items-center", children: [jsx(CaptionText, { children: fromLabel }), jsx("span", { className: "tw-text-grey-600", children: jsx(ChevronRightSmallIcon, {}) }), jsx(CaptionText, { children: toLabel })] }), !!dropdownMenuItems && (jsx("button", { className: "tw-peer tw-absolute tw-right-squid-xxs tw-top-squid-xxs tw-flex tw-h-squid-xl tw-w-squid-xl tw-items-center tw-justify-center tw-rounded-squid-xs tw-bg-material-light-thin tw-p-2 tw-text-grey-300 tw-opacity-0 tw-transition-opacity focus:tw-opacity-100 group-hover/history-item:tw-opacity-100", onClick: openDropdown, ref: openDropdownButtonRef, children: jsx(DotGrid1x3HorizontalIcon, { size: "24" }) })), jsx("div", { className: cn(!!dropdownMenuItems &&
3241
- 'tw-transition-opacity group-hover/history-item:tw-opacity-0 peer-focus:tw-opacity-0'), children: isPending ? (jsx(CaptionText, { className: "tw-text-royal-400", children: pendingLabel })) : (jsx(CaptionText, { children: dateCompleted })) })] }), jsxs("div", { className: "tw-flex tw-h-5 tw-items-center tw-gap-squid-xxs tw-text-grey-300", children: [jsx(BodyText, { size: "small", children: fromAmount }), jsx("span", { className: "tw-text-grey-600", children: jsx(ChevronLargeRightIcon, {}) }), jsx(BodyText, { size: "small", children: toAmount })] })] }), isDropdownOpen && !!dropdownMenuItems ? (jsx(DropdownMenu, { menuRef: menuRef,
3242
+ 'tw-transition-opacity group-hover/history-item:tw-hidden group-hover/history-item:tw-opacity-0 peer-focus:tw-hidden peer-focus:tw-opacity-0'), children: isPending ? (jsx(CaptionText, { className: "tw-text-royal-400", children: pendingLabel })) : (jsx(CaptionText, { children: dateCompleted })) })] }), jsxs("div", { className: "tw-flex tw-h-5 tw-items-center tw-gap-squid-xxs tw-text-grey-300", children: [jsx(BodyText, { size: "small", children: fromAmount }), jsx("span", { className: "tw-text-grey-600", children: jsx(ChevronLargeRightIcon, {}) }), jsx(BodyText, { size: "small", children: toAmount })] })] }), isDropdownOpen && !!dropdownMenuItems ? (jsx(DropdownMenu, { menuRef: menuRef,
3242
3243
  // only show dropdown menu if there is a position defined for it
3243
3244
  isHidden: !dropdownPosition, className: cn(!!dropdownPosition && dropdownPositionClassMap[dropdownPosition]), dropdownRef: dropdownRef, items: dropdownMenuItems })) : null] }) }));
3244
3245
  }
@@ -3288,7 +3289,7 @@ function SettingsItem({ icon, label, controls = [], link, transparent = false, h
3288
3289
  return (jsx("li", { className: cn('tw-h-[50px] tw-self-stretch tw-px-squid-xs', transparent ? 'tw-bg-transparent' : 'tw-bg-grey-800'), children: jsxs(ContentTag, Object.assign({ className: cn('tw-flex tw-items-center tw-justify-center tw-gap-squid-xs tw-rounded-squid-s tw-px-squid-xs tw-py-squid-xs tw-text-grey-300', link && 'hover:tw-bg-material-light-thin') }, contentTagProps, { children: [icon, jsxs("div", { className: "tw-flex tw-flex-1 tw-items-center tw-gap-squid-xxs tw-self-stretch", children: [jsx(BodyText, { size: "small", children: label }), helpTooltip ? (jsx(Tooltip, Object.assign({}, helpTooltip, { children: helpIcon }))) : (jsx(Fragment, { children: helpIcon }))] }), jsx("div", { className: cn('tw-flex tw-h-squid-l tw-items-center tw-justify-center tw-rounded-squid-xs', showDetailsBorder &&
3289
3290
  'tw-rounded-squid-xs tw-border tw-border-solid tw-border-material-light-thin tw-bg-material-dark-thin'), children: !!link ? (jsx(SquareArrowTopRight2Icon, { className: "tw-text-material-light-average" })) : (controls.map((control, index) => {
3290
3291
  if (control.type === 'switch') {
3291
- const switchControl = (jsx(Switch, { size: "large", checked: control.checked, onChange: control.onChange }, index));
3292
+ const switchControl = (jsx(Switch, { size: "large", checked: control.checked, onChange: control.onChange, disabled: control.disabled }, index));
3292
3293
  if (control.tooltip) {
3293
3294
  return jsx(Tooltip, Object.assign({}, control.tooltip, { children: switchControl }));
3294
3295
  }
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { DropdownMenuItemProps } from './DropdownMenuItem';
2
3
  interface HistoryItemProps {
3
4
  firstImageUrl: string;
@@ -10,6 +11,7 @@ interface HistoryItemProps {
10
11
  fromAmount: string;
11
12
  toAmount: string;
12
13
  dropdownMenuItems?: DropdownMenuItemProps[];
14
+ itemsContainerRef?: React.RefObject<HTMLElement>;
13
15
  }
14
- export declare function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel, dropdownMenuItems, }: HistoryItemProps): import("react/jsx-runtime").JSX.Element;
16
+ export declare function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel, dropdownMenuItems, itemsContainerRef, }: HistoryItemProps): import("react/jsx-runtime").JSX.Element;
15
17
  export {};
@@ -26,6 +26,7 @@ export type SettingsControl = {
26
26
  checked: boolean;
27
27
  onChange: (checked: boolean) => void;
28
28
  tooltip?: Omit<TooltipProps, 'children'>;
29
+ disabled?: boolean;
29
30
  };
30
31
  export interface SettingsItemProps {
31
32
  icon: React.ReactNode;
package/dist/index.css CHANGED
@@ -2697,6 +2697,10 @@ input[type='number'] {
2697
2697
  display: flex;
2698
2698
  }
2699
2699
 
2700
+ .tw-group\/history-item:hover .group-hover\/history-item\:tw-hidden {
2701
+ display: none;
2702
+ }
2703
+
2700
2704
  .tw-group\/history-item:hover .group-hover\/history-item\:tw-opacity-0 {
2701
2705
  opacity: 0;
2702
2706
  }
@@ -2714,6 +2718,10 @@ input[type='number'] {
2714
2718
  display: block;
2715
2719
  }
2716
2720
 
2721
+ .tw-peer:focus ~ .peer-focus\:tw-hidden {
2722
+ display: none;
2723
+ }
2724
+
2717
2725
  .tw-peer:focus ~ .peer-focus\:tw-opacity-0 {
2718
2726
  opacity: 0;
2719
2727
  }
package/dist/index.d.ts CHANGED
@@ -202,8 +202,9 @@ interface HistoryItemProps {
202
202
  fromAmount: string;
203
203
  toAmount: string;
204
204
  dropdownMenuItems?: DropdownMenuItemProps[];
205
+ itemsContainerRef?: React.RefObject<HTMLElement>;
205
206
  }
206
- declare function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel, dropdownMenuItems, }: HistoryItemProps): react_jsx_runtime.JSX.Element;
207
+ declare function HistoryItem({ firstImageUrl, secondImageUrl, isPending, dateCompleted, fromAmount, fromLabel, toAmount, toLabel, pendingLabel, dropdownMenuItems, itemsContainerRef, }: HistoryItemProps): react_jsx_runtime.JSX.Element;
207
208
 
208
209
  interface ListItemProps extends React.HTMLAttributes<HTMLLIElement> {
209
210
  itemTitle: string | React.ReactNode;
@@ -269,6 +270,7 @@ type SettingsControl = {
269
270
  checked: boolean;
270
271
  onChange: (checked: boolean) => void;
271
272
  tooltip?: Omit<TooltipProps, 'children'>;
273
+ disabled?: boolean;
272
274
  };
273
275
  interface SettingsItemProps {
274
276
  icon: React.ReactNode;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "git+https://github.com/0xsquid/squid-ui.git"
6
6
  },
7
7
  "description": "Squid's UI components",
8
- "version": "0.9.3",
8
+ "version": "0.9.4",
9
9
  "author": "",
10
10
  "license": "MIT",
11
11
  "scripts": {