addon-ui 0.8.0 → 0.9.0

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 CHANGED
@@ -69,6 +69,7 @@ This library now ships with dedicated documentation files for each component in
69
69
  - [Modal](docs/Modal.md)
70
70
  - [Odometer](docs/Odometer.md) (component + useOdometer hook)
71
71
  - [ScrollArea](docs/ScrollArea.md)
72
+ - [Select](docs/Select.md)
72
73
  - [SvgSprite](docs/SvgSprite.md)
73
74
  - [Switch](docs/Switch.md)
74
75
  - [Tabs](docs/Tabs.md) (includes Tabs, TabsList, TabsTrigger, TabsContent)
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ import { SelectProps } from "@radix-ui/react-select";
3
+ export { SelectProps };
4
+ declare const _default: React.NamedExoticComponent<SelectProps>;
5
+ export default _default;
6
+ //# sourceMappingURL=Select.d.ts.map
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { SelectContentProps as SelectContentRadixProps, SelectPortalProps, SelectViewportProps } from "@radix-ui/react-select";
3
+ export interface SelectContentProps extends SelectContentRadixProps, SelectPortalProps {
4
+ arrow?: boolean;
5
+ arrowWidth?: number;
6
+ arrowHeight?: number;
7
+ fullWidth?: boolean;
8
+ viewportProps?: SelectViewportProps;
9
+ scrollUpButton?: React.ReactNode;
10
+ scrollDownButton?: React.ReactNode;
11
+ }
12
+ declare const _default: React.NamedExoticComponent<SelectContentProps & React.RefAttributes<HTMLDivElement>>;
13
+ export default _default;
14
+ //# sourceMappingURL=SelectContent.d.ts.map
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ import { SelectIconProps } from "@radix-ui/react-select";
3
+ export { SelectIconProps };
4
+ declare const _default: React.NamedExoticComponent<SelectIconProps & React.RefAttributes<HTMLSpanElement>>;
5
+ export default _default;
6
+ //# sourceMappingURL=SelectIcon.d.ts.map
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { SelectItemProps as SelectItemRadixProps } from "@radix-ui/react-select";
3
+ export interface SelectItemProps extends SelectItemRadixProps {
4
+ indicator?: React.ReactNode;
5
+ indicatorClassname?: string;
6
+ }
7
+ declare const _default: React.NamedExoticComponent<SelectItemProps & React.RefAttributes<HTMLDivElement>>;
8
+ export default _default;
9
+ //# sourceMappingURL=SelectItem.d.ts.map
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { SelectIconProps, SelectTriggerProps as SelectTriggerRadixProps, SelectValueProps } from "@radix-ui/react-select";
3
+ export interface SelectTriggerProps extends SelectTriggerRadixProps {
4
+ center?: boolean;
5
+ fullWidth?: boolean;
6
+ ellipsis?: boolean;
7
+ icon?: React.ReactNode;
8
+ placeholder?: React.ReactNode;
9
+ valueProps?: SelectValueProps;
10
+ iconProps?: SelectIconProps;
11
+ }
12
+ declare const _default: React.NamedExoticComponent<SelectTriggerProps & React.RefAttributes<HTMLButtonElement>>;
13
+ export default _default;
14
+ //# sourceMappingURL=SelectTrigger.d.ts.map
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ import { SelectValueProps } from "@radix-ui/react-select";
3
+ export { SelectValueProps };
4
+ declare const _default: React.NamedExoticComponent<SelectValueProps & React.RefAttributes<HTMLSpanElement>>;
5
+ export default _default;
6
+ //# sourceMappingURL=SelectValue.d.ts.map
@@ -0,0 +1,7 @@
1
+ export { default as Select, type SelectProps } from "./Select";
2
+ export { default as SelectItem, type SelectItemProps } from "./SelectItem";
3
+ export { default as SelectIcon, type SelectIconProps } from "./SelectIcon";
4
+ export { default as SelectValue, type SelectValueProps } from "./SelectValue";
5
+ export { default as SelectTrigger, type SelectTriggerProps } from "./SelectTrigger";
6
+ export { default as SelectContent, type SelectContentProps } from "./SelectContent";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -15,6 +15,7 @@ export * from "./ListItem";
15
15
  export * from "./Modal";
16
16
  export * from "./Odometer";
17
17
  export * from "./ScrollArea";
18
+ export * from "./Select";
18
19
  export * from "./SvgSprite";
19
20
  export * from "./Switch";
20
21
  export * from "./Tabs";
@@ -1,4 +1,4 @@
1
- import type { AvatarProps, ButtonProps, CheckboxProps, DialogProps, DrawerProps, FooterProps, HeaderProps, HighlightProps, IconProps, IconButtonProps, ListProps, ListItemProps, ModalProps, OdometerProps, ScrollAreaProps, SwitchProps, TabsProps, TabsContentProps, TabsListProps, TabsTriggerProps, TagProps, TextAreaProps, TextFieldProps, ToastProps, TooltipProps, TruncateProps, TruncateListProps, ViewProps, ViewDrawerProps, ViewModalProps } from "../components";
1
+ import type { AvatarProps, ButtonProps, CheckboxProps, DialogProps, DrawerProps, FooterProps, HeaderProps, HighlightProps, IconProps, IconButtonProps, ListProps, ListItemProps, ModalProps, OdometerProps, ScrollAreaProps, SelectProps, SelectItemProps, SelectIconProps, SelectValueProps, SelectContentProps, SelectTriggerProps, SwitchProps, TabsProps, TabsContentProps, TabsListProps, TabsTriggerProps, TagProps, TextAreaProps, TextFieldProps, ToastProps, TooltipProps, TruncateProps, TruncateListProps, ViewProps, ViewDrawerProps, ViewModalProps } from "../components";
2
2
  export interface ComponentsProps {
3
3
  avatar?: Pick<AvatarProps, "size" | "radius" | "cursorPointer" | "delayMs">;
4
4
  button?: Pick<ButtonProps, "variant" | "color" | "size" | "radius">;
@@ -15,6 +15,12 @@ export interface ComponentsProps {
15
15
  modal?: ModalProps;
16
16
  odometer?: Pick<OdometerProps, "auto" | "format" | "duration">;
17
17
  scrollArea?: ScrollAreaProps;
18
+ select?: SelectProps;
19
+ selectItem?: SelectItemProps;
20
+ selectIcon?: SelectIconProps;
21
+ selectValue?: SelectValueProps;
22
+ selectContent?: SelectContentProps;
23
+ selectTrigger?: SelectTriggerProps;
18
24
  switch?: SwitchProps;
19
25
  tabs?: TabsProps;
20
26
  tabsContent?: TabsContentProps;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "addon-ui",
3
3
  "type": "module",
4
- "version": "0.8.0",
4
+ "version": "0.9.0",
5
5
  "description": "A comprehensive React UI component library designed exclusively for the AddonBone browser extension framework with customizable theming and consistent design patterns",
6
6
  "keywords": [
7
7
  "react",
@@ -0,0 +1,19 @@
1
+ import React, {FC, memo} from "react";
2
+
3
+ import {useLocale} from "adnbn/locale/react";
4
+
5
+ import {Root, SelectProps} from "@radix-ui/react-select";
6
+
7
+ import {useComponentProps} from "../../providers";
8
+
9
+ export {SelectProps};
10
+
11
+ const Select: FC<SelectProps> = props => {
12
+ const {...other} = {...useComponentProps("select"), ...props};
13
+
14
+ const {dir} = useLocale();
15
+
16
+ return <Root dir={dir} {...other} />;
17
+ };
18
+
19
+ export default memo(Select);
@@ -0,0 +1,84 @@
1
+ import React, {forwardRef, ForwardRefRenderFunction, memo} from "react";
2
+
3
+ import classnames from "classnames";
4
+
5
+ import {
6
+ Arrow,
7
+ Content,
8
+ Portal,
9
+ SelectContentProps as SelectContentRadixProps,
10
+ SelectPortalProps,
11
+ SelectScrollDownButton,
12
+ SelectScrollUpButton,
13
+ SelectViewportProps,
14
+ Viewport,
15
+ } from "@radix-ui/react-select";
16
+
17
+ import {useComponentProps} from "../../providers";
18
+
19
+ import styles from "./select.module.scss";
20
+
21
+ export interface SelectContentProps extends SelectContentRadixProps, SelectPortalProps {
22
+ arrow?: boolean;
23
+ arrowWidth?: number;
24
+ arrowHeight?: number;
25
+ fullWidth?: boolean;
26
+ viewportProps?: SelectViewportProps;
27
+ scrollUpButton?: React.ReactNode;
28
+ scrollDownButton?: React.ReactNode;
29
+ }
30
+
31
+ const SelectContent: ForwardRefRenderFunction<HTMLDivElement, SelectContentProps> = (props, ref) => {
32
+ const {
33
+ arrow,
34
+ arrowWidth,
35
+ arrowHeight,
36
+ fullWidth,
37
+ container,
38
+ viewportProps,
39
+ scrollUpButton,
40
+ scrollDownButton,
41
+ className,
42
+ children,
43
+ ...other
44
+ } = {...useComponentProps("selectContent"), ...props};
45
+
46
+ return (
47
+ <Portal container={container}>
48
+ <Content
49
+ ref={ref}
50
+ className={classnames(
51
+ styles["select__content"],
52
+ {
53
+ [styles["select__content--full-width"]]: fullWidth,
54
+ },
55
+ className
56
+ )}
57
+ {...other}
58
+ >
59
+ {scrollUpButton && (
60
+ <SelectScrollUpButton className={classnames(styles["select__scroll-button"])}>
61
+ {scrollUpButton}
62
+ </SelectScrollUpButton>
63
+ )}
64
+
65
+ <Viewport
66
+ {...viewportProps}
67
+ className={classnames(styles["select__viewport"], viewportProps?.className)}
68
+ >
69
+ {children}
70
+ </Viewport>
71
+
72
+ {scrollDownButton && (
73
+ <SelectScrollDownButton className={classnames(styles["select__scroll-button"])}>
74
+ {scrollDownButton}
75
+ </SelectScrollDownButton>
76
+ )}
77
+
78
+ {arrow && <Arrow width={arrowWidth} height={arrowHeight} />}
79
+ </Content>
80
+ </Portal>
81
+ );
82
+ };
83
+
84
+ export default memo(forwardRef(SelectContent));
@@ -0,0 +1,19 @@
1
+ import React, {forwardRef, ForwardRefRenderFunction, memo} from "react";
2
+
3
+ import classnames from "classnames";
4
+
5
+ import {SelectIconProps, Icon} from "@radix-ui/react-select";
6
+
7
+ import {useComponentProps} from "../../providers";
8
+
9
+ import styles from "./select.module.scss";
10
+
11
+ export {SelectIconProps};
12
+
13
+ const SelectIcon: ForwardRefRenderFunction<HTMLSpanElement, SelectIconProps> = (props, ref) => {
14
+ const {className, ...other} = {...useComponentProps("selectIcon"), ...props};
15
+
16
+ return <Icon ref={ref} className={classnames(styles["select__icon"], className)} {...other} />;
17
+ };
18
+
19
+ export default memo(forwardRef(SelectIcon));
@@ -0,0 +1,41 @@
1
+ import React, {forwardRef, ForwardRefRenderFunction, memo} from "react";
2
+
3
+ import classnames from "classnames";
4
+
5
+ import {Item, ItemIndicator, ItemText, SelectItemProps as SelectItemRadixProps} from "@radix-ui/react-select";
6
+
7
+ import {useComponentProps} from "../../providers";
8
+
9
+ import styles from "./select.module.scss";
10
+
11
+ export interface SelectItemProps extends SelectItemRadixProps {
12
+ indicator?: React.ReactNode;
13
+ indicatorClassname?: string;
14
+ }
15
+
16
+ const SelectItem: ForwardRefRenderFunction<HTMLDivElement, SelectItemProps> = (props, ref) => {
17
+ const {indicator, textValue, className, indicatorClassname, children, ...other} = {
18
+ ...useComponentProps("selectItem"),
19
+ ...props,
20
+ };
21
+
22
+ return (
23
+ <Item ref={ref} className={classnames(styles["select__item"], className)} textValue={textValue} {...other}>
24
+ {children && children}
25
+
26
+ {!children && (
27
+ <>
28
+ {indicator && (
29
+ <ItemIndicator className={classnames(styles["select__item__indicator"], indicatorClassname)}>
30
+ {indicator}
31
+ </ItemIndicator>
32
+ )}
33
+
34
+ {textValue && <ItemText className={classnames(styles["select__item__text"])}>{textValue}</ItemText>}
35
+ </>
36
+ )}
37
+ </Item>
38
+ );
39
+ };
40
+
41
+ export default memo(forwardRef(SelectItem));
@@ -0,0 +1,71 @@
1
+ import React, {forwardRef, ForwardRefRenderFunction, memo} from "react";
2
+
3
+ import classnames from "classnames";
4
+
5
+ import {
6
+ Icon,
7
+ SelectIconProps,
8
+ SelectTriggerProps as SelectTriggerRadixProps,
9
+ SelectValueProps,
10
+ Trigger,
11
+ Value,
12
+ } from "@radix-ui/react-select";
13
+
14
+ import {useComponentProps} from "../../providers";
15
+
16
+ import styles from "./select.module.scss";
17
+
18
+ export interface SelectTriggerProps extends SelectTriggerRadixProps {
19
+ center?: boolean;
20
+ fullWidth?: boolean;
21
+ ellipsis?: boolean;
22
+ icon?: React.ReactNode;
23
+ placeholder?: React.ReactNode;
24
+ valueProps?: SelectValueProps;
25
+ iconProps?: SelectIconProps;
26
+ }
27
+
28
+ const SelectTrigger: ForwardRefRenderFunction<HTMLButtonElement, SelectTriggerProps> = (props, ref) => {
29
+ const {
30
+ center,
31
+ ellipsis = true,
32
+ icon,
33
+ placeholder,
34
+ valueProps,
35
+ iconProps,
36
+ className,
37
+ children,
38
+ ...other
39
+ } = {...useComponentProps("selectTrigger"), ...props};
40
+
41
+ return (
42
+ <Trigger
43
+ ref={ref}
44
+ className={classnames(
45
+ styles["select__trigger"],
46
+ {
47
+ [styles["select__trigger--center"]]: center,
48
+ [styles["select__trigger--ellipsis"]]: ellipsis,
49
+ },
50
+ className
51
+ )}
52
+ {...other}
53
+ >
54
+ {children && children}
55
+
56
+ {!children && (
57
+ <>
58
+ <Value placeholder={placeholder} {...valueProps} className={classnames(styles["select__value"])} />
59
+
60
+ {icon && (
61
+ <Icon className={classnames(styles["select__icon"], iconProps?.className)} {...iconProps}>
62
+ {icon}
63
+ </Icon>
64
+ )}
65
+ </>
66
+ )}
67
+ </Trigger>
68
+ );
69
+ };
70
+
71
+ export default memo(forwardRef(SelectTrigger));
@@ -0,0 +1,19 @@
1
+ import React, {forwardRef, ForwardRefRenderFunction, memo} from "react";
2
+
3
+ import classnames from "classnames";
4
+
5
+ import {SelectValueProps, Value} from "@radix-ui/react-select";
6
+
7
+ import {useComponentProps} from "../../providers";
8
+
9
+ import styles from "./select.module.scss";
10
+
11
+ export {SelectValueProps};
12
+
13
+ const SelectValue: ForwardRefRenderFunction<HTMLSpanElement, SelectValueProps> = (props, ref) => {
14
+ const {className, ...other} = {...useComponentProps("selectValue"), ...props};
15
+
16
+ return <Value ref={ref} className={classnames(styles["select__value"], className)} {...other} />;
17
+ };
18
+
19
+ export default memo(forwardRef(SelectValue));
@@ -0,0 +1,6 @@
1
+ export {default as Select, type SelectProps} from "./Select";
2
+ export {default as SelectItem, type SelectItemProps} from "./SelectItem";
3
+ export {default as SelectIcon, type SelectIconProps} from "./SelectIcon";
4
+ export {default as SelectValue, type SelectValueProps} from "./SelectValue";
5
+ export {default as SelectTrigger, type SelectTriggerProps} from "./SelectTrigger";
6
+ export {default as SelectContent, type SelectContentProps} from "./SelectContent";
@@ -0,0 +1,150 @@
1
+ @use "../../styles/mixins" as theme;
2
+
3
+ $root: select;
4
+
5
+ .#{$root} {
6
+ &__trigger {
7
+ all: unset;
8
+ display: flex;
9
+ align-items: center;
10
+ justify-content: space-between;
11
+ cursor: pointer;
12
+ box-sizing: border-box;
13
+ color: var(--select-trigger-color);
14
+ background-color: var(--select-trigger-bg-color, var(--bg-secondary-color));
15
+ box-shadow: var(--select-trigger-shadow-offset) var(--select-trigger-shadow-color);
16
+
17
+ border-width: var(--select-trigger-border-width, 1px);
18
+ border-style: var(--select-trigger-border-style, solid);
19
+ border-color: var(--select-trigger-border-color, var(--border-color));
20
+ border-radius: var(--select-trigger-border-radius, 10px);
21
+
22
+ font-size: var(--select-trigger-font-size, var(--select-font-size, 14px));
23
+ font-weight: var(--select-trigger-font-weight, 500);
24
+ padding: var(--select-trigger-padding, 8px 12px);
25
+ height: var(--select-trigger-height);
26
+ gap: var(--select-trigger-gap, 5px);
27
+
28
+ &--center {
29
+ justify-content: center;
30
+ }
31
+
32
+ &--ellipsis > span {
33
+ overflow: hidden;
34
+ white-space: nowrap;
35
+ text-overflow: ellipsis;
36
+ }
37
+
38
+ &:hover {
39
+ box-shadow: var(--select-trigger-shadow-offset-hover) var(--select-trigger-shadow-color);
40
+ border-width: var(--select-trigger-border-width-hover, var(--select-trigger-border-width, 1px));
41
+ border-color: var(--select-trigger-border-color-hover, var(--select-trigger-border-color, var(--border-color)));
42
+ }
43
+
44
+ &[data-disabled] {
45
+ color: var(--text-disabled-color);
46
+ }
47
+
48
+ &[data-placeholder] {
49
+ color: var(--text-disabled-color);
50
+ }
51
+
52
+ @include theme.rtl {
53
+ flex-direction: row-reverse;
54
+ }
55
+ }
56
+
57
+ &__icon {
58
+ flex-shrink: 0;
59
+ display: flex;
60
+ align-items: center;
61
+ justify-content: center;
62
+ }
63
+
64
+ &__content {
65
+ overflow: hidden;
66
+ background-color: var(--select-content-bg-color, var(--bg-primary-color));
67
+ border-radius: var(--select-content-border-radius, 8px);
68
+ box-shadow: var(--select-content-shadow-offset, 0 0 5px 0) var(--select-content-shadow-color, rgba(0, 0, 0, 0.25));
69
+ height: var(--select-content-height);
70
+ max-height: var(--select-content-max-height, var(--radix-select-content-available-height));
71
+
72
+ &--full-width {
73
+ width: var(--select-content-full-width, var(--radix-select-trigger-width));
74
+ }
75
+ }
76
+
77
+ &__viewport {
78
+ padding: var(--select-viewport-padding, 5px 0);
79
+ }
80
+
81
+ &__item {
82
+ display: flex;
83
+ align-items: center;
84
+ position: relative;
85
+ overflow: hidden;
86
+ white-space: nowrap;
87
+ font-size: var(--select-item-font-size, var(--select-font-size, 14px));
88
+ font-weight: var(--select-item-font-weight, 400);
89
+ color: var(--select-item-color, var(--text-primary-color));
90
+ background-color: var(--select-content-bg-color, --bg-primary-color);
91
+ border-radius: var(--select-item-border-radius);
92
+ height: var(--select-item-height);
93
+ padding: var(--select-item-padding, 10px);
94
+ user-select: none;
95
+
96
+ &__text {
97
+ overflow: hidden;
98
+ white-space: nowrap;
99
+ text-overflow: ellipsis;
100
+
101
+ @include theme.rtl {
102
+ text-align: end;
103
+ }
104
+ }
105
+
106
+ &__indicator {
107
+ display: flex;
108
+ align-items: center;
109
+ justify-content: center;
110
+ }
111
+
112
+ &[data-state="checked"] {
113
+ pointer-events: none;
114
+ font-weight: var(--select-item-checked-font-weight, 600);
115
+ color: var(--select-item-checked-color);
116
+ background-color: var(--select-item-checked-bg-color, var(--bg-secondary-color));
117
+ }
118
+
119
+ &[data-disabled] {
120
+ pointer-events: none;
121
+ opacity: var(--select-item-disabled-opacity, 0.7);
122
+ color: var(--select-item-disabled-color, var(--text-disabled-color));
123
+ background-color: var(--select-item-disabled-bg-color);
124
+ }
125
+
126
+ &[data-highlighted] {
127
+ outline: none;
128
+ color: var(--select-item-highlighted-color, var(--text-primary-color));
129
+ background-color: var(--select-item-highlighted-bg-color, var(--bg-secondary-color));
130
+ }
131
+
132
+ @include theme.rtl {
133
+ flex-direction: row-reverse;
134
+ }
135
+ }
136
+
137
+ &__scroll-button {
138
+ display: flex;
139
+ align-items: center;
140
+ justify-content: center;
141
+ height: var(--select-scroll-btn-height, 25px);
142
+ color: var(--select-scroll-btn-color, var(--text-primary-color));
143
+ background-color: var(--select-scroll-btn-bg-color, var(--select-content-bg-color, var(--bg-primary-color)));
144
+ cursor: var(--select-scroll-btn-cursor, default);
145
+
146
+ &:hover {
147
+ background-color: var(--select-scroll-btn-hover-bg-color, var(--bg-secondary-color));
148
+ }
149
+ }
150
+ }
@@ -59,8 +59,8 @@ const TextArea = forwardRef<TextAreaActions, TextAreaProps>((props, ref) => {
59
59
 
60
60
  const handleChange = useCallback<ChangeEventHandler<HTMLTextAreaElement>>(
61
61
  event => {
62
- onChange?.(event);
63
62
  setValue(event.currentTarget.value);
63
+ onChange?.(event);
64
64
  },
65
65
  [onChange]
66
66
  );
@@ -91,8 +91,8 @@ const TextField = forwardRef<TextFieldActions, TextFieldProps>((props, ref) => {
91
91
 
92
92
  const handleChange = useCallback<ChangeEventHandler<HTMLInputElement>>(
93
93
  event => {
94
- onChange?.(event);
95
94
  setValue(event.currentTarget.value);
95
+ onChange?.(event);
96
96
  },
97
97
  [onChange]
98
98
  );
@@ -15,6 +15,7 @@ export * from "./ListItem";
15
15
  export * from "./Modal";
16
16
  export * from "./Odometer";
17
17
  export * from "./ScrollArea";
18
+ export * from "./Select";
18
19
  export * from "./SvgSprite";
19
20
  export * from "./Switch";
20
21
  export * from "./Tabs";
@@ -14,6 +14,12 @@ import type {
14
14
  ModalProps,
15
15
  OdometerProps,
16
16
  ScrollAreaProps,
17
+ SelectProps,
18
+ SelectItemProps,
19
+ SelectIconProps,
20
+ SelectValueProps,
21
+ SelectContentProps,
22
+ SelectTriggerProps,
17
23
  SwitchProps,
18
24
  TabsProps,
19
25
  TabsContentProps,
@@ -47,6 +53,12 @@ export interface ComponentsProps {
47
53
  modal?: ModalProps;
48
54
  odometer?: Pick<OdometerProps, "auto" | "format" | "duration">;
49
55
  scrollArea?: ScrollAreaProps;
56
+ select?: SelectProps;
57
+ selectItem?: SelectItemProps;
58
+ selectIcon?: SelectIconProps;
59
+ selectValue?: SelectValueProps;
60
+ selectContent?: SelectContentProps;
61
+ selectTrigger?: SelectTriggerProps;
50
62
  switch?: SwitchProps;
51
63
  tabs?: TabsProps;
52
64
  tabsContent?: TabsContentProps;