@yamada-ui/utils 0.4.0 → 0.4.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.
- package/README.md +1 -1
- package/dist/{chunk-RJN7NAQE.mjs → chunk-IL6ZQBL5.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 +3 -1
- package/dist/function.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -4
- package/dist/index.mjs +5 -1
- package/dist/object.mjs +1 -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 +3 -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,7 +14,7 @@ import {
|
|
|
13
14
|
toneColor,
|
|
14
15
|
toneColors,
|
|
15
16
|
transparentizeColor
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-IL6ZQBL5.mjs";
|
|
17
18
|
import "./chunk-SLJ4M7XC.mjs";
|
|
18
19
|
import "./chunk-VYMGBE25.mjs";
|
|
19
20
|
import "./chunk-BZAW2D6U.mjs";
|
|
@@ -26,6 +27,7 @@ export {
|
|
|
26
27
|
darkenColor,
|
|
27
28
|
getColor,
|
|
28
29
|
hues,
|
|
30
|
+
isAccessible,
|
|
29
31
|
isDark,
|
|
30
32
|
isGray,
|
|
31
33
|
isLight,
|
package/dist/function.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -2,11 +2,11 @@ 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';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ 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';
|
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,7 @@ __export(src_exports, {
|
|
|
68
69
|
hasTabIndex: () => hasTabIndex,
|
|
69
70
|
hues: () => hues,
|
|
70
71
|
includesChildren: () => includesChildren,
|
|
72
|
+
isAccessible: () => isAccessible,
|
|
71
73
|
isActiveElement: () => isActiveElement,
|
|
72
74
|
isApple: () => isApple,
|
|
73
75
|
isArray: () => isArray,
|
|
@@ -455,6 +457,7 @@ var useAsyncRetry = (func, deps = []) => {
|
|
|
455
457
|
}, [...deps, stateLoading]);
|
|
456
458
|
return { ...state, retry };
|
|
457
459
|
};
|
|
460
|
+
var createId = (prefix) => `${prefix}-${(/* @__PURE__ */ new Date()).getTime()}`;
|
|
458
461
|
|
|
459
462
|
// src/dom.ts
|
|
460
463
|
var createdDom = () => !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
@@ -584,7 +587,6 @@ var calc = Object.assign(
|
|
|
584
587
|
|
|
585
588
|
// src/color.ts
|
|
586
589
|
var import_color2k = require("color2k");
|
|
587
|
-
var coef = 0.75;
|
|
588
590
|
var hues = [
|
|
589
591
|
50,
|
|
590
592
|
100,
|
|
@@ -599,6 +601,7 @@ var hues = [
|
|
|
599
601
|
950
|
|
600
602
|
];
|
|
601
603
|
var isGray = (colorScheme) => colorScheme === "gray" || colorScheme === "neutral";
|
|
604
|
+
var isAccessible = (colorScheme) => colorScheme === "yellow" || colorScheme === "cyan" || colorScheme === "lime";
|
|
602
605
|
var getColor = (color, fallback) => (theme = {}, colorMode) => {
|
|
603
606
|
var _a, _b, _c;
|
|
604
607
|
const [token, hue] = color.split(".");
|
|
@@ -628,7 +631,7 @@ var darkenColor = (color, amount) => (theme, colorMode) => {
|
|
|
628
631
|
};
|
|
629
632
|
var tintColor = (color, amount) => (theme, colorMode) => {
|
|
630
633
|
const raw = getColor(color, color)(theme, colorMode);
|
|
631
|
-
return (0, import_color2k.toHex)((0, import_color2k.mix)(raw, "#fff", amount));
|
|
634
|
+
return (0, import_color2k.toHex)((0, import_color2k.mix)(raw, "#fff", amount / 100));
|
|
632
635
|
};
|
|
633
636
|
var shadeColor = (color, amount) => (theme, colorMode) => {
|
|
634
637
|
const raw = getColor(color, color)(theme, colorMode);
|
|
@@ -638,18 +641,20 @@ var transparentizeColor = (color, alpha) => (theme, colorMode) => {
|
|
|
638
641
|
const raw = getColor(color, color)(theme, colorMode);
|
|
639
642
|
return (0, import_color2k.transparentize)(raw, 1 - alpha);
|
|
640
643
|
};
|
|
641
|
-
var toneColor = (color, hue) => (theme, colorMode) => {
|
|
644
|
+
var toneColor = (color, hue, lCoef = 0.94, dCoef = 0.86) => (theme, colorMode) => {
|
|
642
645
|
if (hue < 50 || 950 < hue)
|
|
643
646
|
return color;
|
|
644
647
|
let raw = color;
|
|
645
648
|
if (theme && colorMode)
|
|
646
649
|
getColor(color, color)(theme, colorMode);
|
|
650
|
+
const coef = hue < 500 ? lCoef : dCoef;
|
|
647
651
|
const amount = (500 - hue) * 1e-3 * coef;
|
|
648
652
|
return (0, import_color2k.toHex)((0, import_color2k.lighten)(raw, amount));
|
|
649
653
|
};
|
|
650
|
-
var toneColors = (color) => {
|
|
654
|
+
var toneColors = (color, lCoef = 0.94, dCoef = 0.86) => {
|
|
651
655
|
const colors = {};
|
|
652
656
|
hues.forEach((hue) => {
|
|
657
|
+
const coef = hue < 500 ? lCoef : dCoef;
|
|
653
658
|
const amount = (500 - hue) * 1e-3 * coef;
|
|
654
659
|
colors[hue] = (0, import_color2k.toHex)((0, import_color2k.lighten)(color, amount));
|
|
655
660
|
});
|
|
@@ -794,6 +799,7 @@ var addPointerEvent = (target, type, cb, options) => addDomEvent(target, type, w
|
|
|
794
799
|
clampNumber,
|
|
795
800
|
countDecimal,
|
|
796
801
|
createContext,
|
|
802
|
+
createId,
|
|
797
803
|
createdDom,
|
|
798
804
|
cx,
|
|
799
805
|
darkenColor,
|
|
@@ -822,6 +828,7 @@ var addPointerEvent = (target, type, cb, options) => addDomEvent(target, type, w
|
|
|
822
828
|
hasTabIndex,
|
|
823
829
|
hues,
|
|
824
830
|
includesChildren,
|
|
831
|
+
isAccessible,
|
|
825
832
|
isActiveElement,
|
|
826
833
|
isApple,
|
|
827
834
|
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,7 +53,7 @@ import {
|
|
|
51
53
|
useSafeLayoutEffect,
|
|
52
54
|
useUnmountEffect,
|
|
53
55
|
useUpdateEffect
|
|
54
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-IL6ZQBL5.mjs";
|
|
55
57
|
import "./chunk-SLJ4M7XC.mjs";
|
|
56
58
|
import {
|
|
57
59
|
clampNumber,
|
|
@@ -133,6 +135,7 @@ export {
|
|
|
133
135
|
clampNumber,
|
|
134
136
|
countDecimal,
|
|
135
137
|
createContext,
|
|
138
|
+
createId,
|
|
136
139
|
createdDom,
|
|
137
140
|
cx,
|
|
138
141
|
darkenColor,
|
|
@@ -161,6 +164,7 @@ export {
|
|
|
161
164
|
hasTabIndex,
|
|
162
165
|
hues,
|
|
163
166
|
includesChildren,
|
|
167
|
+
isAccessible,
|
|
164
168
|
isActiveElement,
|
|
165
169
|
isApple,
|
|
166
170
|
isArray,
|
package/dist/object.mjs
CHANGED
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,7 +20,7 @@ import {
|
|
|
19
20
|
useSafeLayoutEffect,
|
|
20
21
|
useUnmountEffect,
|
|
21
22
|
useUpdateEffect
|
|
22
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-IL6ZQBL5.mjs";
|
|
23
24
|
import "./chunk-SLJ4M7XC.mjs";
|
|
24
25
|
import "./chunk-VYMGBE25.mjs";
|
|
25
26
|
import "./chunk-BZAW2D6U.mjs";
|
|
@@ -31,6 +32,7 @@ import "./chunk-G7Q2EDJF.mjs";
|
|
|
31
32
|
export {
|
|
32
33
|
assignRef,
|
|
33
34
|
createContext,
|
|
35
|
+
createId,
|
|
34
36
|
cx,
|
|
35
37
|
findChildren,
|
|
36
38
|
getValidChildren,
|