@yamada-ui/utils 0.3.3 → 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 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
- ## Licence
27
+ ## License
28
28
 
29
29
  This package is licensed under the terms of the
30
30
 
package/dist/calc.d.mts CHANGED
@@ -14,4 +14,4 @@ declare const calc: ((x: Operand) => Calc) & {
14
14
  negate: (value: Operand) => string;
15
15
  };
16
16
 
17
- export { Operand, calc };
17
+ export { type Operand, calc };
package/dist/calc.d.ts CHANGED
@@ -14,4 +14,4 @@ declare const calc: ((x: Operand) => Calc) & {
14
14
  negate: (value: Operand) => string;
15
15
  };
16
16
 
17
- export { Operand, calc };
17
+ export { type Operand, calc };
@@ -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 {
@@ -193,7 +194,8 @@ var hues = [
193
194
  900,
194
195
  950
195
196
  ];
196
- var isGray = (colorScheme) => colorScheme === "gray" || colorScheme === "zinc" || colorScheme === "neutral" || colorScheme === "stone";
197
+ var isGray = (colorScheme) => colorScheme === "gray" || colorScheme === "neutral";
198
+ var isAccessible = (colorScheme) => colorScheme === "yellow" || colorScheme === "cyan" || colorScheme === "lime";
197
199
  var getColor = (color, fallback) => (theme = {}, colorMode) => {
198
200
  var _a, _b, _c;
199
201
  const [token, hue] = color.split(".");
@@ -223,7 +225,7 @@ var darkenColor = (color, amount) => (theme, colorMode) => {
223
225
  };
224
226
  var tintColor = (color, amount) => (theme, colorMode) => {
225
227
  const raw = getColor(color, color)(theme, colorMode);
226
- return toHex(mix(raw, "#fff", amount));
228
+ return toHex(mix(raw, "#fff", amount / 100));
227
229
  };
228
230
  var shadeColor = (color, amount) => (theme, colorMode) => {
229
231
  const raw = getColor(color, color)(theme, colorMode);
@@ -233,17 +235,24 @@ var transparentizeColor = (color, alpha) => (theme, colorMode) => {
233
235
  const raw = getColor(color, color)(theme, colorMode);
234
236
  return transparentize(raw, 1 - alpha);
235
237
  };
236
- var toneColor = (color, hue) => (theme, colorMode) => {
237
- const raw = getColor(color, color)(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
- let n = (hue - 500) / 10;
241
- const isLighten = n <= 0;
242
- if (isLighten)
243
- n *= -1;
244
- if (n !== 0)
245
- n = n - 5 * (isLighten ? 1 : -1);
246
- return toHex(isLighten ? lighten(raw, n / 100) : mix(raw, "#000", n / 100));
241
+ let raw = color;
242
+ if (theme && colorMode)
243
+ getColor(color, color)(theme, colorMode);
244
+ const coef = hue < 500 ? lCoef : dCoef;
245
+ const amount = (500 - hue) * 1e-3 * coef;
246
+ return toHex(lighten(raw, amount));
247
+ };
248
+ var toneColors = (color, lCoef = 0.94, dCoef = 0.86) => {
249
+ const colors = {};
250
+ hues.forEach((hue) => {
251
+ const coef = hue < 500 ? lCoef : dCoef;
252
+ const amount = (500 - hue) * 1e-3 * coef;
253
+ colors[hue] = toHex(lighten(color, amount));
254
+ });
255
+ return colors;
247
256
  };
248
257
  var randomColor = ({
249
258
  string,
@@ -404,9 +413,8 @@ var getObject = (obj, path, fallback, i) => {
404
413
  var memoizeObject = (func) => {
405
414
  const cache = /* @__PURE__ */ new WeakMap();
406
415
  const memoizedFunc = (obj, path, fallback, i) => {
407
- if (typeof obj === "undefined") {
416
+ if (typeof obj === "undefined")
408
417
  return func(obj, path, fallback);
409
- }
410
418
  if (!cache.has(obj))
411
419
  cache.set(obj, /* @__PURE__ */ new Map());
412
420
  const map = cache.get(obj);
@@ -476,8 +484,10 @@ export {
476
484
  useAsync,
477
485
  useAsyncFunc,
478
486
  useAsyncRetry,
487
+ createId,
479
488
  hues,
480
489
  isGray,
490
+ isAccessible,
481
491
  getColor,
482
492
  lightenColor,
483
493
  darkenColor,
@@ -485,6 +495,7 @@ export {
485
495
  shadeColor,
486
496
  transparentizeColor,
487
497
  toneColor,
498
+ toneColors,
488
499
  randomColor,
489
500
  isTone,
490
501
  isLight,
package/dist/color.d.mts CHANGED
@@ -1,15 +1,17 @@
1
1
  import { Dict } from './index.types.mjs';
2
2
 
3
- type ColorMode = 'light' | 'dark';
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 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>;
13
15
  declare const randomColor: ({ string, colors, }?: {
14
16
  string?: string | undefined;
15
17
  colors?: string[] | undefined;
@@ -18,4 +20,4 @@ declare const isTone: (color: string) => (theme?: Dict, colorMode?: ColorMode) =
18
20
  declare const isLight: (color: string) => (theme?: Dict, colorMode?: ColorMode) => boolean;
19
21
  declare const isDark: (color: string) => (theme?: Dict, colorMode?: ColorMode) => boolean;
20
22
 
21
- export { darkenColor, getColor, hues, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, transparentizeColor };
23
+ export { darkenColor, getColor, hues, isAccessible, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, toneColors, transparentizeColor };
package/dist/color.d.ts CHANGED
@@ -1,15 +1,17 @@
1
1
  import { Dict } from './index.types.js';
2
2
 
3
- type ColorMode = 'light' | 'dark';
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 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>;
13
15
  declare const randomColor: ({ string, colors, }?: {
14
16
  string?: string | undefined;
15
17
  colors?: string[] | undefined;
@@ -18,4 +20,4 @@ declare const isTone: (color: string) => (theme?: Dict, colorMode?: ColorMode) =
18
20
  declare const isLight: (color: string) => (theme?: Dict, colorMode?: ColorMode) => boolean;
19
21
  declare const isDark: (color: string) => (theme?: Dict, colorMode?: ColorMode) => boolean;
20
22
 
21
- export { darkenColor, getColor, hues, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, 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,
@@ -32,6 +33,7 @@ __export(color_exports, {
32
33
  shadeColor: () => shadeColor,
33
34
  tintColor: () => tintColor,
34
35
  toneColor: () => toneColor,
36
+ toneColors: () => toneColors,
35
37
  transparentizeColor: () => transparentizeColor
36
38
  });
37
39
  module.exports = __toCommonJS(color_exports);
@@ -53,9 +55,8 @@ var getObject = (obj, path, fallback, i) => {
53
55
  var memoizeObject = (func) => {
54
56
  const cache = /* @__PURE__ */ new WeakMap();
55
57
  const memoizedFunc = (obj, path, fallback, i) => {
56
- if (typeof obj === "undefined") {
58
+ if (typeof obj === "undefined")
57
59
  return func(obj, path, fallback);
58
- }
59
60
  if (!cache.has(obj))
60
61
  cache.set(obj, /* @__PURE__ */ new Map());
61
62
  const map = cache.get(obj);
@@ -83,7 +84,8 @@ var hues = [
83
84
  900,
84
85
  950
85
86
  ];
86
- var isGray = (colorScheme) => colorScheme === "gray" || colorScheme === "zinc" || colorScheme === "neutral" || colorScheme === "stone";
87
+ var isGray = (colorScheme) => colorScheme === "gray" || colorScheme === "neutral";
88
+ var isAccessible = (colorScheme) => colorScheme === "yellow" || colorScheme === "cyan" || colorScheme === "lime";
87
89
  var getColor = (color, fallback) => (theme = {}, colorMode) => {
88
90
  var _a, _b, _c;
89
91
  const [token, hue] = color.split(".");
@@ -113,7 +115,7 @@ var darkenColor = (color, amount) => (theme, colorMode) => {
113
115
  };
114
116
  var tintColor = (color, amount) => (theme, colorMode) => {
115
117
  const raw = getColor(color, color)(theme, colorMode);
116
- 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));
117
119
  };
118
120
  var shadeColor = (color, amount) => (theme, colorMode) => {
119
121
  const raw = getColor(color, color)(theme, colorMode);
@@ -123,17 +125,24 @@ var transparentizeColor = (color, alpha) => (theme, colorMode) => {
123
125
  const raw = getColor(color, color)(theme, colorMode);
124
126
  return (0, import_color2k.transparentize)(raw, 1 - alpha);
125
127
  };
126
- var toneColor = (color, hue) => (theme, colorMode) => {
127
- const raw = getColor(color, color)(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
- let n = (hue - 500) / 10;
131
- const isLighten = n <= 0;
132
- if (isLighten)
133
- n *= -1;
134
- if (n !== 0)
135
- n = n - 5 * (isLighten ? 1 : -1);
136
- return (0, import_color2k.toHex)(isLighten ? (0, import_color2k.lighten)(raw, n / 100) : (0, import_color2k.mix)(raw, "#000", n / 100));
131
+ let raw = color;
132
+ if (theme && colorMode)
133
+ getColor(color, color)(theme, colorMode);
134
+ const coef = hue < 500 ? lCoef : dCoef;
135
+ const amount = (500 - hue) * 1e-3 * coef;
136
+ return (0, import_color2k.toHex)((0, import_color2k.lighten)(raw, amount));
137
+ };
138
+ var toneColors = (color, lCoef = 0.94, dCoef = 0.86) => {
139
+ const colors = {};
140
+ hues.forEach((hue) => {
141
+ const coef = hue < 500 ? lCoef : dCoef;
142
+ const amount = (500 - hue) * 1e-3 * coef;
143
+ colors[hue] = (0, import_color2k.toHex)((0, import_color2k.lighten)(color, amount));
144
+ });
145
+ return colors;
137
146
  };
138
147
  var randomColor = ({
139
148
  string,
@@ -193,6 +202,7 @@ var isDark = (color) => (theme, colorMode) => isTone(color)(theme, colorMode) ==
193
202
  darkenColor,
194
203
  getColor,
195
204
  hues,
205
+ isAccessible,
196
206
  isDark,
197
207
  isGray,
198
208
  isLight,
@@ -202,5 +212,6 @@ var isDark = (color) => (theme, colorMode) => isTone(color)(theme, colorMode) ==
202
212
  shadeColor,
203
213
  tintColor,
204
214
  toneColor,
215
+ toneColors,
205
216
  transparentizeColor
206
217
  });
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,
@@ -11,8 +12,9 @@ import {
11
12
  shadeColor,
12
13
  tintColor,
13
14
  toneColor,
15
+ toneColors,
14
16
  transparentizeColor
15
- } from "./chunk-5OQGKXOK.mjs";
17
+ } from "./chunk-IL6ZQBL5.mjs";
16
18
  import "./chunk-SLJ4M7XC.mjs";
17
19
  import "./chunk-VYMGBE25.mjs";
18
20
  import "./chunk-BZAW2D6U.mjs";
@@ -25,6 +27,7 @@ export {
25
27
  darkenColor,
26
28
  getColor,
27
29
  hues,
30
+ isAccessible,
28
31
  isDark,
29
32
  isGray,
30
33
  isLight,
@@ -34,5 +37,6 @@ export {
34
37
  shadeColor,
35
38
  tintColor,
36
39
  toneColor,
40
+ toneColors,
37
41
  transparentizeColor
38
42
  };
package/dist/dom.d.mts CHANGED
@@ -15,7 +15,7 @@ declare const hasTabIndex: (el: HTMLElement) => boolean;
15
15
  declare const isContentEditable: (el: HTMLElement) => boolean;
16
16
  declare const isContains: (parent: HTMLElement | null, child: HTMLElement | null) => boolean | undefined;
17
17
  declare const getEventRelatedTarget: (ev: React__default.FocusEvent | React__default.MouseEvent) => HTMLElement | null;
18
- type Booleanish = boolean | 'true' | 'false';
18
+ type Booleanish = boolean | "true" | "false";
19
19
  declare const dataAttr: (condition: boolean | undefined) => Booleanish;
20
20
  declare const ariaAttr: (condition: boolean | undefined) => boolean | undefined;
21
21
  type FocusableElement = {
@@ -30,4 +30,4 @@ declare const getOwnerDocument: (el?: Element | null) => Document;
30
30
  declare const getActiveElement: (el?: HTMLElement) => HTMLElement;
31
31
  declare const isActiveElement: (el: HTMLElement) => boolean;
32
32
 
33
- 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 };
33
+ export { type 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 };
package/dist/dom.d.ts CHANGED
@@ -15,7 +15,7 @@ declare const hasTabIndex: (el: HTMLElement) => boolean;
15
15
  declare const isContentEditable: (el: HTMLElement) => boolean;
16
16
  declare const isContains: (parent: HTMLElement | null, child: HTMLElement | null) => boolean | undefined;
17
17
  declare const getEventRelatedTarget: (ev: React__default.FocusEvent | React__default.MouseEvent) => HTMLElement | null;
18
- type Booleanish = boolean | 'true' | 'false';
18
+ type Booleanish = boolean | "true" | "false";
19
19
  declare const dataAttr: (condition: boolean | undefined) => Booleanish;
20
20
  declare const ariaAttr: (condition: boolean | undefined) => boolean | undefined;
21
21
  type FocusableElement = {
@@ -30,4 +30,4 @@ declare const getOwnerDocument: (el?: Element | null) => Document;
30
30
  declare const getActiveElement: (el?: HTMLElement) => HTMLElement;
31
31
  declare const isActiveElement: (el: HTMLElement) => boolean;
32
32
 
33
- 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 };
33
+ export { type 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 };
package/dist/event.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  type AnyPointerEvent = MouseEvent | TouchEvent | PointerEvent;
2
- type PointType = 'page' | 'client';
2
+ type PointType = "page" | "client";
3
3
  type Point = {
4
4
  x: number;
5
5
  y: number;
@@ -27,4 +27,4 @@ declare const getEventPoint: (ev: AnyPointerEvent, type?: PointType) => {
27
27
  declare const addDomEvent: (target: EventTarget, type: string, cb: EventListener, options?: AddEventListenerOptions) => () => void;
28
28
  declare const addPointerEvent: (target: EventTarget, type: string, cb: MixedEventListener, options?: AddEventListenerOptions) => () => void;
29
29
 
30
- export { AnyPointerEvent, MixedEventListener, Point, PointType, PointerEventInfo, addDomEvent, addPointerEvent, getEventPoint, getEventWindow, isMouseEvent, isMultiTouchEvent, isTouchEvent, pointFromMouse, pointFromTouch };
30
+ export { type AnyPointerEvent, type MixedEventListener, type Point, type PointType, type PointerEventInfo, addDomEvent, addPointerEvent, getEventPoint, getEventWindow, isMouseEvent, isMultiTouchEvent, isTouchEvent, pointFromMouse, pointFromTouch };
package/dist/event.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  type AnyPointerEvent = MouseEvent | TouchEvent | PointerEvent;
2
- type PointType = 'page' | 'client';
2
+ type PointType = "page" | "client";
3
3
  type Point = {
4
4
  x: number;
5
5
  y: number;
@@ -27,4 +27,4 @@ declare const getEventPoint: (ev: AnyPointerEvent, type?: PointType) => {
27
27
  declare const addDomEvent: (target: EventTarget, type: string, cb: EventListener, options?: AddEventListenerOptions) => () => void;
28
28
  declare const addPointerEvent: (target: EventTarget, type: string, cb: MixedEventListener, options?: AddEventListenerOptions) => () => void;
29
29
 
30
- export { AnyPointerEvent, MixedEventListener, Point, PointType, PointerEventInfo, addDomEvent, addPointerEvent, getEventPoint, getEventWindow, isMouseEvent, isMultiTouchEvent, isTouchEvent, pointFromMouse, pointFromTouch };
30
+ export { type AnyPointerEvent, type MixedEventListener, type Point, type PointType, type PointerEventInfo, addDomEvent, addPointerEvent, getEventPoint, getEventWindow, isMouseEvent, isMultiTouchEvent, isTouchEvent, pointFromMouse, pointFromTouch };
package/dist/function.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  handlerAll,
4
4
  noop,
5
5
  runIfFunc
6
- } from "./chunk-5OQGKXOK.mjs";
6
+ } from "./chunk-IL6ZQBL5.mjs";
7
7
  import "./chunk-SLJ4M7XC.mjs";
8
8
  import "./chunk-VYMGBE25.mjs";
9
9
  import "./chunk-BZAW2D6U.mjs";
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, 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, 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,
@@ -124,6 +126,7 @@ __export(src_exports, {
124
126
  tintColor: () => tintColor,
125
127
  toPrecision: () => toPrecision,
126
128
  toneColor: () => toneColor,
129
+ toneColors: () => toneColors,
127
130
  transparentizeColor: () => transparentizeColor,
128
131
  useAsync: () => useAsync,
129
132
  useAsyncFunc: () => useAsyncFunc,
@@ -258,9 +261,8 @@ var getObject = (obj, path, fallback, i) => {
258
261
  var memoizeObject = (func) => {
259
262
  const cache = /* @__PURE__ */ new WeakMap();
260
263
  const memoizedFunc = (obj, path, fallback, i) => {
261
- if (typeof obj === "undefined") {
264
+ if (typeof obj === "undefined")
262
265
  return func(obj, path, fallback);
263
- }
264
266
  if (!cache.has(obj))
265
267
  cache.set(obj, /* @__PURE__ */ new Map());
266
268
  const map = cache.get(obj);
@@ -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);
@@ -597,7 +600,8 @@ var hues = [
597
600
  900,
598
601
  950
599
602
  ];
600
- var isGray = (colorScheme) => colorScheme === "gray" || colorScheme === "zinc" || colorScheme === "neutral" || colorScheme === "stone";
603
+ var isGray = (colorScheme) => colorScheme === "gray" || colorScheme === "neutral";
604
+ var isAccessible = (colorScheme) => colorScheme === "yellow" || colorScheme === "cyan" || colorScheme === "lime";
601
605
  var getColor = (color, fallback) => (theme = {}, colorMode) => {
602
606
  var _a, _b, _c;
603
607
  const [token, hue] = color.split(".");
@@ -627,7 +631,7 @@ var darkenColor = (color, amount) => (theme, colorMode) => {
627
631
  };
628
632
  var tintColor = (color, amount) => (theme, colorMode) => {
629
633
  const raw = getColor(color, color)(theme, colorMode);
630
- 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));
631
635
  };
632
636
  var shadeColor = (color, amount) => (theme, colorMode) => {
633
637
  const raw = getColor(color, color)(theme, colorMode);
@@ -637,17 +641,24 @@ var transparentizeColor = (color, alpha) => (theme, colorMode) => {
637
641
  const raw = getColor(color, color)(theme, colorMode);
638
642
  return (0, import_color2k.transparentize)(raw, 1 - alpha);
639
643
  };
640
- var toneColor = (color, hue) => (theme, colorMode) => {
641
- const raw = getColor(color, color)(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
- let n = (hue - 500) / 10;
645
- const isLighten = n <= 0;
646
- if (isLighten)
647
- n *= -1;
648
- if (n !== 0)
649
- n = n - 5 * (isLighten ? 1 : -1);
650
- return (0, import_color2k.toHex)(isLighten ? (0, import_color2k.lighten)(raw, n / 100) : (0, import_color2k.mix)(raw, "#000", n / 100));
647
+ let raw = color;
648
+ if (theme && colorMode)
649
+ getColor(color, color)(theme, colorMode);
650
+ const coef = hue < 500 ? lCoef : dCoef;
651
+ const amount = (500 - hue) * 1e-3 * coef;
652
+ return (0, import_color2k.toHex)((0, import_color2k.lighten)(raw, amount));
653
+ };
654
+ var toneColors = (color, lCoef = 0.94, dCoef = 0.86) => {
655
+ const colors = {};
656
+ hues.forEach((hue) => {
657
+ const coef = hue < 500 ? lCoef : dCoef;
658
+ const amount = (500 - hue) * 1e-3 * coef;
659
+ colors[hue] = (0, import_color2k.toHex)((0, import_color2k.lighten)(color, amount));
660
+ });
661
+ return colors;
651
662
  };
652
663
  var randomColor = ({
653
664
  string,
@@ -788,6 +799,7 @@ var addPointerEvent = (target, type, cb, options) => addDomEvent(target, type, w
788
799
  clampNumber,
789
800
  countDecimal,
790
801
  createContext,
802
+ createId,
791
803
  createdDom,
792
804
  cx,
793
805
  darkenColor,
@@ -816,6 +828,7 @@ var addPointerEvent = (target, type, cb, options) => addDomEvent(target, type, w
816
828
  hasTabIndex,
817
829
  hues,
818
830
  includesChildren,
831
+ isAccessible,
819
832
  isActiveElement,
820
833
  isApple,
821
834
  isArray,
@@ -872,6 +885,7 @@ var addPointerEvent = (target, type, cb, options) => addDomEvent(target, type, w
872
885
  tintColor,
873
886
  toPrecision,
874
887
  toneColor,
888
+ toneColors,
875
889
  transparentizeColor,
876
890
  useAsync,
877
891
  useAsyncFunc,
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,
@@ -40,6 +42,7 @@ import {
40
42
  splitObject,
41
43
  tintColor,
42
44
  toneColor,
45
+ toneColors,
43
46
  transparentizeColor,
44
47
  useAsync,
45
48
  useAsyncFunc,
@@ -50,7 +53,7 @@ import {
50
53
  useSafeLayoutEffect,
51
54
  useUnmountEffect,
52
55
  useUpdateEffect
53
- } from "./chunk-5OQGKXOK.mjs";
56
+ } from "./chunk-IL6ZQBL5.mjs";
54
57
  import "./chunk-SLJ4M7XC.mjs";
55
58
  import {
56
59
  clampNumber,
@@ -132,6 +135,7 @@ export {
132
135
  clampNumber,
133
136
  countDecimal,
134
137
  createContext,
138
+ createId,
135
139
  createdDom,
136
140
  cx,
137
141
  darkenColor,
@@ -160,6 +164,7 @@ export {
160
164
  hasTabIndex,
161
165
  hues,
162
166
  includesChildren,
167
+ isAccessible,
163
168
  isActiveElement,
164
169
  isApple,
165
170
  isArray,
@@ -216,6 +221,7 @@ export {
216
221
  tintColor,
217
222
  toPrecision,
218
223
  toneColor,
224
+ toneColors,
219
225
  transparentizeColor,
220
226
  useAsync,
221
227
  useAsyncFunc,
@@ -11,4 +11,4 @@ type Merge<T extends object> = {
11
11
  [K in keyof T]: T[K];
12
12
  };
13
13
 
14
- export { Dict, Length, Merge, Path, Primitive, StringLiteral, Union };
14
+ export type { Dict, Length, Merge, Path, Primitive, StringLiteral, Union };
@@ -11,4 +11,4 @@ type Merge<T extends object> = {
11
11
  [K in keyof T]: T[K];
12
12
  };
13
13
 
14
- export { Dict, Length, Merge, Path, Primitive, StringLiteral, Union };
14
+ export type { Dict, Length, Merge, Path, Primitive, StringLiteral, Union };
package/dist/object.js CHANGED
@@ -147,9 +147,8 @@ var getObject = (obj, path, fallback, i) => {
147
147
  var memoizeObject = (func) => {
148
148
  const cache = /* @__PURE__ */ new WeakMap();
149
149
  const memoizedFunc = (obj, path, fallback, i) => {
150
- if (typeof obj === "undefined") {
150
+ if (typeof obj === "undefined")
151
151
  return func(obj, path, fallback);
152
- }
153
152
  if (!cache.has(obj))
154
153
  cache.set(obj, /* @__PURE__ */ new Map());
155
154
  const map = cache.get(obj);
package/dist/object.mjs CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  pickObject,
14
14
  replaceObject,
15
15
  splitObject
16
- } from "./chunk-5OQGKXOK.mjs";
16
+ } from "./chunk-IL6ZQBL5.mjs";
17
17
  import "./chunk-SLJ4M7XC.mjs";
18
18
  import "./chunk-VYMGBE25.mjs";
19
19
  import "./chunk-BZAW2D6U.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 { 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 };
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 { 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 };
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-5OQGKXOK.mjs";
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yamada-ui/utils",
3
- "version": "0.3.3",
3
+ "version": "0.4.1",
4
4
  "description": "Yamada UI utils",
5
5
  "keywords": [
6
6
  "utils",