@particle-network/ui-react 0.0.1

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.
Files changed (109) hide show
  1. package/README.md +23 -0
  2. package/dist/components/ProgressWrapper/index.d.ts +34 -0
  3. package/dist/components/ProgressWrapper/index.js +102 -0
  4. package/dist/components/UXButton/button-group-context.d.ts +2 -0
  5. package/dist/components/UXButton/button-group-context.js +6 -0
  6. package/dist/components/UXButton/button-group.d.ts +4 -0
  7. package/dist/components/UXButton/button-group.js +22 -0
  8. package/dist/components/UXButton/button-theme.d.ts +236 -0
  9. package/dist/components/UXButton/button-theme.js +626 -0
  10. package/dist/components/UXButton/button.d.ts +4 -0
  11. package/dist/components/UXButton/button.js +31 -0
  12. package/dist/components/UXButton/index.d.ts +8 -0
  13. package/dist/components/UXButton/index.js +6 -0
  14. package/dist/components/UXButton/use-button-group.d.ts +37 -0
  15. package/dist/components/UXButton/use-button-group.js +55 -0
  16. package/dist/components/UXButton/use-button.d.ts +65 -0
  17. package/dist/components/UXButton/use-button.js +136 -0
  18. package/dist/components/UXCheckbox/checkbox.extend.d.ts +7 -0
  19. package/dist/components/UXCheckbox/checkbox.extend.js +151 -0
  20. package/dist/components/UXCheckbox/checkbox.icon.d.ts +6 -0
  21. package/dist/components/UXCheckbox/checkbox.icon.js +46 -0
  22. package/dist/components/UXCheckbox/index.d.ts +10 -0
  23. package/dist/components/UXCheckbox/index.js +17 -0
  24. package/dist/components/UXChip/chip.extend.d.ts +299 -0
  25. package/dist/components/UXChip/chip.extend.js +236 -0
  26. package/dist/components/UXChip/index.d.ts +302 -0
  27. package/dist/components/UXChip/index.js +10 -0
  28. package/dist/components/UXDivider/divider.extend.d.ts +286 -0
  29. package/dist/components/UXDivider/divider.extend.js +15 -0
  30. package/dist/components/UXDivider/index.d.ts +4 -0
  31. package/dist/components/UXDivider/index.js +10 -0
  32. package/dist/components/UXDropdown/dropdown-item.d.ts +3 -0
  33. package/dist/components/UXDropdown/dropdown-item.js +306 -0
  34. package/dist/components/UXDropdown/dropdown-menu.d.ts +3 -0
  35. package/dist/components/UXDropdown/dropdown-menu.js +25 -0
  36. package/dist/components/UXDropdown/dropdown-section.d.ts +1 -0
  37. package/dist/components/UXDropdown/dropdown-section.js +2 -0
  38. package/dist/components/UXDropdown/dropdown.d.ts +4 -0
  39. package/dist/components/UXDropdown/dropdown.js +21 -0
  40. package/dist/components/UXDropdown/index.d.ts +6 -0
  41. package/dist/components/UXDropdown/index.js +6 -0
  42. package/dist/components/UXHint/index.d.ts +8 -0
  43. package/dist/components/UXHint/index.js +22 -0
  44. package/dist/components/UXInput/index.d.ts +346 -0
  45. package/dist/components/UXInput/index.js +10 -0
  46. package/dist/components/UXInput/input.extend.d.ts +343 -0
  47. package/dist/components/UXInput/input.extend.js +6 -0
  48. package/dist/components/UXModal/index.d.ts +10 -0
  49. package/dist/components/UXModal/index.js +89 -0
  50. package/dist/components/UXNumberInput/index.d.ts +5 -0
  51. package/dist/components/UXNumberInput/index.js +10 -0
  52. package/dist/components/UXNumberInput/number-input.extend.d.ts +8 -0
  53. package/dist/components/UXNumberInput/number-input.extend.js +6 -0
  54. package/dist/components/UXPopover/index.d.ts +6 -0
  55. package/dist/components/UXPopover/index.js +10 -0
  56. package/dist/components/UXPopover/popover.extend.d.ts +7 -0
  57. package/dist/components/UXPopover/popover.extend.js +26 -0
  58. package/dist/components/UXRadio/index.d.ts +10 -0
  59. package/dist/components/UXRadio/index.js +12 -0
  60. package/dist/components/UXRadio/radio.extend.d.ts +7 -0
  61. package/dist/components/UXRadio/radio.extend.js +97 -0
  62. package/dist/components/UXSelect/index.d.ts +6 -0
  63. package/dist/components/UXSelect/index.js +51 -0
  64. package/dist/components/UXSwitch/index.d.ts +331 -0
  65. package/dist/components/UXSwitch/index.js +10 -0
  66. package/dist/components/UXSwitch/switch.extend.d.ts +328 -0
  67. package/dist/components/UXSwitch/switch.extend.js +117 -0
  68. package/dist/components/UXTabs/index.d.ts +9 -0
  69. package/dist/components/UXTabs/index.js +11 -0
  70. package/dist/components/UXTabs/tabs.classes.d.ts +210 -0
  71. package/dist/components/UXTabs/tabs.classes.js +530 -0
  72. package/dist/components/UXTabs/tabs.extend.d.ts +8 -0
  73. package/dist/components/UXTabs/tabs.extend.js +6 -0
  74. package/dist/components/UXTooltip/index.d.ts +5 -0
  75. package/dist/components/UXTooltip/index.js +23 -0
  76. package/dist/components/UXTooltip/tooltip.extend.d.ts +314 -0
  77. package/dist/components/UXTooltip/tooltip.extend.js +27 -0
  78. package/dist/components/index.d.ts +44 -0
  79. package/dist/components/index.js +31 -0
  80. package/dist/components/layout/Center.d.ts +4 -0
  81. package/dist/components/layout/Center.js +11 -0
  82. package/dist/components/layout/Circle.d.ts +6 -0
  83. package/dist/components/layout/Circle.js +12 -0
  84. package/dist/components/layout/Flex.d.ts +29 -0
  85. package/dist/components/layout/Flex.js +24 -0
  86. package/dist/components/layout/HStack.d.ts +4 -0
  87. package/dist/components/layout/HStack.js +12 -0
  88. package/dist/components/layout/Square.d.ts +8 -0
  89. package/dist/components/layout/Square.js +13 -0
  90. package/dist/components/layout/VStack.d.ts +4 -0
  91. package/dist/components/layout/VStack.js +12 -0
  92. package/dist/components/typography/Text.d.ts +3 -0
  93. package/dist/components/typography/Text.js +12 -0
  94. package/dist/components/typography/Text.type.d.ts +103 -0
  95. package/dist/components/typography/Text.type.js +47 -0
  96. package/dist/icons/index.d.ts +6 -0
  97. package/dist/icons/index.js +58 -0
  98. package/dist/index.d.ts +2 -0
  99. package/dist/index.js +2 -0
  100. package/dist/utils/classes.d.ts +35 -0
  101. package/dist/utils/classes.js +87 -0
  102. package/dist/utils/index.d.ts +3 -0
  103. package/dist/utils/index.js +4 -0
  104. package/dist/utils/input-classes.d.ts +427 -0
  105. package/dist/utils/input-classes.js +568 -0
  106. package/dist/utils/variants.d.ts +91 -0
  107. package/dist/utils/variants.js +100 -0
  108. package/package.json +42 -0
  109. package/tailwind-preset.js +298 -0
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # Rslib project
2
+
3
+ ## Setup
4
+
5
+ Install the dependencies:
6
+
7
+ ```bash
8
+ pnpm install
9
+ ```
10
+
11
+ ## Get started
12
+
13
+ Build the library:
14
+
15
+ ```bash
16
+ pnpm build
17
+ ```
18
+
19
+ Build the library in watch mode:
20
+
21
+ ```bash
22
+ pnpm dev
23
+ ```
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { type UXForegroundColor, type UXRadius } from '@particle-network/ui-shared';
3
+ export interface ProgressWrapperProps extends React.HTMLAttributes<HTMLDivElement> {
4
+ /**
5
+ * 进度 (%)
6
+ */
7
+ value?: number;
8
+ /**
9
+ * 宽度
10
+ */
11
+ width?: number;
12
+ /**
13
+ * 高度
14
+ */
15
+ height?: number;
16
+ /**
17
+ * 进度条宽度
18
+ */
19
+ strokeWidth?: number;
20
+ /**
21
+ * 圆角
22
+ */
23
+ radius?: UXRadius | number;
24
+ /**
25
+ * 进度条颜色
26
+ */
27
+ color?: UXForegroundColor | 'transparent';
28
+ /**
29
+ * 进度条 SVG 样式
30
+ */
31
+ svgClassName?: string;
32
+ }
33
+ declare const ProgressWrapper: React.FC<ProgressWrapperProps>;
34
+ export default ProgressWrapper;
@@ -0,0 +1,102 @@
1
+ 'use client';
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useMemo, useRef } from "react";
4
+ import { cn } from "@heroui/theme";
5
+ import { getHexColorFromCSSVariable, radiusMap } from "@particle-network/ui-shared";
6
+ import { useSize } from "ahooks";
7
+ import Center from "../layout/Center.js";
8
+ const ProgressWrapper = ({ className, value = 0, width, height, radius = 'sm', strokeWidth = 1, color = 'primary', children, svgClassName, ...restProps })=>{
9
+ const autoLayout = !width && !height;
10
+ const containerRef = useRef(null);
11
+ const { width: childWidth, height: childHeight } = useSize(containerRef) ?? {
12
+ width: 0,
13
+ height: 0
14
+ };
15
+ const widthValue = useMemo(()=>{
16
+ if (width) return width;
17
+ return childWidth + 2 * strokeWidth;
18
+ }, [
19
+ childWidth,
20
+ strokeWidth,
21
+ width
22
+ ]);
23
+ const heightValue = useMemo(()=>{
24
+ if (height) return height;
25
+ return childHeight + 2 * strokeWidth;
26
+ }, [
27
+ childHeight,
28
+ strokeWidth,
29
+ height
30
+ ]);
31
+ const clampedProgress = Math.max(0, Math.min(100, value));
32
+ const rectWidth = widthValue - strokeWidth;
33
+ const rectHeight = heightValue - strokeWidth;
34
+ const rectXY = strokeWidth / 2;
35
+ const perimeter = 2 * (rectWidth + rectHeight);
36
+ const strokeDashoffset = perimeter * (1 - clampedProgress / 100);
37
+ const colorValue = 'transparent' === color ? 'transparent' : getHexColorFromCSSVariable(color);
38
+ const trackColor = 'transparent' === color ? 'transparent' : `${colorValue}40`;
39
+ const radiusValue = 'number' == typeof radius ? radius : radiusMap[radius];
40
+ const createPathData = (x, y, w, h, r)=>{
41
+ if (0 === r) return `
42
+ M ${x + w} ${y + h}
43
+ L ${x} ${y + h}
44
+ L ${x} ${y}
45
+ L ${x + w} ${y}
46
+ Z
47
+ `;
48
+ return `
49
+ M ${x + w - r} ${y + h}
50
+ L ${x + r} ${y + h}
51
+ Q ${x} ${y + h} ${x} ${y + h - r}
52
+ L ${x} ${y + r}
53
+ Q ${x} ${y} ${x + r} ${y}
54
+ L ${x + w - r} ${y}
55
+ Q ${x + w} ${y} ${x + w} ${y + r}
56
+ L ${x + w} ${y + h - r}
57
+ Q ${x + w} ${y + h} ${x + w - r} ${y + h}
58
+ Z
59
+ `;
60
+ };
61
+ const pathData = createPathData(rectXY, rectXY, rectWidth, rectHeight, radiusValue);
62
+ return /*#__PURE__*/ jsxs(Center, {
63
+ style: {
64
+ width: `${widthValue}px`,
65
+ height: `${heightValue}px`
66
+ },
67
+ className: cn('relative cursor-pointer', className),
68
+ ...restProps,
69
+ children: [
70
+ /*#__PURE__*/ jsxs("svg", {
71
+ className: cn('absolute left-0 top-0', svgClassName),
72
+ width: widthValue,
73
+ height: heightValue,
74
+ children: [
75
+ /*#__PURE__*/ jsx("path", {
76
+ d: pathData,
77
+ fill: "none",
78
+ stroke: trackColor,
79
+ strokeWidth: strokeWidth
80
+ }),
81
+ /*#__PURE__*/ jsx("path", {
82
+ d: pathData,
83
+ fill: "none",
84
+ stroke: colorValue,
85
+ strokeWidth: strokeWidth,
86
+ strokeLinecap: "round",
87
+ strokeLinejoin: "round",
88
+ strokeDasharray: perimeter,
89
+ strokeDashoffset: strokeDashoffset
90
+ })
91
+ ]
92
+ }),
93
+ autoLayout ? /*#__PURE__*/ jsx("div", {
94
+ ref: containerRef,
95
+ children: children
96
+ }) : children
97
+ ]
98
+ });
99
+ };
100
+ ProgressWrapper.displayName = 'UX.ProgressWrapper';
101
+ const components_ProgressWrapper = ProgressWrapper;
102
+ export { components_ProgressWrapper as default };
@@ -0,0 +1,2 @@
1
+ import type { ContextType } from './use-button-group';
2
+ export declare const ButtonGroupProvider: import("react").Provider<ContextType>, useButtonGroupContext: () => ContextType;
@@ -0,0 +1,6 @@
1
+ import { createContext } from "@heroui/react-utils";
2
+ const [ButtonGroupProvider, useButtonGroupContext] = createContext({
3
+ name: 'ButtonGroupContext',
4
+ strict: false
5
+ });
6
+ export { ButtonGroupProvider, useButtonGroupContext };
@@ -0,0 +1,4 @@
1
+ import type { UseButtonGroupProps } from './use-button-group';
2
+ export type ButtonGroupProps = UseButtonGroupProps;
3
+ declare const ButtonGroup: import("@heroui/system-rsc").InternalForwardRefRenderFunction<"div", UseButtonGroupProps, never>;
4
+ export default ButtonGroup;
@@ -0,0 +1,22 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "@heroui/system";
3
+ import { ButtonGroupProvider } from "./button-group-context.js";
4
+ import { useButtonGroup } from "./use-button-group.js";
5
+ const ButtonGroup = forwardRef((props, ref)=>{
6
+ const { Component, domRef, context, children, classNames, getButtonGroupProps } = useButtonGroup({
7
+ ...props,
8
+ ref
9
+ });
10
+ return /*#__PURE__*/ jsx(ButtonGroupProvider, {
11
+ value: context,
12
+ children: /*#__PURE__*/ jsx(Component, {
13
+ ref: domRef,
14
+ className: classNames,
15
+ ...getButtonGroupProps(),
16
+ children: children
17
+ })
18
+ });
19
+ });
20
+ ButtonGroup.displayName = 'HeroUI.ButtonGroup';
21
+ const button_group = ButtonGroup;
22
+ export { button_group as default };
@@ -0,0 +1,236 @@
1
+ import type { VariantProps } from 'tailwind-variants';
2
+ /**
3
+ * Button wrapper **Tailwind Variants** component
4
+ *
5
+ * const classNames = button({...})
6
+ *
7
+ * @example
8
+ * <button
9
+ * className={classNames())}
10
+ * data-pressed={true/false}
11
+ * data-hover={true/false}
12
+ * data-focus={true/false}
13
+ * data-focus-visible={true/false}
14
+ * >
15
+ * Button
16
+ * </button>
17
+ */
18
+ declare const button: import("tailwind-variants").TVReturnType<{
19
+ variant: {
20
+ solid: string;
21
+ bordered: string;
22
+ light: string;
23
+ flat: string;
24
+ faded: string;
25
+ shadow: string;
26
+ ghost: string;
27
+ text: string;
28
+ };
29
+ size: {
30
+ sm: string;
31
+ md: string;
32
+ lg: string;
33
+ auto: string;
34
+ };
35
+ color: {
36
+ default: string;
37
+ primary: string;
38
+ secondary: string;
39
+ success: string;
40
+ warning: string;
41
+ danger: string;
42
+ /**
43
+ * 看涨
44
+ */
45
+ bullish: string;
46
+ /**
47
+ * 看跌
48
+ */
49
+ bearish: string;
50
+ /**
51
+ * 对比色
52
+ */
53
+ contrast: string;
54
+ };
55
+ radius: {
56
+ none: string;
57
+ sm: string;
58
+ md: string;
59
+ lg: string;
60
+ full: string;
61
+ };
62
+ fullWidth: {
63
+ true: string;
64
+ };
65
+ isDisabled: {
66
+ true: string;
67
+ };
68
+ isSelected: {
69
+ true: string;
70
+ };
71
+ isInGroup: {
72
+ true: string;
73
+ };
74
+ isIconOnly: {
75
+ true: string;
76
+ false: string;
77
+ };
78
+ disableAnimation: {
79
+ true: string;
80
+ false: string;
81
+ };
82
+ }, undefined, string[], {
83
+ variant: {
84
+ solid: string;
85
+ bordered: string;
86
+ light: string;
87
+ flat: string;
88
+ faded: string;
89
+ shadow: string;
90
+ ghost: string;
91
+ text: string;
92
+ };
93
+ size: {
94
+ sm: string;
95
+ md: string;
96
+ lg: string;
97
+ auto: string;
98
+ };
99
+ color: {
100
+ default: string;
101
+ primary: string;
102
+ secondary: string;
103
+ success: string;
104
+ warning: string;
105
+ danger: string;
106
+ /**
107
+ * 看涨
108
+ */
109
+ bullish: string;
110
+ /**
111
+ * 看跌
112
+ */
113
+ bearish: string;
114
+ /**
115
+ * 对比色
116
+ */
117
+ contrast: string;
118
+ };
119
+ radius: {
120
+ none: string;
121
+ sm: string;
122
+ md: string;
123
+ lg: string;
124
+ full: string;
125
+ };
126
+ fullWidth: {
127
+ true: string;
128
+ };
129
+ isDisabled: {
130
+ true: string;
131
+ };
132
+ isSelected: {
133
+ true: string;
134
+ };
135
+ isInGroup: {
136
+ true: string;
137
+ };
138
+ isIconOnly: {
139
+ true: string;
140
+ false: string;
141
+ };
142
+ disableAnimation: {
143
+ true: string;
144
+ false: string;
145
+ };
146
+ }, undefined, import("tailwind-variants").TVReturnType<{
147
+ variant: {
148
+ solid: string;
149
+ bordered: string;
150
+ light: string;
151
+ flat: string;
152
+ faded: string;
153
+ shadow: string;
154
+ ghost: string;
155
+ text: string;
156
+ };
157
+ size: {
158
+ sm: string;
159
+ md: string;
160
+ lg: string;
161
+ auto: string;
162
+ };
163
+ color: {
164
+ default: string;
165
+ primary: string;
166
+ secondary: string;
167
+ success: string;
168
+ warning: string;
169
+ danger: string;
170
+ /**
171
+ * 看涨
172
+ */
173
+ bullish: string;
174
+ /**
175
+ * 看跌
176
+ */
177
+ bearish: string;
178
+ /**
179
+ * 对比色
180
+ */
181
+ contrast: string;
182
+ };
183
+ radius: {
184
+ none: string;
185
+ sm: string;
186
+ md: string;
187
+ lg: string;
188
+ full: string;
189
+ };
190
+ fullWidth: {
191
+ true: string;
192
+ };
193
+ isDisabled: {
194
+ true: string;
195
+ };
196
+ isSelected: {
197
+ true: string;
198
+ };
199
+ isInGroup: {
200
+ true: string;
201
+ };
202
+ isIconOnly: {
203
+ true: string;
204
+ false: string;
205
+ };
206
+ disableAnimation: {
207
+ true: string;
208
+ false: string;
209
+ };
210
+ }, undefined, string[], unknown, unknown, undefined>>;
211
+ /**
212
+ * ButtonGroup wrapper **Tailwind Variants** component
213
+ *
214
+ * const classNames = buttonGroup({...})
215
+ *
216
+ * @example
217
+ * <div role="group" className={classNames())}>
218
+ * // button elements
219
+ * </div>
220
+ */
221
+ declare const buttonGroup: import("tailwind-variants").TVReturnType<{
222
+ fullWidth: {
223
+ true: string;
224
+ };
225
+ }, undefined, "inline-flex items-center justify-center h-auto", {
226
+ fullWidth: {
227
+ true: string;
228
+ };
229
+ }, undefined, import("tailwind-variants").TVReturnType<{
230
+ fullWidth: {
231
+ true: string;
232
+ };
233
+ }, undefined, "inline-flex items-center justify-center h-auto", unknown, unknown, undefined>>;
234
+ export type ButtonGroupVariantProps = VariantProps<typeof buttonGroup>;
235
+ export type ButtonVariantProps = VariantProps<typeof button>;
236
+ export { button, buttonGroup };