@yugu-ui/shared 0.0.0-stage → 0.1.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.
Files changed (66) hide show
  1. package/bin.ts +4 -0
  2. package/dist/bin.d.ts +0 -0
  3. package/dist/hooks/index.d.ts +8 -0
  4. package/dist/hooks/use-boolean.d.ts +12 -0
  5. package/dist/hooks/use-context.d.ts +15 -0
  6. package/dist/hooks/use-count-down.d.ts +12 -0
  7. package/dist/hooks/use-loading.d.ts +10 -0
  8. package/dist/hooks/use-request.d.ts +23 -0
  9. package/dist/hooks/use-svg-icon-render.d.ts +19 -0
  10. package/dist/hooks/use-table.d.ts +63 -0
  11. package/dist/hooks.d.ts +2 -0
  12. package/dist/hooks.js +205 -0
  13. package/dist/index.d.ts +2 -0
  14. package/dist/index.js +3110 -0
  15. package/dist/nanoid-CQE6QAZJ.js +2 -0
  16. package/dist/request/constant.d.ts +6 -0
  17. package/dist/request/index.d.ts +22 -0
  18. package/dist/request/options.d.ts +6 -0
  19. package/dist/request/shared.d.ts +17 -0
  20. package/dist/request/type.d.ts +94 -0
  21. package/dist/request.d.ts +2 -0
  22. package/dist/request.js +182 -0
  23. package/dist/scripts/src/commands/changelog.d.ts +2 -0
  24. package/dist/scripts/src/commands/cleanup.d.ts +1 -0
  25. package/dist/scripts/src/commands/git-commit.d.ts +9 -0
  26. package/dist/scripts/src/commands/index.d.ts +6 -0
  27. package/dist/scripts/src/commands/release.d.ts +1 -0
  28. package/dist/scripts/src/commands/router.d.ts +2 -0
  29. package/dist/scripts/src/commands/update-pkg.d.ts +1 -0
  30. package/dist/scripts/src/config/index.d.ts +2 -0
  31. package/dist/scripts/src/index.d.ts +1 -0
  32. package/dist/scripts/src/locales/index.d.ts +25 -0
  33. package/dist/scripts/src/shared/index.d.ts +2 -0
  34. package/dist/scripts/src/types/index.d.ts +30 -0
  35. package/dist/uno-preset/index.d.ts +4 -0
  36. package/dist/uno-preset.d.ts +6 -0
  37. package/dist/uno-preset.js +49 -0
  38. package/dist/utils/color/constant/index.d.ts +2 -0
  39. package/dist/utils/color/constant/name.d.ts +8 -0
  40. package/dist/utils/color/constant/palette.d.ts +2 -0
  41. package/dist/utils/color/index.d.ts +5 -0
  42. package/dist/utils/color/palette/antd.d.ts +18 -0
  43. package/dist/utils/color/palette/index.d.ts +17 -0
  44. package/dist/utils/color/palette/recommend.d.ts +20 -0
  45. package/dist/utils/color/shared/colord.d.ts +38 -0
  46. package/dist/utils/color/shared/index.d.ts +2 -0
  47. package/dist/utils/color/shared/name.d.ts +6 -0
  48. package/dist/utils/color/types/index.d.ts +52 -0
  49. package/dist/utils/index.d.ts +4 -0
  50. package/dist/utils/klona.d.ts +2 -0
  51. package/dist/utils/nanoid.d.ts +1 -0
  52. package/dist/utils/storage.d.ts +28 -0
  53. package/package.json +84 -4
  54. package/scripts/src/commands/changelog.ts +10 -0
  55. package/scripts/src/commands/cleanup.ts +5 -0
  56. package/scripts/src/commands/git-commit.ts +107 -0
  57. package/scripts/src/commands/index.ts +6 -0
  58. package/scripts/src/commands/release.ts +12 -0
  59. package/scripts/src/commands/router.ts +90 -0
  60. package/scripts/src/commands/update-pkg.ts +5 -0
  61. package/scripts/src/config/index.ts +39 -0
  62. package/scripts/src/index.ts +110 -0
  63. package/scripts/src/locales/index.ts +84 -0
  64. package/scripts/src/shared/index.ts +7 -0
  65. package/scripts/src/types/index.ts +31 -0
  66. package/README.md +0 -3
@@ -0,0 +1,2 @@
1
+ import { nanoid } from "nanoid";
2
+ export { nanoid as t };
@@ -0,0 +1,6 @@
1
+ /** request id key */
2
+ export declare const REQUEST_ID_KEY = "X-Request-Id";
3
+ /** the backend error code key */
4
+ export declare const BACKEND_ERROR_CODE = "BACKEND_ERROR";
5
+ /** the request canceled code */
6
+ export declare const REQUEST_CANCELED_CODE = "ERR_CANCELED";
@@ -0,0 +1,22 @@
1
+ import { AxiosError, CreateAxiosDefaults } from 'axios';
2
+ import { BACKEND_ERROR_CODE, REQUEST_CANCELED_CODE, REQUEST_ID_KEY } from './constant';
3
+ import { FlatRequestInstance, RequestInstance, RequestOption } from './type';
4
+ /**
5
+ * create a request instance
6
+ *
7
+ * @param axiosConfig axios config
8
+ * @param options request options
9
+ */
10
+ export declare function createRequest<ResponseData, ApiData, State extends Record<string, unknown>>(axiosConfig?: CreateAxiosDefaults, options?: Partial<RequestOption<ResponseData, ApiData, State>>): RequestInstance<ApiData, State>;
11
+ /**
12
+ * create a flat request instance
13
+ *
14
+ * The response data is a flat object: { data: any, error: AxiosError }
15
+ *
16
+ * @param axiosConfig axios config
17
+ * @param options request options
18
+ */
19
+ export declare function createFlatRequest<ResponseData, ApiData, State extends Record<string, unknown>>(axiosConfig?: CreateAxiosDefaults, options?: Partial<RequestOption<ResponseData, ApiData, State>>): FlatRequestInstance<ResponseData, ApiData, State>;
20
+ export { BACKEND_ERROR_CODE, REQUEST_CANCELED_CODE, REQUEST_ID_KEY };
21
+ export type * from './type';
22
+ export type { CreateAxiosDefaults, AxiosError };
@@ -0,0 +1,6 @@
1
+ import { CreateAxiosDefaults } from 'axios';
2
+ import { IAxiosRetryConfig } from 'axios-retry';
3
+ import { RequestOption } from './type';
4
+ export declare function createDefaultOptions<ResponseData, ApiData = ResponseData, State extends Record<string, unknown> = Record<string, unknown>>(options?: Partial<RequestOption<ResponseData, ApiData, State>>): RequestOption<ResponseData, ApiData, State>;
5
+ export declare function createRetryOptions(config?: Partial<CreateAxiosDefaults>): IAxiosRetryConfig;
6
+ export declare function createAxiosConfig(config?: Partial<CreateAxiosDefaults>): CreateAxiosDefaults<any>;
@@ -0,0 +1,17 @@
1
+ import { AxiosResponse, InternalAxiosRequestConfig } from 'axios';
2
+ export declare function getContentType(config: InternalAxiosRequestConfig): string | number | true | string[] | import('axios').AxiosHeaders;
3
+ /**
4
+ * check if http status is success
5
+ *
6
+ * @param status
7
+ */
8
+ export declare function isHttpSuccess(status: number): boolean;
9
+ /**
10
+ * is response json
11
+ *
12
+ * @param response axios response
13
+ */
14
+ export declare function isResponseJson(response: AxiosResponse): boolean;
15
+ export declare function transformResponse(response: AxiosResponse): Promise<void>;
16
+ export declare function transformBlobToJson(response: AxiosResponse): Promise<void>;
17
+ export declare function transformArrayBufferToJson(response: AxiosResponse): Promise<void>;
@@ -0,0 +1,94 @@
1
+ import { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
2
+ export type ContentType = 'text/html' | 'text/plain' | 'multipart/form-data' | 'application/json' | 'application/x-www-form-urlencoded' | 'application/octet-stream';
3
+ export type ResponseTransform<Input = any, Output = any> = (input: Input) => Output | Promise<Output>;
4
+ export interface RequestOption<ResponseData, ApiData = ResponseData, State extends Record<string, unknown> = Record<string, unknown>> {
5
+ /**
6
+ * The default state
7
+ */
8
+ defaultState?: State;
9
+ /**
10
+ * transform the response data to the api data
11
+ *
12
+ * @param response Axios response
13
+ */
14
+ transform: ResponseTransform<AxiosResponse<ResponseData>, ApiData>;
15
+ /**
16
+ * transform the response data to the api data
17
+ *
18
+ * @deprecated use `transform` instead, will be removed in the next major version v3
19
+ * @param response Axios response
20
+ */
21
+ transformBackendResponse: ResponseTransform<AxiosResponse<ResponseData>, ApiData>;
22
+ /**
23
+ * The hook before request
24
+ *
25
+ * For example: You can add header token in this hook
26
+ *
27
+ * @param config Axios config
28
+ */
29
+ onRequest: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>;
30
+ /**
31
+ * The hook to check backend response is success or not
32
+ *
33
+ * @param response Axios response
34
+ */
35
+ isBackendSuccess: (response: AxiosResponse<ResponseData>) => boolean;
36
+ /**
37
+ * The hook after backend request fail
38
+ *
39
+ * For example: You can handle the expired token in this hook
40
+ *
41
+ * @param response Axios response
42
+ * @param instance Axios instance
43
+ */
44
+ onBackendFail: (response: AxiosResponse<ResponseData>, instance: AxiosInstance) => Promise<AxiosResponse | null> | Promise<void>;
45
+ /**
46
+ * The hook to handle error
47
+ *
48
+ * For example: You can show error message in this hook
49
+ *
50
+ * @param error
51
+ */
52
+ onError: (error: AxiosError<ResponseData>) => void | Promise<void>;
53
+ }
54
+ interface ResponseMap {
55
+ blob: Blob;
56
+ text: string;
57
+ arrayBuffer: ArrayBuffer;
58
+ stream: ReadableStream<Uint8Array>;
59
+ document: Document;
60
+ }
61
+ export type ResponseType = keyof ResponseMap | 'json';
62
+ export type MappedType<R extends ResponseType, JsonType = any> = R extends keyof ResponseMap ? ResponseMap[R] : JsonType;
63
+ export type CustomAxiosRequestConfig<R extends ResponseType = 'json'> = Omit<AxiosRequestConfig, 'responseType'> & {
64
+ responseType?: R;
65
+ };
66
+ export interface RequestInstanceCommon<State extends Record<string, unknown>> {
67
+ /**
68
+ * cancel all request
69
+ *
70
+ * if the request provide abort controller sign from config, it will not collect in the abort controller map
71
+ */
72
+ cancelAllRequest: () => void;
73
+ /** you can set custom state in the request instance */
74
+ state: State;
75
+ }
76
+ /** The request instance */
77
+ export interface RequestInstance<ApiData, State extends Record<string, unknown>> extends RequestInstanceCommon<State> {
78
+ <T extends ApiData = ApiData, R extends ResponseType = 'json'>(config: CustomAxiosRequestConfig<R>): Promise<MappedType<R, T>>;
79
+ }
80
+ export type FlatResponseSuccessData<ResponseData, ApiData> = {
81
+ data: ApiData;
82
+ error: null;
83
+ response: AxiosResponse<ResponseData>;
84
+ };
85
+ export type FlatResponseFailData<ResponseData> = {
86
+ data: null;
87
+ error: AxiosError<ResponseData>;
88
+ response: AxiosResponse<ResponseData>;
89
+ };
90
+ export type FlatResponseData<ResponseData, ApiData> = FlatResponseSuccessData<ResponseData, ApiData> | FlatResponseFailData<ResponseData>;
91
+ export interface FlatRequestInstance<ResponseData, ApiData, State extends Record<string, unknown>> extends RequestInstanceCommon<State> {
92
+ <T extends ApiData = ApiData, R extends ResponseType = 'json'>(config: CustomAxiosRequestConfig<R>): Promise<FlatResponseData<ResponseData, MappedType<R, T>>>;
93
+ }
94
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './request/index.js'
2
+ export {}
@@ -0,0 +1,182 @@
1
+ import { t as nanoid } from "./nanoid-CQE6QAZJ.js";
2
+ import { AxiosError, create } from "axios";
3
+ import axiosRetry from "axios-retry";
4
+ import { stringify } from "qs";
5
+ //#region src/request/shared.ts
6
+ /**
7
+ * check if http status is success
8
+ *
9
+ * @param status
10
+ */
11
+ function isHttpSuccess(status) {
12
+ return status >= 200 && status < 300 || status === 304;
13
+ }
14
+ async function transformResponse(response) {
15
+ const responseType = response.config?.responseType || "json";
16
+ if (responseType === "json") return;
17
+ if (!response.headers["content-type"]?.includes("application/json")) return;
18
+ if (responseType === "blob") await transformBlobToJson(response);
19
+ if (responseType === "arrayBuffer") await transformArrayBufferToJson(response);
20
+ }
21
+ async function transformBlobToJson(response) {
22
+ try {
23
+ let data = response.data;
24
+ if (typeof data === "string") data = JSON.parse(data);
25
+ if (Object.prototype.toString.call(data) === "[object Blob]") {
26
+ const json = await data.text();
27
+ data = JSON.parse(json);
28
+ }
29
+ response.data = data;
30
+ } catch {}
31
+ }
32
+ async function transformArrayBufferToJson(response) {
33
+ try {
34
+ let data = response.data;
35
+ if (typeof data === "string") data = JSON.parse(data);
36
+ if (Object.prototype.toString.call(data) === "[object ArrayBuffer]") {
37
+ const json = new TextDecoder().decode(data);
38
+ data = JSON.parse(json);
39
+ }
40
+ response.data = data;
41
+ } catch {}
42
+ }
43
+ //#endregion
44
+ //#region src/request/options.ts
45
+ function createDefaultOptions(options) {
46
+ const opts = {
47
+ defaultState: {},
48
+ transform: async (response) => response.data,
49
+ transformBackendResponse: async (response) => response.data,
50
+ onRequest: async (config) => config,
51
+ isBackendSuccess: (_response) => true,
52
+ onBackendFail: async () => {},
53
+ onError: async () => {}
54
+ };
55
+ if (options?.transform) opts.transform = options.transform;
56
+ else opts.transform = options?.transformBackendResponse || opts.transform;
57
+ Object.assign(opts, options);
58
+ return opts;
59
+ }
60
+ function createRetryOptions(config) {
61
+ const retryConfig = { retries: 0 };
62
+ Object.assign(retryConfig, config);
63
+ return retryConfig;
64
+ }
65
+ function createAxiosConfig(config) {
66
+ const axiosConfig = {
67
+ timeout: 10 * 1e3,
68
+ headers: { "Content-Type": "application/json" },
69
+ validateStatus: isHttpSuccess,
70
+ paramsSerializer: (params) => {
71
+ return stringify(params);
72
+ }
73
+ };
74
+ Object.assign(axiosConfig, config);
75
+ return axiosConfig;
76
+ }
77
+ //#endregion
78
+ //#region src/request/constant.ts
79
+ /** request id key */
80
+ var REQUEST_ID_KEY = "X-Request-Id";
81
+ /** the backend error code key */
82
+ var BACKEND_ERROR_CODE = "BACKEND_ERROR";
83
+ /** the request canceled code */
84
+ var REQUEST_CANCELED_CODE = "ERR_CANCELED";
85
+ //#endregion
86
+ //#region src/request/index.ts
87
+ function createCommonRequest(axiosConfig, options) {
88
+ const opts = createDefaultOptions(options);
89
+ const axiosConf = createAxiosConfig(axiosConfig);
90
+ const instance = create(axiosConf);
91
+ const abortControllerMap = /* @__PURE__ */ new Map();
92
+ axiosRetry(instance, createRetryOptions(axiosConf));
93
+ instance.interceptors.request.use((conf) => {
94
+ const config = { ...conf };
95
+ const requestId = nanoid();
96
+ config.headers.set(REQUEST_ID_KEY, requestId);
97
+ if (!config.signal) {
98
+ const abortController = new AbortController();
99
+ config.signal = abortController.signal;
100
+ abortControllerMap.set(requestId, abortController);
101
+ }
102
+ return opts.onRequest?.(config) || config;
103
+ });
104
+ instance.interceptors.response.use(async (response) => {
105
+ const responseType = response.config?.responseType || "json";
106
+ await transformResponse(response);
107
+ if (responseType !== "json" || opts.isBackendSuccess(response)) return Promise.resolve(response);
108
+ const fail = await opts.onBackendFail(response, instance);
109
+ if (fail) return fail;
110
+ const backendError = new AxiosError("请求失败,请联系管理员", BACKEND_ERROR_CODE, response.config, response.request, response);
111
+ await opts.onError(backendError);
112
+ return Promise.reject(backendError);
113
+ }, async (error) => {
114
+ await opts.onError(error);
115
+ return Promise.reject(error);
116
+ });
117
+ function cancelAllRequest() {
118
+ abortControllerMap.forEach((abortController) => {
119
+ abortController.abort();
120
+ });
121
+ abortControllerMap.clear();
122
+ }
123
+ return {
124
+ instance,
125
+ opts,
126
+ cancelAllRequest
127
+ };
128
+ }
129
+ /**
130
+ * create a request instance
131
+ *
132
+ * @param axiosConfig axios config
133
+ * @param options request options
134
+ */
135
+ function createRequest(axiosConfig, options) {
136
+ const { instance, opts, cancelAllRequest } = createCommonRequest(axiosConfig, options);
137
+ const request = async function request(config) {
138
+ const response = await instance(config);
139
+ if ((response.config?.responseType || "json") === "json") return opts.transform(response);
140
+ return response.data;
141
+ };
142
+ request.cancelAllRequest = cancelAllRequest;
143
+ request.state = {};
144
+ return request;
145
+ }
146
+ /**
147
+ * create a flat request instance
148
+ *
149
+ * The response data is a flat object: { data: any, error: AxiosError }
150
+ *
151
+ * @param axiosConfig axios config
152
+ * @param options request options
153
+ */
154
+ function createFlatRequest(axiosConfig, options) {
155
+ const { instance, opts, cancelAllRequest } = createCommonRequest(axiosConfig, options);
156
+ const flatRequest = async function flatRequest(config) {
157
+ try {
158
+ const response = await instance(config);
159
+ if ((response.config?.responseType || "json") === "json") return {
160
+ data: await opts.transform(response),
161
+ error: null,
162
+ response
163
+ };
164
+ return {
165
+ data: response.data,
166
+ error: null,
167
+ response
168
+ };
169
+ } catch (error) {
170
+ return {
171
+ data: null,
172
+ error,
173
+ response: error.response
174
+ };
175
+ }
176
+ };
177
+ flatRequest.cancelAllRequest = cancelAllRequest;
178
+ flatRequest.state = { ...opts.defaultState };
179
+ return flatRequest;
180
+ }
181
+ //#endregion
182
+ export { BACKEND_ERROR_CODE, REQUEST_CANCELED_CODE, REQUEST_ID_KEY, createFlatRequest, createRequest };
@@ -0,0 +1,2 @@
1
+ import { ChangelogOption } from '@soybeanjs/changelog';
2
+ export declare function genChangelog(options?: Partial<ChangelogOption>, total?: boolean): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function cleanup(paths: string[]): Promise<void>;
@@ -0,0 +1,9 @@
1
+ import { Lang } from '../locales';
2
+ /**
3
+ * Git commit with Conventional Commits standard
4
+ *
5
+ * @param lang
6
+ */
7
+ export declare function gitCommit(lang?: Lang): Promise<void>;
8
+ /** Git commit message verify */
9
+ export declare function gitCommitVerify(lang?: Lang, ignores?: RegExp[]): Promise<void>;
@@ -0,0 +1,6 @@
1
+ export * from './git-commit';
2
+ export * from './cleanup';
3
+ export * from './update-pkg';
4
+ export * from './changelog';
5
+ export * from './release';
6
+ export * from './router';
@@ -0,0 +1 @@
1
+ export declare function release(execute?: string, push?: boolean): Promise<void>;
@@ -0,0 +1,2 @@
1
+ /** generate route */
2
+ export declare function generateRoute(): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function updatePkg(args?: string[]): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { CliOption } from '../types';
2
+ export declare function loadCliOptions(overrides?: Partial<CliOption>, cwd?: string): Promise<CliOption>;
@@ -0,0 +1 @@
1
+ export declare function setupCli(): Promise<void>;
@@ -0,0 +1,25 @@
1
+ export type Lang = 'zh-cn' | 'en-us';
2
+ export declare const locales: {
3
+ 'zh-cn': {
4
+ gitCommitMessages: {
5
+ types: string;
6
+ scopes: string;
7
+ description: string;
8
+ };
9
+ gitCommitTypes: [string, string][];
10
+ gitCommitScopes: [string, string][];
11
+ gitCommitNoStaged: string;
12
+ gitCommitVerify: string;
13
+ };
14
+ 'en-us': {
15
+ gitCommitMessages: {
16
+ types: string;
17
+ scopes: string;
18
+ description: string;
19
+ };
20
+ gitCommitTypes: [string, string][];
21
+ gitCommitScopes: [string, string][];
22
+ gitCommitNoStaged: string;
23
+ gitCommitVerify: string;
24
+ };
25
+ };
@@ -0,0 +1,2 @@
1
+ import { Options } from 'execa';
2
+ export declare function execCommand(cmd: string, args: string[], options?: Options): Promise<string>;
@@ -0,0 +1,30 @@
1
+ import { ChangelogOption } from '@soybeanjs/changelog';
2
+ export interface CliOption {
3
+ /** The project root directory */
4
+ cwd: string;
5
+ /**
6
+ * Cleanup dirs
7
+ *
8
+ * Glob pattern syntax {@link https://github.com/isaacs/minimatch}
9
+ *
10
+ * @default
11
+ * ```json
12
+ * ["** /dist", "** /pnpm-lock.yaml", "** /node_modules", "!node_modules/**"]
13
+ * ```
14
+ */
15
+ cleanupDirs: string[];
16
+ /**
17
+ * Npm-check-updates command args
18
+ *
19
+ * @default ['--deep', '-u']
20
+ */
21
+ ncuCommandArgs: string[];
22
+ /**
23
+ * Options of generate changelog
24
+ *
25
+ * @link https://github.com/soybeanjs/changelog
26
+ */
27
+ changelogOptions: Partial<ChangelogOption>;
28
+ /** The ignore pattern list of git commit verify */
29
+ gitCommitVerifyIgnores: RegExp[];
30
+ }
@@ -0,0 +1,4 @@
1
+ import { Preset } from '@unocss/core';
2
+ import { Theme } from '@unocss/preset-mini';
3
+ export declare function createPresetYugu(name?: string): Preset<Theme>;
4
+ export default createPresetYugu;
@@ -0,0 +1,6 @@
1
+ export * from './uno-preset/index.js'
2
+ export {}
3
+ import _default from './uno-preset/index.js'
4
+ export default _default
5
+ export * from './uno-preset/index.js'
6
+ export {}
@@ -0,0 +1,49 @@
1
+ //#region src/uno-preset/index.ts
2
+ function createPresetYugu(name = "preset-yugu") {
3
+ return {
4
+ name,
5
+ shortcuts: [
6
+ {
7
+ "flex-center": "flex justify-center items-center",
8
+ "flex-x-center": "flex justify-center",
9
+ "flex-y-center": "flex items-center",
10
+ "flex-col": "flex flex-col",
11
+ "flex-col-center": "flex-center flex-col",
12
+ "flex-col-stretch": "flex-col items-stretch",
13
+ "i-flex-center": "inline-flex justify-center items-center",
14
+ "i-flex-x-center": "inline-flex justify-center",
15
+ "i-flex-y-center": "inline-flex items-center",
16
+ "i-flex-col": "flex-col inline-flex",
17
+ "i-flex-col-center": "flex-col i-flex-center",
18
+ "i-flex-col-stretch": "i-flex-col items-stretch",
19
+ "flex-1-hidden": "flex-1 overflow-hidden"
20
+ },
21
+ {
22
+ "absolute-lt": "absolute left-0 top-0",
23
+ "absolute-lb": "absolute left-0 bottom-0",
24
+ "absolute-rt": "absolute right-0 top-0",
25
+ "absolute-rb": "absolute right-0 bottom-0",
26
+ "absolute-tl": "absolute-lt",
27
+ "absolute-tr": "absolute-rt",
28
+ "absolute-bl": "absolute-lb",
29
+ "absolute-br": "absolute-rb",
30
+ "absolute-center": "absolute-lt flex-center size-full",
31
+ "fixed-lt": "fixed left-0 top-0",
32
+ "fixed-lb": "fixed left-0 bottom-0",
33
+ "fixed-rt": "fixed right-0 top-0",
34
+ "fixed-rb": "fixed right-0 bottom-0",
35
+ "fixed-tl": "fixed-lt",
36
+ "fixed-tr": "fixed-rt",
37
+ "fixed-bl": "fixed-lb",
38
+ "fixed-br": "fixed-rb",
39
+ "fixed-center": "fixed-lt flex-center size-full"
40
+ },
41
+ {
42
+ "nowrap-hidden": "overflow-hidden whitespace-nowrap",
43
+ "ellipsis-text": "nowrap-hidden text-ellipsis"
44
+ }
45
+ ]
46
+ };
47
+ }
48
+ //#endregion
49
+ export { createPresetYugu, createPresetYugu as default };
@@ -0,0 +1,2 @@
1
+ export * from './name';
2
+ export * from './palette';
@@ -0,0 +1,8 @@
1
+ export declare const colorNames: [hex: string, name: string][];
2
+ /**
3
+ * Map Of hex color values to color names
4
+ *
5
+ * - key: hex value
6
+ * - value: color name
7
+ */
8
+ export declare const colorNameMap: Record<string, string>;
@@ -0,0 +1,2 @@
1
+ import { ColorPaletteFamily } from '../types';
2
+ export declare const colorPalettes: ColorPaletteFamily[];
@@ -0,0 +1,5 @@
1
+ import { colorPalettes } from './constant';
2
+ export * from './palette';
3
+ export * from './shared';
4
+ export { colorPalettes };
5
+ export * from './types';
@@ -0,0 +1,18 @@
1
+ import { AnyColor } from 'colord';
2
+ import { ColorIndex } from '../types';
3
+ /**
4
+ * Get AntD palette color by index
5
+ *
6
+ * @param color - Color
7
+ * @param index - The color index of color palette (the main color index is 6)
8
+ * @returns Hex color
9
+ */
10
+ export declare function getAntDPaletteColorByIndex(color: AnyColor, index: ColorIndex): string;
11
+ /**
12
+ * Get AntD color palette
13
+ *
14
+ * @param color - Color
15
+ * @param darkTheme - Dark theme
16
+ * @param darkThemeMixColor - Dark theme mix color (default: #141414)
17
+ */
18
+ export declare function getAntDColorPalette(color: AnyColor, darkTheme?: boolean, darkThemeMixColor?: string): string[];
@@ -0,0 +1,17 @@
1
+ import { AnyColor } from 'colord';
2
+ import { ColorPaletteNumber } from '../types';
3
+ /**
4
+ * get color palette by provided color
5
+ *
6
+ * @param color
7
+ * @param recommended whether to get recommended color palette (the provided color may not be the main color)
8
+ */
9
+ export declare function getColorPalette(color: AnyColor, recommended?: boolean): Map<ColorPaletteNumber, string>;
10
+ /**
11
+ * get color palette color by number
12
+ *
13
+ * @param color the provided color
14
+ * @param number the color palette number
15
+ * @param recommended whether to get recommended color palette (the provided color may not be the main color)
16
+ */
17
+ export declare function getPaletteColorByNumber(color: AnyColor, number: ColorPaletteNumber, recommended?: boolean): string;
@@ -0,0 +1,20 @@
1
+ import { ColorPaletteFamily, ColorPaletteMatch, ColorPaletteNumber } from '../types';
2
+ /**
3
+ * get recommended color palette by provided color
4
+ *
5
+ * @param color the provided color
6
+ */
7
+ export declare function getRecommendedColorPalette(color: string): ColorPaletteMatch;
8
+ /**
9
+ * get recommended palette color by provided color
10
+ *
11
+ * @param color the provided color
12
+ * @param number the color palette number
13
+ */
14
+ export declare function getRecommendedPaletteColorByNumber(color: string, number: ColorPaletteNumber): string;
15
+ /**
16
+ * get color palette family by provided color and color name
17
+ *
18
+ * @param color the provided color
19
+ */
20
+ export declare function getRecommendedColorPaletteFamily(color: string): ColorPaletteFamily;
@@ -0,0 +1,38 @@
1
+ import { colord, AnyColor, HslColor } from 'colord';
2
+ export declare function isValidColor(color: AnyColor): boolean;
3
+ export declare function getHex(color: AnyColor): string;
4
+ export declare function getRgb(color: AnyColor): import('colord').RgbaColor;
5
+ export declare function getHsl(color: AnyColor): import('colord').HslaColor;
6
+ export declare function getHsv(color: AnyColor): import('colord').HsvaColor;
7
+ export declare function getDeltaE(color1: AnyColor, color2: AnyColor): number;
8
+ export declare function transformHslToHex(color: HslColor): string;
9
+ /**
10
+ * Add color alpha
11
+ *
12
+ * @param color - Color
13
+ * @param alpha - Alpha (0 - 1)
14
+ */
15
+ export declare function addColorAlpha(color: AnyColor, alpha: number): string;
16
+ /**
17
+ * Mix color
18
+ *
19
+ * @param firstColor - First color
20
+ * @param secondColor - Second color
21
+ * @param ratio - The ratio of the second color (0 - 1)
22
+ */
23
+ export declare function mixColor(firstColor: AnyColor, secondColor: AnyColor, ratio: number): string;
24
+ /**
25
+ * Transform color with opacity to similar color without opacity
26
+ *
27
+ * @param color - Color
28
+ * @param alpha - Alpha (0 - 1)
29
+ * @param bgColor Background color (usually white or black)
30
+ */
31
+ export declare function transformColorWithOpacity(color: AnyColor, alpha: number, bgColor?: string): string;
32
+ /**
33
+ * Is white color
34
+ *
35
+ * @param color - Color
36
+ */
37
+ export declare function isWhiteColor(color: AnyColor): boolean;
38
+ export { colord };
@@ -0,0 +1,2 @@
1
+ export * from './colord';
2
+ export * from './name';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Get color name
3
+ *
4
+ * @param color
5
+ */
6
+ export declare function getColorName(color: string): string;