@yamada-ui/utils 0.0.0-dev-20231207022217 → 0.0.0-dev-20231212223458
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 +1 -1
- package/dist/chunk-SAZNI4PK.mjs +6 -0
- package/dist/{chunk-RJN7NAQE.mjs → chunk-WYLOTAWH.mjs} +9 -4
- package/dist/color.d.mts +4 -3
- package/dist/color.d.ts +4 -3
- package/dist/color.js +8 -4
- package/dist/color.mjs +4 -1
- package/dist/function.mjs +2 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +16 -4
- package/dist/index.mjs +9 -1
- package/dist/module.d.mts +3 -0
- package/dist/module.d.ts +3 -0
- package/dist/module.js +30 -0
- package/dist/module.mjs +6 -0
- package/dist/object.mjs +2 -1
- package/dist/react.d.mts +2 -1
- package/dist/react.d.ts +2 -1
- package/dist/react.js +3 -0
- package/dist/react.mjs +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ $ npm install @yamada-ui/utils
|
|
|
24
24
|
|
|
25
25
|
Wouldn't you like to contribute? That's amazing! We have prepared a [contribution guide](https://github.com/hirotomoyamada/yamada-ui/blob/main/CONTRIBUTING.md) to assist you.
|
|
26
26
|
|
|
27
|
-
##
|
|
27
|
+
## License
|
|
28
28
|
|
|
29
29
|
This package is licensed under the terms of the
|
|
30
30
|
|
|
@@ -170,6 +170,7 @@ var useAsyncRetry = (func, deps = []) => {
|
|
|
170
170
|
}, [...deps, stateLoading]);
|
|
171
171
|
return { ...state, retry };
|
|
172
172
|
};
|
|
173
|
+
var createId = (prefix) => `${prefix}-${(/* @__PURE__ */ new Date()).getTime()}`;
|
|
173
174
|
|
|
174
175
|
// src/color.ts
|
|
175
176
|
import {
|
|
@@ -180,7 +181,6 @@ import {
|
|
|
180
181
|
darken,
|
|
181
182
|
lighten
|
|
182
183
|
} from "color2k";
|
|
183
|
-
var coef = 0.75;
|
|
184
184
|
var hues = [
|
|
185
185
|
50,
|
|
186
186
|
100,
|
|
@@ -195,6 +195,7 @@ var hues = [
|
|
|
195
195
|
950
|
|
196
196
|
];
|
|
197
197
|
var isGray = (colorScheme) => colorScheme === "gray" || colorScheme === "neutral";
|
|
198
|
+
var isAccessible = (colorScheme) => colorScheme === "yellow" || colorScheme === "cyan" || colorScheme === "lime";
|
|
198
199
|
var getColor = (color, fallback) => (theme = {}, colorMode) => {
|
|
199
200
|
var _a, _b, _c;
|
|
200
201
|
const [token, hue] = color.split(".");
|
|
@@ -224,7 +225,7 @@ var darkenColor = (color, amount) => (theme, colorMode) => {
|
|
|
224
225
|
};
|
|
225
226
|
var tintColor = (color, amount) => (theme, colorMode) => {
|
|
226
227
|
const raw = getColor(color, color)(theme, colorMode);
|
|
227
|
-
return toHex(mix(raw, "#fff", amount));
|
|
228
|
+
return toHex(mix(raw, "#fff", amount / 100));
|
|
228
229
|
};
|
|
229
230
|
var shadeColor = (color, amount) => (theme, colorMode) => {
|
|
230
231
|
const raw = getColor(color, color)(theme, colorMode);
|
|
@@ -234,18 +235,20 @@ var transparentizeColor = (color, alpha) => (theme, colorMode) => {
|
|
|
234
235
|
const raw = getColor(color, color)(theme, colorMode);
|
|
235
236
|
return transparentize(raw, 1 - alpha);
|
|
236
237
|
};
|
|
237
|
-
var toneColor = (color, hue) => (theme, colorMode) => {
|
|
238
|
+
var toneColor = (color, hue, lCoef = 0.94, dCoef = 0.86) => (theme, colorMode) => {
|
|
238
239
|
if (hue < 50 || 950 < hue)
|
|
239
240
|
return color;
|
|
240
241
|
let raw = color;
|
|
241
242
|
if (theme && colorMode)
|
|
242
243
|
getColor(color, color)(theme, colorMode);
|
|
244
|
+
const coef = hue < 500 ? lCoef : dCoef;
|
|
243
245
|
const amount = (500 - hue) * 1e-3 * coef;
|
|
244
246
|
return toHex(lighten(raw, amount));
|
|
245
247
|
};
|
|
246
|
-
var toneColors = (color) => {
|
|
248
|
+
var toneColors = (color, lCoef = 0.94, dCoef = 0.86) => {
|
|
247
249
|
const colors = {};
|
|
248
250
|
hues.forEach((hue) => {
|
|
251
|
+
const coef = hue < 500 ? lCoef : dCoef;
|
|
249
252
|
const amount = (500 - hue) * 1e-3 * coef;
|
|
250
253
|
colors[hue] = toHex(lighten(color, amount));
|
|
251
254
|
});
|
|
@@ -481,8 +484,10 @@ export {
|
|
|
481
484
|
useAsync,
|
|
482
485
|
useAsyncFunc,
|
|
483
486
|
useAsyncRetry,
|
|
487
|
+
createId,
|
|
484
488
|
hues,
|
|
485
489
|
isGray,
|
|
490
|
+
isAccessible,
|
|
486
491
|
getColor,
|
|
487
492
|
lightenColor,
|
|
488
493
|
darkenColor,
|
package/dist/color.d.mts
CHANGED
|
@@ -3,14 +3,15 @@ import { Dict } from './index.types.mjs';
|
|
|
3
3
|
type ColorMode = "light" | "dark";
|
|
4
4
|
declare const hues: readonly [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
|
|
5
5
|
declare const isGray: (colorScheme: string) => boolean;
|
|
6
|
+
declare const isAccessible: (colorScheme: string) => boolean;
|
|
6
7
|
declare const getColor: (color: string, fallback?: string) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
7
8
|
declare const lightenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
8
9
|
declare const darkenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
9
10
|
declare const tintColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
10
11
|
declare const shadeColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
11
12
|
declare const transparentizeColor: (color: string, alpha: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
12
|
-
declare const toneColor: (color: string, hue: (typeof hues)[number]) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
13
|
-
declare const toneColors: (color: string) => Record<string, string>;
|
|
13
|
+
declare const toneColor: (color: string, hue: (typeof hues)[number], lCoef?: number, dCoef?: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
14
|
+
declare const toneColors: (color: string, lCoef?: number, dCoef?: number) => Record<string, string>;
|
|
14
15
|
declare const randomColor: ({ string, colors, }?: {
|
|
15
16
|
string?: string | undefined;
|
|
16
17
|
colors?: string[] | undefined;
|
|
@@ -19,4 +20,4 @@ declare const isTone: (color: string) => (theme?: Dict, colorMode?: ColorMode) =
|
|
|
19
20
|
declare const isLight: (color: string) => (theme?: Dict, colorMode?: ColorMode) => boolean;
|
|
20
21
|
declare const isDark: (color: string) => (theme?: Dict, colorMode?: ColorMode) => boolean;
|
|
21
22
|
|
|
22
|
-
export { darkenColor, getColor, hues, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, toneColors, transparentizeColor };
|
|
23
|
+
export { darkenColor, getColor, hues, isAccessible, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, toneColors, transparentizeColor };
|
package/dist/color.d.ts
CHANGED
|
@@ -3,14 +3,15 @@ import { Dict } from './index.types.js';
|
|
|
3
3
|
type ColorMode = "light" | "dark";
|
|
4
4
|
declare const hues: readonly [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
|
|
5
5
|
declare const isGray: (colorScheme: string) => boolean;
|
|
6
|
+
declare const isAccessible: (colorScheme: string) => boolean;
|
|
6
7
|
declare const getColor: (color: string, fallback?: string) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
7
8
|
declare const lightenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
8
9
|
declare const darkenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
9
10
|
declare const tintColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
10
11
|
declare const shadeColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
11
12
|
declare const transparentizeColor: (color: string, alpha: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
12
|
-
declare const toneColor: (color: string, hue: (typeof hues)[number]) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
13
|
-
declare const toneColors: (color: string) => Record<string, string>;
|
|
13
|
+
declare const toneColor: (color: string, hue: (typeof hues)[number], lCoef?: number, dCoef?: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
14
|
+
declare const toneColors: (color: string, lCoef?: number, dCoef?: number) => Record<string, string>;
|
|
14
15
|
declare const randomColor: ({ string, colors, }?: {
|
|
15
16
|
string?: string | undefined;
|
|
16
17
|
colors?: string[] | undefined;
|
|
@@ -19,4 +20,4 @@ declare const isTone: (color: string) => (theme?: Dict, colorMode?: ColorMode) =
|
|
|
19
20
|
declare const isLight: (color: string) => (theme?: Dict, colorMode?: ColorMode) => boolean;
|
|
20
21
|
declare const isDark: (color: string) => (theme?: Dict, colorMode?: ColorMode) => boolean;
|
|
21
22
|
|
|
22
|
-
export { darkenColor, getColor, hues, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, toneColors, transparentizeColor };
|
|
23
|
+
export { darkenColor, getColor, hues, isAccessible, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, toneColors, transparentizeColor };
|
package/dist/color.js
CHANGED
|
@@ -23,6 +23,7 @@ __export(color_exports, {
|
|
|
23
23
|
darkenColor: () => darkenColor,
|
|
24
24
|
getColor: () => getColor,
|
|
25
25
|
hues: () => hues,
|
|
26
|
+
isAccessible: () => isAccessible,
|
|
26
27
|
isDark: () => isDark,
|
|
27
28
|
isGray: () => isGray,
|
|
28
29
|
isLight: () => isLight,
|
|
@@ -70,7 +71,6 @@ var memoizeObject = (func) => {
|
|
|
70
71
|
var getMemoizedObject = memoizeObject(getObject);
|
|
71
72
|
|
|
72
73
|
// src/color.ts
|
|
73
|
-
var coef = 0.75;
|
|
74
74
|
var hues = [
|
|
75
75
|
50,
|
|
76
76
|
100,
|
|
@@ -85,6 +85,7 @@ var hues = [
|
|
|
85
85
|
950
|
|
86
86
|
];
|
|
87
87
|
var isGray = (colorScheme) => colorScheme === "gray" || colorScheme === "neutral";
|
|
88
|
+
var isAccessible = (colorScheme) => colorScheme === "yellow" || colorScheme === "cyan" || colorScheme === "lime";
|
|
88
89
|
var getColor = (color, fallback) => (theme = {}, colorMode) => {
|
|
89
90
|
var _a, _b, _c;
|
|
90
91
|
const [token, hue] = color.split(".");
|
|
@@ -114,7 +115,7 @@ var darkenColor = (color, amount) => (theme, colorMode) => {
|
|
|
114
115
|
};
|
|
115
116
|
var tintColor = (color, amount) => (theme, colorMode) => {
|
|
116
117
|
const raw = getColor(color, color)(theme, colorMode);
|
|
117
|
-
return (0, import_color2k.toHex)((0, import_color2k.mix)(raw, "#fff", amount));
|
|
118
|
+
return (0, import_color2k.toHex)((0, import_color2k.mix)(raw, "#fff", amount / 100));
|
|
118
119
|
};
|
|
119
120
|
var shadeColor = (color, amount) => (theme, colorMode) => {
|
|
120
121
|
const raw = getColor(color, color)(theme, colorMode);
|
|
@@ -124,18 +125,20 @@ var transparentizeColor = (color, alpha) => (theme, colorMode) => {
|
|
|
124
125
|
const raw = getColor(color, color)(theme, colorMode);
|
|
125
126
|
return (0, import_color2k.transparentize)(raw, 1 - alpha);
|
|
126
127
|
};
|
|
127
|
-
var toneColor = (color, hue) => (theme, colorMode) => {
|
|
128
|
+
var toneColor = (color, hue, lCoef = 0.94, dCoef = 0.86) => (theme, colorMode) => {
|
|
128
129
|
if (hue < 50 || 950 < hue)
|
|
129
130
|
return color;
|
|
130
131
|
let raw = color;
|
|
131
132
|
if (theme && colorMode)
|
|
132
133
|
getColor(color, color)(theme, colorMode);
|
|
134
|
+
const coef = hue < 500 ? lCoef : dCoef;
|
|
133
135
|
const amount = (500 - hue) * 1e-3 * coef;
|
|
134
136
|
return (0, import_color2k.toHex)((0, import_color2k.lighten)(raw, amount));
|
|
135
137
|
};
|
|
136
|
-
var toneColors = (color) => {
|
|
138
|
+
var toneColors = (color, lCoef = 0.94, dCoef = 0.86) => {
|
|
137
139
|
const colors = {};
|
|
138
140
|
hues.forEach((hue) => {
|
|
141
|
+
const coef = hue < 500 ? lCoef : dCoef;
|
|
139
142
|
const amount = (500 - hue) * 1e-3 * coef;
|
|
140
143
|
colors[hue] = (0, import_color2k.toHex)((0, import_color2k.lighten)(color, amount));
|
|
141
144
|
});
|
|
@@ -199,6 +202,7 @@ var isDark = (color) => (theme, colorMode) => isTone(color)(theme, colorMode) ==
|
|
|
199
202
|
darkenColor,
|
|
200
203
|
getColor,
|
|
201
204
|
hues,
|
|
205
|
+
isAccessible,
|
|
202
206
|
isDark,
|
|
203
207
|
isGray,
|
|
204
208
|
isLight,
|
package/dist/color.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
darkenColor,
|
|
3
3
|
getColor,
|
|
4
4
|
hues,
|
|
5
|
+
isAccessible,
|
|
5
6
|
isDark,
|
|
6
7
|
isGray,
|
|
7
8
|
isLight,
|
|
@@ -13,8 +14,9 @@ import {
|
|
|
13
14
|
toneColor,
|
|
14
15
|
toneColors,
|
|
15
16
|
transparentizeColor
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-WYLOTAWH.mjs";
|
|
17
18
|
import "./chunk-SLJ4M7XC.mjs";
|
|
19
|
+
import "./chunk-SAZNI4PK.mjs";
|
|
18
20
|
import "./chunk-VYMGBE25.mjs";
|
|
19
21
|
import "./chunk-BZAW2D6U.mjs";
|
|
20
22
|
import "./chunk-PURW64JE.mjs";
|
|
@@ -26,6 +28,7 @@ export {
|
|
|
26
28
|
darkenColor,
|
|
27
29
|
getColor,
|
|
28
30
|
hues,
|
|
31
|
+
isAccessible,
|
|
29
32
|
isDark,
|
|
30
33
|
isGray,
|
|
31
34
|
isLight,
|
package/dist/function.mjs
CHANGED
|
@@ -3,8 +3,9 @@ import {
|
|
|
3
3
|
handlerAll,
|
|
4
4
|
noop,
|
|
5
5
|
runIfFunc
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WYLOTAWH.mjs";
|
|
7
7
|
import "./chunk-SLJ4M7XC.mjs";
|
|
8
|
+
import "./chunk-SAZNI4PK.mjs";
|
|
8
9
|
import "./chunk-VYMGBE25.mjs";
|
|
9
10
|
import "./chunk-BZAW2D6U.mjs";
|
|
10
11
|
import "./chunk-PURW64JE.mjs";
|
package/dist/index.d.mts
CHANGED
|
@@ -2,12 +2,13 @@ export { Dict, Length, Merge, Path, Primitive, StringLiteral, Union } from './in
|
|
|
2
2
|
export { cast, isArray, isEmpty, isFunction, isNotNumber, isNull, isNumber, isNumeric, isObject, isString, isUndefined, isUnit } from './assertion.mjs';
|
|
3
3
|
export { assignAfter, filterObject, filterUndefined, flattenObject, getMemoizedObject, getObject, keysFormObject, memoizeObject, merge, objectFromEntries, omitObject, pickObject, replaceObject, splitObject } from './object.mjs';
|
|
4
4
|
export { funcAll, handlerAll, noop, runIfFunc } from './function.mjs';
|
|
5
|
-
export { AsyncFnReturn, AsyncState, AsyncStateRetry, DOMAttributes, FunctionReturningPromise, MaybeRenderProp, PromiseType, PropGetter, RequiredPropGetter, assignRef, createContext, cx, findChildren, getValidChildren, includesChildren, isRefObject, isValidElement, mergeRefs, omitChildren, pickChildren, useAsync, useAsyncFunc, useAsyncRetry, useCallbackRef, useIsMounted, useMergeRefs, useSafeLayoutEffect, useUnmountEffect, useUpdateEffect } from './react.mjs';
|
|
5
|
+
export { AsyncFnReturn, AsyncState, AsyncStateRetry, DOMAttributes, FunctionReturningPromise, MaybeRenderProp, PromiseType, PropGetter, RequiredPropGetter, assignRef, createContext, createId, cx, findChildren, getValidChildren, includesChildren, isRefObject, isValidElement, mergeRefs, omitChildren, pickChildren, useAsync, useAsyncFunc, useAsyncRetry, useCallbackRef, useIsMounted, useMergeRefs, useSafeLayoutEffect, useUnmountEffect, useUpdateEffect } from './react.mjs';
|
|
6
6
|
export { FocusableElement, ariaAttr, createdDom, dataAttr, getActiveElement, getAllFocusable, getEventRelatedTarget, getOwnerDocument, getOwnerWindow, getPlatform, hasNegativeTabIndex, hasTabIndex, isActiveElement, isApple, isContains, isContentEditable, isDisabled, isElement, isFocusable, isHTMLElement, isHidden, isMac, isSafari, isTabbable, platform, vendor } from './dom.mjs';
|
|
7
7
|
export { escape } from './string.mjs';
|
|
8
8
|
export { Operand, calc } from './calc.mjs';
|
|
9
|
-
export { darkenColor, getColor, hues, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, toneColors, transparentizeColor } from './color.mjs';
|
|
9
|
+
export { darkenColor, getColor, hues, isAccessible, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, toneColors, transparentizeColor } from './color.mjs';
|
|
10
10
|
export { filterEmpty } from './array.mjs';
|
|
11
11
|
export { clampNumber, countDecimal, percentToValue, roundNumberToStep, toPrecision, valueToPercent } from './number.mjs';
|
|
12
12
|
export { AnyPointerEvent, MixedEventListener, Point, PointType, PointerEventInfo, addDomEvent, addPointerEvent, getEventPoint, getEventWindow, isMouseEvent, isMultiTouchEvent, isTouchEvent, pointFromMouse, pointFromTouch } from './event.mjs';
|
|
13
|
+
export { interopDefault } from './module.mjs';
|
|
13
14
|
import 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ export { Dict, Length, Merge, Path, Primitive, StringLiteral, Union } from './in
|
|
|
2
2
|
export { cast, isArray, isEmpty, isFunction, isNotNumber, isNull, isNumber, isNumeric, isObject, isString, isUndefined, isUnit } from './assertion.js';
|
|
3
3
|
export { assignAfter, filterObject, filterUndefined, flattenObject, getMemoizedObject, getObject, keysFormObject, memoizeObject, merge, objectFromEntries, omitObject, pickObject, replaceObject, splitObject } from './object.js';
|
|
4
4
|
export { funcAll, handlerAll, noop, runIfFunc } from './function.js';
|
|
5
|
-
export { AsyncFnReturn, AsyncState, AsyncStateRetry, DOMAttributes, FunctionReturningPromise, MaybeRenderProp, PromiseType, PropGetter, RequiredPropGetter, assignRef, createContext, cx, findChildren, getValidChildren, includesChildren, isRefObject, isValidElement, mergeRefs, omitChildren, pickChildren, useAsync, useAsyncFunc, useAsyncRetry, useCallbackRef, useIsMounted, useMergeRefs, useSafeLayoutEffect, useUnmountEffect, useUpdateEffect } from './react.js';
|
|
5
|
+
export { AsyncFnReturn, AsyncState, AsyncStateRetry, DOMAttributes, FunctionReturningPromise, MaybeRenderProp, PromiseType, PropGetter, RequiredPropGetter, assignRef, createContext, createId, cx, findChildren, getValidChildren, includesChildren, isRefObject, isValidElement, mergeRefs, omitChildren, pickChildren, useAsync, useAsyncFunc, useAsyncRetry, useCallbackRef, useIsMounted, useMergeRefs, useSafeLayoutEffect, useUnmountEffect, useUpdateEffect } from './react.js';
|
|
6
6
|
export { FocusableElement, ariaAttr, createdDom, dataAttr, getActiveElement, getAllFocusable, getEventRelatedTarget, getOwnerDocument, getOwnerWindow, getPlatform, hasNegativeTabIndex, hasTabIndex, isActiveElement, isApple, isContains, isContentEditable, isDisabled, isElement, isFocusable, isHTMLElement, isHidden, isMac, isSafari, isTabbable, platform, vendor } from './dom.js';
|
|
7
7
|
export { escape } from './string.js';
|
|
8
8
|
export { Operand, calc } from './calc.js';
|
|
9
|
-
export { darkenColor, getColor, hues, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, toneColors, transparentizeColor } from './color.js';
|
|
9
|
+
export { darkenColor, getColor, hues, isAccessible, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, toneColors, transparentizeColor } from './color.js';
|
|
10
10
|
export { filterEmpty } from './array.js';
|
|
11
11
|
export { clampNumber, countDecimal, percentToValue, roundNumberToStep, toPrecision, valueToPercent } from './number.js';
|
|
12
12
|
export { AnyPointerEvent, MixedEventListener, Point, PointType, PointerEventInfo, addDomEvent, addPointerEvent, getEventPoint, getEventWindow, isMouseEvent, isMultiTouchEvent, isTouchEvent, pointFromMouse, pointFromTouch } from './event.js';
|
|
13
|
+
export { interopDefault } from './module.js';
|
|
13
14
|
import 'react';
|
package/dist/index.js
CHANGED
|
@@ -40,6 +40,7 @@ __export(src_exports, {
|
|
|
40
40
|
clampNumber: () => clampNumber,
|
|
41
41
|
countDecimal: () => countDecimal,
|
|
42
42
|
createContext: () => createContext2,
|
|
43
|
+
createId: () => createId,
|
|
43
44
|
createdDom: () => createdDom,
|
|
44
45
|
cx: () => cx,
|
|
45
46
|
darkenColor: () => darkenColor,
|
|
@@ -68,6 +69,8 @@ __export(src_exports, {
|
|
|
68
69
|
hasTabIndex: () => hasTabIndex,
|
|
69
70
|
hues: () => hues,
|
|
70
71
|
includesChildren: () => includesChildren,
|
|
72
|
+
interopDefault: () => interopDefault,
|
|
73
|
+
isAccessible: () => isAccessible,
|
|
71
74
|
isActiveElement: () => isActiveElement,
|
|
72
75
|
isApple: () => isApple,
|
|
73
76
|
isArray: () => isArray,
|
|
@@ -455,6 +458,7 @@ var useAsyncRetry = (func, deps = []) => {
|
|
|
455
458
|
}, [...deps, stateLoading]);
|
|
456
459
|
return { ...state, retry };
|
|
457
460
|
};
|
|
461
|
+
var createId = (prefix) => `${prefix}-${(/* @__PURE__ */ new Date()).getTime()}`;
|
|
458
462
|
|
|
459
463
|
// src/dom.ts
|
|
460
464
|
var createdDom = () => !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
@@ -584,7 +588,6 @@ var calc = Object.assign(
|
|
|
584
588
|
|
|
585
589
|
// src/color.ts
|
|
586
590
|
var import_color2k = require("color2k");
|
|
587
|
-
var coef = 0.75;
|
|
588
591
|
var hues = [
|
|
589
592
|
50,
|
|
590
593
|
100,
|
|
@@ -599,6 +602,7 @@ var hues = [
|
|
|
599
602
|
950
|
|
600
603
|
];
|
|
601
604
|
var isGray = (colorScheme) => colorScheme === "gray" || colorScheme === "neutral";
|
|
605
|
+
var isAccessible = (colorScheme) => colorScheme === "yellow" || colorScheme === "cyan" || colorScheme === "lime";
|
|
602
606
|
var getColor = (color, fallback) => (theme = {}, colorMode) => {
|
|
603
607
|
var _a, _b, _c;
|
|
604
608
|
const [token, hue] = color.split(".");
|
|
@@ -628,7 +632,7 @@ var darkenColor = (color, amount) => (theme, colorMode) => {
|
|
|
628
632
|
};
|
|
629
633
|
var tintColor = (color, amount) => (theme, colorMode) => {
|
|
630
634
|
const raw = getColor(color, color)(theme, colorMode);
|
|
631
|
-
return (0, import_color2k.toHex)((0, import_color2k.mix)(raw, "#fff", amount));
|
|
635
|
+
return (0, import_color2k.toHex)((0, import_color2k.mix)(raw, "#fff", amount / 100));
|
|
632
636
|
};
|
|
633
637
|
var shadeColor = (color, amount) => (theme, colorMode) => {
|
|
634
638
|
const raw = getColor(color, color)(theme, colorMode);
|
|
@@ -638,18 +642,20 @@ var transparentizeColor = (color, alpha) => (theme, colorMode) => {
|
|
|
638
642
|
const raw = getColor(color, color)(theme, colorMode);
|
|
639
643
|
return (0, import_color2k.transparentize)(raw, 1 - alpha);
|
|
640
644
|
};
|
|
641
|
-
var toneColor = (color, hue) => (theme, colorMode) => {
|
|
645
|
+
var toneColor = (color, hue, lCoef = 0.94, dCoef = 0.86) => (theme, colorMode) => {
|
|
642
646
|
if (hue < 50 || 950 < hue)
|
|
643
647
|
return color;
|
|
644
648
|
let raw = color;
|
|
645
649
|
if (theme && colorMode)
|
|
646
650
|
getColor(color, color)(theme, colorMode);
|
|
651
|
+
const coef = hue < 500 ? lCoef : dCoef;
|
|
647
652
|
const amount = (500 - hue) * 1e-3 * coef;
|
|
648
653
|
return (0, import_color2k.toHex)((0, import_color2k.lighten)(raw, amount));
|
|
649
654
|
};
|
|
650
|
-
var toneColors = (color) => {
|
|
655
|
+
var toneColors = (color, lCoef = 0.94, dCoef = 0.86) => {
|
|
651
656
|
const colors = {};
|
|
652
657
|
hues.forEach((hue) => {
|
|
658
|
+
const coef = hue < 500 ? lCoef : dCoef;
|
|
653
659
|
const amount = (500 - hue) * 1e-3 * coef;
|
|
654
660
|
colors[hue] = (0, import_color2k.toHex)((0, import_color2k.lighten)(color, amount));
|
|
655
661
|
});
|
|
@@ -782,6 +788,9 @@ var wrap = (cb, filterPrimary = false) => {
|
|
|
782
788
|
return fn;
|
|
783
789
|
};
|
|
784
790
|
var addPointerEvent = (target, type, cb, options) => addDomEvent(target, type, wrap(cb, type === "pointerdown"), options);
|
|
791
|
+
|
|
792
|
+
// src/module.ts
|
|
793
|
+
var interopDefault = (module2) => module2.default || module2;
|
|
785
794
|
// Annotate the CommonJS export names for ESM import in node:
|
|
786
795
|
0 && (module.exports = {
|
|
787
796
|
addDomEvent,
|
|
@@ -794,6 +803,7 @@ var addPointerEvent = (target, type, cb, options) => addDomEvent(target, type, w
|
|
|
794
803
|
clampNumber,
|
|
795
804
|
countDecimal,
|
|
796
805
|
createContext,
|
|
806
|
+
createId,
|
|
797
807
|
createdDom,
|
|
798
808
|
cx,
|
|
799
809
|
darkenColor,
|
|
@@ -822,6 +832,8 @@ var addPointerEvent = (target, type, cb, options) => addDomEvent(target, type, w
|
|
|
822
832
|
hasTabIndex,
|
|
823
833
|
hues,
|
|
824
834
|
includesChildren,
|
|
835
|
+
interopDefault,
|
|
836
|
+
isAccessible,
|
|
825
837
|
isActiveElement,
|
|
826
838
|
isApple,
|
|
827
839
|
isArray,
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
assignAfter,
|
|
3
3
|
assignRef,
|
|
4
4
|
createContext,
|
|
5
|
+
createId,
|
|
5
6
|
cx,
|
|
6
7
|
darkenColor,
|
|
7
8
|
filterObject,
|
|
@@ -16,6 +17,7 @@ import {
|
|
|
16
17
|
handlerAll,
|
|
17
18
|
hues,
|
|
18
19
|
includesChildren,
|
|
20
|
+
isAccessible,
|
|
19
21
|
isDark,
|
|
20
22
|
isGray,
|
|
21
23
|
isLight,
|
|
@@ -51,8 +53,11 @@ import {
|
|
|
51
53
|
useSafeLayoutEffect,
|
|
52
54
|
useUnmountEffect,
|
|
53
55
|
useUpdateEffect
|
|
54
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-WYLOTAWH.mjs";
|
|
55
57
|
import "./chunk-SLJ4M7XC.mjs";
|
|
58
|
+
import {
|
|
59
|
+
interopDefault
|
|
60
|
+
} from "./chunk-SAZNI4PK.mjs";
|
|
56
61
|
import {
|
|
57
62
|
clampNumber,
|
|
58
63
|
countDecimal,
|
|
@@ -133,6 +138,7 @@ export {
|
|
|
133
138
|
clampNumber,
|
|
134
139
|
countDecimal,
|
|
135
140
|
createContext,
|
|
141
|
+
createId,
|
|
136
142
|
createdDom,
|
|
137
143
|
cx,
|
|
138
144
|
darkenColor,
|
|
@@ -161,6 +167,8 @@ export {
|
|
|
161
167
|
hasTabIndex,
|
|
162
168
|
hues,
|
|
163
169
|
includesChildren,
|
|
170
|
+
interopDefault,
|
|
171
|
+
isAccessible,
|
|
164
172
|
isActiveElement,
|
|
165
173
|
isApple,
|
|
166
174
|
isArray,
|
package/dist/module.d.ts
ADDED
package/dist/module.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/module.ts
|
|
21
|
+
var module_exports = {};
|
|
22
|
+
__export(module_exports, {
|
|
23
|
+
interopDefault: () => interopDefault
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(module_exports);
|
|
26
|
+
var interopDefault = (module2) => module2.default || module2;
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
interopDefault
|
|
30
|
+
});
|
package/dist/module.mjs
ADDED
package/dist/object.mjs
CHANGED
|
@@ -13,8 +13,9 @@ import {
|
|
|
13
13
|
pickObject,
|
|
14
14
|
replaceObject,
|
|
15
15
|
splitObject
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-WYLOTAWH.mjs";
|
|
17
17
|
import "./chunk-SLJ4M7XC.mjs";
|
|
18
|
+
import "./chunk-SAZNI4PK.mjs";
|
|
18
19
|
import "./chunk-VYMGBE25.mjs";
|
|
19
20
|
import "./chunk-BZAW2D6U.mjs";
|
|
20
21
|
import "./chunk-PURW64JE.mjs";
|
package/dist/react.d.mts
CHANGED
|
@@ -87,5 +87,6 @@ declare const useAsyncRetry: <T>(func: () => Promise<T>, deps?: React.Dependency
|
|
|
87
87
|
error?: undefined;
|
|
88
88
|
value: T;
|
|
89
89
|
};
|
|
90
|
+
declare const createId: (prefix: string) => string;
|
|
90
91
|
|
|
91
|
-
export { type AsyncFnReturn, type AsyncState, type AsyncStateRetry, type DOMAttributes, type FunctionReturningPromise, type MaybeRenderProp, type PromiseType, type PropGetter, type RequiredPropGetter, assignRef, createContext, cx, findChildren, getValidChildren, includesChildren, isRefObject, isValidElement, mergeRefs, omitChildren, pickChildren, useAsync, useAsyncFunc, useAsyncRetry, useCallbackRef, useIsMounted, useMergeRefs, useSafeLayoutEffect, useUnmountEffect, useUpdateEffect };
|
|
92
|
+
export { type AsyncFnReturn, type AsyncState, type AsyncStateRetry, type DOMAttributes, type FunctionReturningPromise, type MaybeRenderProp, type PromiseType, type PropGetter, type RequiredPropGetter, assignRef, createContext, createId, cx, findChildren, getValidChildren, includesChildren, isRefObject, isValidElement, mergeRefs, omitChildren, pickChildren, useAsync, useAsyncFunc, useAsyncRetry, useCallbackRef, useIsMounted, useMergeRefs, useSafeLayoutEffect, useUnmountEffect, useUpdateEffect };
|
package/dist/react.d.ts
CHANGED
|
@@ -87,5 +87,6 @@ declare const useAsyncRetry: <T>(func: () => Promise<T>, deps?: React.Dependency
|
|
|
87
87
|
error?: undefined;
|
|
88
88
|
value: T;
|
|
89
89
|
};
|
|
90
|
+
declare const createId: (prefix: string) => string;
|
|
90
91
|
|
|
91
|
-
export { type AsyncFnReturn, type AsyncState, type AsyncStateRetry, type DOMAttributes, type FunctionReturningPromise, type MaybeRenderProp, type PromiseType, type PropGetter, type RequiredPropGetter, assignRef, createContext, cx, findChildren, getValidChildren, includesChildren, isRefObject, isValidElement, mergeRefs, omitChildren, pickChildren, useAsync, useAsyncFunc, useAsyncRetry, useCallbackRef, useIsMounted, useMergeRefs, useSafeLayoutEffect, useUnmountEffect, useUpdateEffect };
|
|
92
|
+
export { type AsyncFnReturn, type AsyncState, type AsyncStateRetry, type DOMAttributes, type FunctionReturningPromise, type MaybeRenderProp, type PromiseType, type PropGetter, type RequiredPropGetter, assignRef, createContext, createId, cx, findChildren, getValidChildren, includesChildren, isRefObject, isValidElement, mergeRefs, omitChildren, pickChildren, useAsync, useAsyncFunc, useAsyncRetry, useCallbackRef, useIsMounted, useMergeRefs, useSafeLayoutEffect, useUnmountEffect, useUpdateEffect };
|
package/dist/react.js
CHANGED
|
@@ -32,6 +32,7 @@ var react_exports = {};
|
|
|
32
32
|
__export(react_exports, {
|
|
33
33
|
assignRef: () => assignRef,
|
|
34
34
|
createContext: () => createContext2,
|
|
35
|
+
createId: () => createId,
|
|
35
36
|
cx: () => cx,
|
|
36
37
|
findChildren: () => findChildren,
|
|
37
38
|
getValidChildren: () => getValidChildren,
|
|
@@ -209,10 +210,12 @@ var useAsyncRetry = (func, deps = []) => {
|
|
|
209
210
|
}, [...deps, stateLoading]);
|
|
210
211
|
return { ...state, retry };
|
|
211
212
|
};
|
|
213
|
+
var createId = (prefix) => `${prefix}-${(/* @__PURE__ */ new Date()).getTime()}`;
|
|
212
214
|
// Annotate the CommonJS export names for ESM import in node:
|
|
213
215
|
0 && (module.exports = {
|
|
214
216
|
assignRef,
|
|
215
217
|
createContext,
|
|
218
|
+
createId,
|
|
216
219
|
cx,
|
|
217
220
|
findChildren,
|
|
218
221
|
getValidChildren,
|
package/dist/react.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assignRef,
|
|
3
3
|
createContext,
|
|
4
|
+
createId,
|
|
4
5
|
cx,
|
|
5
6
|
findChildren,
|
|
6
7
|
getValidChildren,
|
|
@@ -19,8 +20,9 @@ import {
|
|
|
19
20
|
useSafeLayoutEffect,
|
|
20
21
|
useUnmountEffect,
|
|
21
22
|
useUpdateEffect
|
|
22
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-WYLOTAWH.mjs";
|
|
23
24
|
import "./chunk-SLJ4M7XC.mjs";
|
|
25
|
+
import "./chunk-SAZNI4PK.mjs";
|
|
24
26
|
import "./chunk-VYMGBE25.mjs";
|
|
25
27
|
import "./chunk-BZAW2D6U.mjs";
|
|
26
28
|
import "./chunk-PURW64JE.mjs";
|
|
@@ -31,6 +33,7 @@ import "./chunk-G7Q2EDJF.mjs";
|
|
|
31
33
|
export {
|
|
32
34
|
assignRef,
|
|
33
35
|
createContext,
|
|
36
|
+
createId,
|
|
34
37
|
cx,
|
|
35
38
|
findChildren,
|
|
36
39
|
getValidChildren,
|