@bigstack-oss/cube-ui 0.0.2

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.
@@ -0,0 +1,181 @@
1
+ import * as react from 'react';
2
+ import { ForwardRefExoticComponent, SVGProps, RefAttributes, ReactElement, JSX, ButtonHTMLAttributes, InputHTMLAttributes, PropsWithChildren } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ export { BackgroundColorClass, BorderColorClass, CubeThemeName, CubeThemeProvider, CubeThemeProviderProps, FillColorClass, StrokeColorClass, TextColorClass, Typography, TypographyClassName, cubePreset, cubeTheme, getTypography } from './theme.cjs';
5
+ import 'tailwindcss/types/config';
6
+
7
+ declare const cubeIconSizes: readonly ["xs", "sm", "md-sm", "md", "lg", "xl"];
8
+ type CubeIconSize = (typeof cubeIconSizes)[number];
9
+ type SvgComponent = ForwardRefExoticComponent<SVGProps<SVGSVGElement> & RefAttributes<SVGSVGElement>>;
10
+ type SvgElement = ReactElement<SVGProps<SVGSVGElement>>;
11
+ type CubeIconFrameProps = {
12
+ className?: string;
13
+ /**
14
+ * @default "md"
15
+ */
16
+ size?: CubeIconSize;
17
+ onClick?: () => void;
18
+ children: SvgElement;
19
+ };
20
+
21
+ declare const cubeButtonTypes: readonly ["primary", "secondary", "ghost", "warning", "light"];
22
+ declare const cubeButtonSizes: readonly ["sm", "md", "lg"];
23
+ declare const cubeButtonUsages: readonly ["text-only", "icon-only", "icon-left", "icon-right"];
24
+ type CubeButtonType = (typeof cubeButtonTypes)[number];
25
+ type CubeButtonSize = (typeof cubeButtonSizes)[number];
26
+ type CubeButtonUsage = (typeof cubeButtonUsages)[number];
27
+ type CubeButtonProps = Omit<JSX.IntrinsicElements['button'], 'type' | 'children'> & {
28
+ /**
29
+ * @default "button"
30
+ */
31
+ htmlType?: ButtonHTMLAttributes<HTMLButtonElement>['type'];
32
+ /**
33
+ * @default "primary"
34
+ */
35
+ type?: CubeButtonType;
36
+ /**
37
+ * @default "md"
38
+ */
39
+ size?: CubeButtonSize;
40
+ /**
41
+ * @default false
42
+ */
43
+ disabled?: boolean;
44
+ /**
45
+ * @default false
46
+ */
47
+ loading?: boolean;
48
+ } & ({
49
+ usage?: never;
50
+ children: string;
51
+ } | {
52
+ usage: Extract<CubeButtonUsage, 'text-only'>;
53
+ children: string;
54
+ } | {
55
+ usage: Extract<CubeButtonUsage, 'icon-only'>;
56
+ Icon: SvgComponent;
57
+ } | {
58
+ usage: Extract<CubeButtonUsage, 'icon-left' | 'icon-right'>;
59
+ children: string;
60
+ Icon: SvgComponent;
61
+ });
62
+
63
+ declare const CubeButton: (props: CubeButtonProps) => react.JSX.Element;
64
+
65
+ type CubeButtonSkeletonProps = {
66
+ /**
67
+ * @default 'md
68
+ */
69
+ size?: CubeButtonSize;
70
+ /**
71
+ * @default 'text-only'
72
+ */
73
+ usage?: CubeButtonUsage;
74
+ };
75
+ declare const CubeButtonSkeleton: (props: CubeButtonSkeletonProps) => react.JSX.Element;
76
+
77
+ declare const CubeIconFrame: (props: CubeIconFrameProps) => react.JSX.Element;
78
+
79
+ type CubeInputProps = InputHTMLAttributes<HTMLInputElement> & {
80
+ /**
81
+ * @default false
82
+ */
83
+ isLoading?: boolean;
84
+ label?: string;
85
+ tooltip?: React.ReactNode;
86
+ helpMessage?: string;
87
+ errorMessage?: string | boolean;
88
+ trailingIcon?: SvgElement;
89
+ };
90
+ declare const CubeInput: react.ForwardRefExoticComponent<InputHTMLAttributes<HTMLInputElement> & {
91
+ /**
92
+ * @default false
93
+ */
94
+ isLoading?: boolean;
95
+ label?: string;
96
+ tooltip?: React.ReactNode;
97
+ helpMessage?: string;
98
+ errorMessage?: string | boolean;
99
+ trailingIcon?: SvgElement;
100
+ } & react.RefAttributes<HTMLInputElement>>;
101
+
102
+ type PropsWithClassName = {
103
+ className?: string | undefined;
104
+ };
105
+
106
+ declare const cubeLoadingSpinnerVariants: readonly ["dot45", "dot120", "cube"];
107
+ type CubeLoadingSpinnerVariant = (typeof cubeLoadingSpinnerVariants)[number];
108
+ type CubeLoadingSpinnerProps = PropsWithClassName & {
109
+ variant: CubeLoadingSpinnerVariant;
110
+ };
111
+
112
+ declare const CubeLoadingSpinner: (props: CubeLoadingSpinnerProps) => react.JSX.Element;
113
+
114
+ type CubePasswordInputProps = Omit<CubeInputProps, 'trailingIcon' | 'type'> & {
115
+ /**
116
+ * @default false
117
+ */
118
+ initialShowPassword?: boolean;
119
+ };
120
+ declare const CubePasswordInput: (props: CubePasswordInputProps) => react.JSX.Element;
121
+
122
+ type CubeSkeletonProps = PropsWithClassName & {
123
+ style?: React.CSSProperties;
124
+ };
125
+ declare const CubeSkeleton: (props: CubeSkeletonProps) => react.JSX.Element;
126
+
127
+ var enUS = {
128
+ "component.common.loading": "Loading",
129
+ "component.common.noData": "No Data"
130
+ };
131
+
132
+ /**
133
+ * The exact set of valid @bigstack-oss/cube-ui translation keys, derived from the
134
+ * shipped English dictionary. Used to type-check consumer-supplied
135
+ * translations - passing an unknown/misspelled key is a compile error.
136
+ */
137
+ type CubeUiTranslationResource = typeof enUS;
138
+ /**
139
+ * Autocompletes the locales @bigstack-oss/cube-ui ships out of the box, while still
140
+ * allowing a consumer to pass an arbitrary additional locale code.
141
+ */
142
+ type CubeUiLocale = 'en-US' | 'zh-TW' | (string & {});
143
+
144
+ /**
145
+ * Registers additional or overriding translations for @bigstack-oss/cube-ui's own
146
+ * strings. Use this to add a locale @bigstack-oss/cube-ui doesn't ship by default, or to
147
+ * override specific default strings for a locale it does ship.
148
+ *
149
+ * `resources` is checked against @bigstack-oss/cube-ui's real key set - an unknown or
150
+ * misspelled key is a TypeScript error. Omitted keys for a new locale fall
151
+ * back to the English (`en-US`) text.
152
+ *
153
+ * **Mutation warning:** i18next stores the resource objects passed to `init`
154
+ * by reference and deep-merges overrides into them in place. Any imported
155
+ * JSON module used as a default will reflect overrides after this is called.
156
+ * Take a `structuredClone` snapshot of your defaults before calling this if
157
+ * you need to restore them later.
158
+ */
159
+ declare function addCubeUiTranslations(locale: CubeUiLocale, resources: Partial<CubeUiTranslationResource>): void;
160
+
161
+ type CubeUiLocaleProviderProps = PropsWithChildren<{
162
+ /** The consumer app's active locale, kept in sync with @bigstack-oss/cube-ui's own i18n instance. */
163
+ locale: CubeUiLocale;
164
+ }>;
165
+ /**
166
+ * Wrap the app (or the part of it that renders @bigstack-oss/cube-ui components) in this
167
+ * to sync your app's active locale into @bigstack-oss/cube-ui's own i18next instance.
168
+ *
169
+ * If you only need @bigstack-oss/cube-ui's shipped `en-US`/`zh-TW` translations, this is
170
+ * the entire integration - no `addCubeUiTranslations` call required.
171
+ */
172
+ declare const CubeUiLocaleProvider: (props: CubeUiLocaleProviderProps) => react.ReactNode;
173
+
174
+ /**
175
+ * Components should use this instead of react-i18next's `useTranslation`
176
+ * directly, to stay pinned to @bigstack-oss/cube-ui's own i18next instance rather than
177
+ * being affected by an outer i18n provider the consumer app may have.
178
+ */
179
+ declare const useCubeUiTranslation: typeof useTranslation;
180
+
181
+ export { CubeButton, type CubeButtonProps, type CubeButtonSize, CubeButtonSkeleton, type CubeButtonSkeletonProps, type CubeButtonType, type CubeButtonUsage, CubeIconFrame, type CubeIconFrameProps, type CubeIconSize, CubeInput, type CubeInputProps, CubeLoadingSpinner, type CubeLoadingSpinnerProps, type CubeLoadingSpinnerVariant, CubePasswordInput, type CubePasswordInputProps, CubeSkeleton, type CubeSkeletonProps, type CubeUiLocale, CubeUiLocaleProvider, type CubeUiLocaleProviderProps, type CubeUiTranslationResource, type SvgComponent, type SvgElement, addCubeUiTranslations, useCubeUiTranslation };
@@ -0,0 +1,181 @@
1
+ import * as react from 'react';
2
+ import { ForwardRefExoticComponent, SVGProps, RefAttributes, ReactElement, JSX, ButtonHTMLAttributes, InputHTMLAttributes, PropsWithChildren } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ export { BackgroundColorClass, BorderColorClass, CubeThemeName, CubeThemeProvider, CubeThemeProviderProps, FillColorClass, StrokeColorClass, TextColorClass, Typography, TypographyClassName, cubePreset, cubeTheme, getTypography } from './theme.js';
5
+ import 'tailwindcss/types/config';
6
+
7
+ declare const cubeIconSizes: readonly ["xs", "sm", "md-sm", "md", "lg", "xl"];
8
+ type CubeIconSize = (typeof cubeIconSizes)[number];
9
+ type SvgComponent = ForwardRefExoticComponent<SVGProps<SVGSVGElement> & RefAttributes<SVGSVGElement>>;
10
+ type SvgElement = ReactElement<SVGProps<SVGSVGElement>>;
11
+ type CubeIconFrameProps = {
12
+ className?: string;
13
+ /**
14
+ * @default "md"
15
+ */
16
+ size?: CubeIconSize;
17
+ onClick?: () => void;
18
+ children: SvgElement;
19
+ };
20
+
21
+ declare const cubeButtonTypes: readonly ["primary", "secondary", "ghost", "warning", "light"];
22
+ declare const cubeButtonSizes: readonly ["sm", "md", "lg"];
23
+ declare const cubeButtonUsages: readonly ["text-only", "icon-only", "icon-left", "icon-right"];
24
+ type CubeButtonType = (typeof cubeButtonTypes)[number];
25
+ type CubeButtonSize = (typeof cubeButtonSizes)[number];
26
+ type CubeButtonUsage = (typeof cubeButtonUsages)[number];
27
+ type CubeButtonProps = Omit<JSX.IntrinsicElements['button'], 'type' | 'children'> & {
28
+ /**
29
+ * @default "button"
30
+ */
31
+ htmlType?: ButtonHTMLAttributes<HTMLButtonElement>['type'];
32
+ /**
33
+ * @default "primary"
34
+ */
35
+ type?: CubeButtonType;
36
+ /**
37
+ * @default "md"
38
+ */
39
+ size?: CubeButtonSize;
40
+ /**
41
+ * @default false
42
+ */
43
+ disabled?: boolean;
44
+ /**
45
+ * @default false
46
+ */
47
+ loading?: boolean;
48
+ } & ({
49
+ usage?: never;
50
+ children: string;
51
+ } | {
52
+ usage: Extract<CubeButtonUsage, 'text-only'>;
53
+ children: string;
54
+ } | {
55
+ usage: Extract<CubeButtonUsage, 'icon-only'>;
56
+ Icon: SvgComponent;
57
+ } | {
58
+ usage: Extract<CubeButtonUsage, 'icon-left' | 'icon-right'>;
59
+ children: string;
60
+ Icon: SvgComponent;
61
+ });
62
+
63
+ declare const CubeButton: (props: CubeButtonProps) => react.JSX.Element;
64
+
65
+ type CubeButtonSkeletonProps = {
66
+ /**
67
+ * @default 'md
68
+ */
69
+ size?: CubeButtonSize;
70
+ /**
71
+ * @default 'text-only'
72
+ */
73
+ usage?: CubeButtonUsage;
74
+ };
75
+ declare const CubeButtonSkeleton: (props: CubeButtonSkeletonProps) => react.JSX.Element;
76
+
77
+ declare const CubeIconFrame: (props: CubeIconFrameProps) => react.JSX.Element;
78
+
79
+ type CubeInputProps = InputHTMLAttributes<HTMLInputElement> & {
80
+ /**
81
+ * @default false
82
+ */
83
+ isLoading?: boolean;
84
+ label?: string;
85
+ tooltip?: React.ReactNode;
86
+ helpMessage?: string;
87
+ errorMessage?: string | boolean;
88
+ trailingIcon?: SvgElement;
89
+ };
90
+ declare const CubeInput: react.ForwardRefExoticComponent<InputHTMLAttributes<HTMLInputElement> & {
91
+ /**
92
+ * @default false
93
+ */
94
+ isLoading?: boolean;
95
+ label?: string;
96
+ tooltip?: React.ReactNode;
97
+ helpMessage?: string;
98
+ errorMessage?: string | boolean;
99
+ trailingIcon?: SvgElement;
100
+ } & react.RefAttributes<HTMLInputElement>>;
101
+
102
+ type PropsWithClassName = {
103
+ className?: string | undefined;
104
+ };
105
+
106
+ declare const cubeLoadingSpinnerVariants: readonly ["dot45", "dot120", "cube"];
107
+ type CubeLoadingSpinnerVariant = (typeof cubeLoadingSpinnerVariants)[number];
108
+ type CubeLoadingSpinnerProps = PropsWithClassName & {
109
+ variant: CubeLoadingSpinnerVariant;
110
+ };
111
+
112
+ declare const CubeLoadingSpinner: (props: CubeLoadingSpinnerProps) => react.JSX.Element;
113
+
114
+ type CubePasswordInputProps = Omit<CubeInputProps, 'trailingIcon' | 'type'> & {
115
+ /**
116
+ * @default false
117
+ */
118
+ initialShowPassword?: boolean;
119
+ };
120
+ declare const CubePasswordInput: (props: CubePasswordInputProps) => react.JSX.Element;
121
+
122
+ type CubeSkeletonProps = PropsWithClassName & {
123
+ style?: React.CSSProperties;
124
+ };
125
+ declare const CubeSkeleton: (props: CubeSkeletonProps) => react.JSX.Element;
126
+
127
+ var enUS = {
128
+ "component.common.loading": "Loading",
129
+ "component.common.noData": "No Data"
130
+ };
131
+
132
+ /**
133
+ * The exact set of valid @bigstack-oss/cube-ui translation keys, derived from the
134
+ * shipped English dictionary. Used to type-check consumer-supplied
135
+ * translations - passing an unknown/misspelled key is a compile error.
136
+ */
137
+ type CubeUiTranslationResource = typeof enUS;
138
+ /**
139
+ * Autocompletes the locales @bigstack-oss/cube-ui ships out of the box, while still
140
+ * allowing a consumer to pass an arbitrary additional locale code.
141
+ */
142
+ type CubeUiLocale = 'en-US' | 'zh-TW' | (string & {});
143
+
144
+ /**
145
+ * Registers additional or overriding translations for @bigstack-oss/cube-ui's own
146
+ * strings. Use this to add a locale @bigstack-oss/cube-ui doesn't ship by default, or to
147
+ * override specific default strings for a locale it does ship.
148
+ *
149
+ * `resources` is checked against @bigstack-oss/cube-ui's real key set - an unknown or
150
+ * misspelled key is a TypeScript error. Omitted keys for a new locale fall
151
+ * back to the English (`en-US`) text.
152
+ *
153
+ * **Mutation warning:** i18next stores the resource objects passed to `init`
154
+ * by reference and deep-merges overrides into them in place. Any imported
155
+ * JSON module used as a default will reflect overrides after this is called.
156
+ * Take a `structuredClone` snapshot of your defaults before calling this if
157
+ * you need to restore them later.
158
+ */
159
+ declare function addCubeUiTranslations(locale: CubeUiLocale, resources: Partial<CubeUiTranslationResource>): void;
160
+
161
+ type CubeUiLocaleProviderProps = PropsWithChildren<{
162
+ /** The consumer app's active locale, kept in sync with @bigstack-oss/cube-ui's own i18n instance. */
163
+ locale: CubeUiLocale;
164
+ }>;
165
+ /**
166
+ * Wrap the app (or the part of it that renders @bigstack-oss/cube-ui components) in this
167
+ * to sync your app's active locale into @bigstack-oss/cube-ui's own i18next instance.
168
+ *
169
+ * If you only need @bigstack-oss/cube-ui's shipped `en-US`/`zh-TW` translations, this is
170
+ * the entire integration - no `addCubeUiTranslations` call required.
171
+ */
172
+ declare const CubeUiLocaleProvider: (props: CubeUiLocaleProviderProps) => react.ReactNode;
173
+
174
+ /**
175
+ * Components should use this instead of react-i18next's `useTranslation`
176
+ * directly, to stay pinned to @bigstack-oss/cube-ui's own i18next instance rather than
177
+ * being affected by an outer i18n provider the consumer app may have.
178
+ */
179
+ declare const useCubeUiTranslation: typeof useTranslation;
180
+
181
+ export { CubeButton, type CubeButtonProps, type CubeButtonSize, CubeButtonSkeleton, type CubeButtonSkeletonProps, type CubeButtonType, type CubeButtonUsage, CubeIconFrame, type CubeIconFrameProps, type CubeIconSize, CubeInput, type CubeInputProps, CubeLoadingSpinner, type CubeLoadingSpinnerProps, type CubeLoadingSpinnerVariant, CubePasswordInput, type CubePasswordInputProps, CubeSkeleton, type CubeSkeletonProps, type CubeUiLocale, CubeUiLocaleProvider, type CubeUiLocaleProviderProps, type CubeUiTranslationResource, type SvgComponent, type SvgElement, addCubeUiTranslations, useCubeUiTranslation };