@yamada-ui/utils 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/assertion.js CHANGED
@@ -40,9 +40,9 @@ var isNumeric = (value) => value != null && parseFloat(value.toString()) - parse
40
40
  var isString = (value) => Object.prototype.toString.call(value) === "[object String]";
41
41
  var isUndefined = (value) => typeof value === "undefined" && value === void 0;
42
42
  var isNull = (value) => value === null;
43
- var isObject = (value) => value !== null && (typeof value === "object" || typeof value === "function") && !Array.isArray(value);
43
+ var isObject = (value) => value !== null && (typeof value === "object" || typeof value === "function") && !isArray(value);
44
44
  var isArray = (value) => Array.isArray(value);
45
- var isEmpty = (value) => !Array.isArray(value) || !value.length || value.every((v) => v == null);
45
+ var isEmpty = (value) => !isArray(value) || !value.length || value.every((v) => v == null);
46
46
  var isFunction = (value) => typeof value === "function";
47
47
  var isUnit = (value) => /[0-9].*[px|rem|em|%|vw|vh]$/.test(value);
48
48
  var cast = (value) => value;
@@ -11,7 +11,7 @@ import {
11
11
  isString,
12
12
  isUndefined,
13
13
  isUnit
14
- } from "./chunk-IVGIIDMV.mjs";
14
+ } from "./chunk-BU4LEFZY.mjs";
15
15
  export {
16
16
  cast,
17
17
  isArray,
@@ -5,9 +5,9 @@ var isNumeric = (value) => value != null && parseFloat(value.toString()) - parse
5
5
  var isString = (value) => Object.prototype.toString.call(value) === "[object String]";
6
6
  var isUndefined = (value) => typeof value === "undefined" && value === void 0;
7
7
  var isNull = (value) => value === null;
8
- var isObject = (value) => value !== null && (typeof value === "object" || typeof value === "function") && !Array.isArray(value);
8
+ var isObject = (value) => value !== null && (typeof value === "object" || typeof value === "function") && !isArray(value);
9
9
  var isArray = (value) => Array.isArray(value);
10
- var isEmpty = (value) => !Array.isArray(value) || !value.length || value.every((v) => v == null);
10
+ var isEmpty = (value) => !isArray(value) || !value.length || value.every((v) => v == null);
11
11
  var isFunction = (value) => typeof value === "function";
12
12
  var isUnit = (value) => /[0-9].*[px|rem|em|%|vw|vh]$/.test(value);
13
13
  var cast = (value) => value;
@@ -26,13 +26,13 @@ var addDomEvent = (target, type, cb, options) => {
26
26
  target.removeEventListener(type, cb, options);
27
27
  };
28
28
  };
29
- var filter = (cb) => (event) => {
30
- const isMouse = isMouseEvent(event);
31
- if (!isMouse || isMouse && event.button === 0)
32
- cb(event);
29
+ var filter = (cb) => (ev) => {
30
+ const isMouse = isMouseEvent(ev);
31
+ if (!isMouse || isMouse && ev.button === 0)
32
+ cb(ev);
33
33
  };
34
34
  var wrap = (cb, filterPrimary = false) => {
35
- const listener = (event) => cb(event, { point: getEventPoint(event) });
35
+ const listener = (ev) => cb(ev, { point: getEventPoint(ev) });
36
36
  const fn = filterPrimary ? filter(listener) : listener;
37
37
  return fn;
38
38
  };
@@ -4,7 +4,7 @@ import {
4
4
  isNumber,
5
5
  isObject,
6
6
  isString
7
- } from "./chunk-IVGIIDMV.mjs";
7
+ } from "./chunk-BU4LEFZY.mjs";
8
8
 
9
9
  // src/function.ts
10
10
  var noop = () => {
@@ -180,13 +180,32 @@ import {
180
180
  darken,
181
181
  lighten
182
182
  } from "color2k";
183
+ var hues = [
184
+ 50,
185
+ 100,
186
+ 200,
187
+ 300,
188
+ 400,
189
+ 500,
190
+ 600,
191
+ 700,
192
+ 800,
193
+ 900,
194
+ 950
195
+ ];
183
196
  var isGray = (colorScheme) => colorScheme === "gray" || colorScheme === "zinc" || colorScheme === "neutral" || colorScheme === "stone";
184
- var getColor = (color, fallback) => (theme, colorMode) => {
197
+ var getColor = (color, fallback) => (theme = {}, colorMode) => {
198
+ var _a, _b, _c;
199
+ const [token, hue] = color.split(".");
200
+ const [, relatedToken] = (_c = Object.entries((_b = (_a = theme.semantics) == null ? void 0 : _a.colorSchemes) != null ? _b : {}).find(
201
+ ([semanticToken]) => token === semanticToken
202
+ )) != null ? _c : [];
203
+ if (relatedToken)
204
+ color = `${relatedToken}.${hue}`;
185
205
  const hex = getMemoizedObject(theme, `colors.${color}`, color);
186
206
  try {
187
207
  if (isArray(hex)) {
188
- const [lightHex, darkHex] = hex;
189
- return toHex(String(colorMode !== "dark" ? lightHex : darkHex));
208
+ return toHex(String(colorMode !== "dark" ? hex[0] : hex[1]));
190
209
  } else {
191
210
  return toHex(String(hex));
192
211
  }
@@ -195,30 +214,30 @@ var getColor = (color, fallback) => (theme, colorMode) => {
195
214
  }
196
215
  };
197
216
  var lightenColor = (color, amount) => (theme, colorMode) => {
198
- const raw = theme ? getColor(color)(theme, colorMode) : color;
217
+ const raw = getColor(color, color)(theme, colorMode);
199
218
  return toHex(lighten(raw, amount / 100));
200
219
  };
201
220
  var darkenColor = (color, amount) => (theme, colorMode) => {
202
- const raw = theme ? getColor(color)(theme, colorMode) : color;
221
+ const raw = getColor(color, color)(theme, colorMode);
203
222
  return toHex(darken(raw, amount / 100));
204
223
  };
205
224
  var tintColor = (color, amount) => (theme, colorMode) => {
206
- const raw = theme ? getColor(color)(theme, colorMode) : color;
225
+ const raw = getColor(color, color)(theme, colorMode);
207
226
  return toHex(mix(raw, "#fff", amount));
208
227
  };
209
228
  var shadeColor = (color, amount) => (theme, colorMode) => {
210
- const raw = theme ? getColor(color)(theme, colorMode) : color;
229
+ const raw = getColor(color, color)(theme, colorMode);
211
230
  return toHex(mix(raw, "#000", amount / 100));
212
231
  };
213
232
  var transparentizeColor = (color, alpha) => (theme, colorMode) => {
214
- const raw = theme ? getColor(color)(theme, colorMode) : color;
233
+ const raw = getColor(color, color)(theme, colorMode);
215
234
  return transparentize(raw, 1 - alpha);
216
235
  };
217
- var toneColor = (color, l) => (theme, colorMode) => {
218
- const raw = theme ? getColor(color)(theme, colorMode) : color;
219
- if (l < 0 || 900 < l)
236
+ var toneColor = (color, hue) => (theme, colorMode) => {
237
+ const raw = getColor(color, color)(theme, colorMode);
238
+ if (hue < 50 || 950 < hue)
220
239
  return color;
221
- let n = (l - 500) / 10;
240
+ let n = (hue - 500) / 10;
222
241
  const isLighten = n <= 0;
223
242
  if (isLighten)
224
243
  n *= -1;
@@ -322,16 +341,20 @@ var filterObject = (obj, func) => {
322
341
  var filterUndefined = (obj) => filterObject(obj, (_, val) => val !== null && val !== void 0);
323
342
  var merge = (target, source, overrideArray = false) => {
324
343
  let result = Object.assign({}, target);
325
- if (isObject(target) && isObject(source)) {
326
- for (const [sourceKey, sourceValue] of Object.entries(source)) {
327
- const targetValue = target[sourceKey];
328
- if (overrideArray && Array.isArray(sourceValue) && Array.isArray(targetValue)) {
329
- result[sourceKey] = targetValue.concat(...sourceValue);
330
- } else if (!isFunction(sourceValue) && isObject(sourceValue) && target.hasOwnProperty(sourceKey)) {
331
- result[sourceKey] = merge(targetValue, sourceValue, overrideArray);
332
- } else {
333
- Object.assign(result, { [sourceKey]: sourceValue });
344
+ if (isObject(source)) {
345
+ if (isObject(target)) {
346
+ for (const [sourceKey, sourceValue] of Object.entries(source)) {
347
+ const targetValue = target[sourceKey];
348
+ if (overrideArray && isArray(sourceValue) && isArray(targetValue)) {
349
+ result[sourceKey] = targetValue.concat(...sourceValue);
350
+ } else if (!isFunction(sourceValue) && isObject(sourceValue) && target.hasOwnProperty(sourceKey)) {
351
+ result[sourceKey] = merge(targetValue, sourceValue, overrideArray);
352
+ } else {
353
+ Object.assign(result, { [sourceKey]: sourceValue });
354
+ }
334
355
  }
356
+ } else {
357
+ result = source;
335
358
  }
336
359
  }
337
360
  return result;
@@ -453,6 +476,7 @@ export {
453
476
  useAsync,
454
477
  useAsyncFunc,
455
478
  useAsyncRetry,
479
+ hues,
456
480
  isGray,
457
481
  getColor,
458
482
  lightenColor,
package/dist/color.d.mts CHANGED
@@ -1,13 +1,14 @@
1
1
  import { Dict } from './index.types.mjs';
2
2
 
3
+ declare const hues: readonly [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
3
4
  declare const isGray: (colorScheme: string) => boolean;
4
- declare const getColor: (color: string, fallback?: string) => (theme: Dict, colorMode?: 'light' | 'dark') => string;
5
+ declare const getColor: (color: string, fallback?: string) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
5
6
  declare const lightenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
6
7
  declare const darkenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
7
8
  declare const tintColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
8
9
  declare const shadeColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
9
10
  declare const transparentizeColor: (color: string, alpha: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
10
- declare const toneColor: (color: string, l: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
11
+ declare const toneColor: (color: string, hue: (typeof hues)[number]) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
11
12
  declare const randomColor: ({ string, colors, }?: {
12
13
  string?: string | undefined;
13
14
  colors?: string[] | undefined;
@@ -16,4 +17,4 @@ declare const isTone: (color: string) => (theme?: Dict, colorMode?: 'light' | 'd
16
17
  declare const isLight: (color: string) => (theme?: Dict, colorMode?: 'light' | 'dark') => boolean;
17
18
  declare const isDark: (color: string) => (theme?: Dict, colorMode?: 'light' | 'dark') => boolean;
18
19
 
19
- export { darkenColor, getColor, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, transparentizeColor };
20
+ export { darkenColor, getColor, hues, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, transparentizeColor };
package/dist/color.d.ts CHANGED
@@ -1,13 +1,14 @@
1
1
  import { Dict } from './index.types.js';
2
2
 
3
+ declare const hues: readonly [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
3
4
  declare const isGray: (colorScheme: string) => boolean;
4
- declare const getColor: (color: string, fallback?: string) => (theme: Dict, colorMode?: 'light' | 'dark') => string;
5
+ declare const getColor: (color: string, fallback?: string) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
5
6
  declare const lightenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
6
7
  declare const darkenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
7
8
  declare const tintColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
8
9
  declare const shadeColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
9
10
  declare const transparentizeColor: (color: string, alpha: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
10
- declare const toneColor: (color: string, l: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
11
+ declare const toneColor: (color: string, hue: (typeof hues)[number]) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
11
12
  declare const randomColor: ({ string, colors, }?: {
12
13
  string?: string | undefined;
13
14
  colors?: string[] | undefined;
@@ -16,4 +17,4 @@ declare const isTone: (color: string) => (theme?: Dict, colorMode?: 'light' | 'd
16
17
  declare const isLight: (color: string) => (theme?: Dict, colorMode?: 'light' | 'dark') => boolean;
17
18
  declare const isDark: (color: string) => (theme?: Dict, colorMode?: 'light' | 'dark') => boolean;
18
19
 
19
- export { darkenColor, getColor, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, transparentizeColor };
20
+ export { darkenColor, getColor, hues, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, transparentizeColor };
package/dist/color.js CHANGED
@@ -22,6 +22,7 @@ var color_exports = {};
22
22
  __export(color_exports, {
23
23
  darkenColor: () => darkenColor,
24
24
  getColor: () => getColor,
25
+ hues: () => hues,
25
26
  isDark: () => isDark,
26
27
  isGray: () => isGray,
27
28
  isLight: () => isLight,
@@ -69,13 +70,32 @@ var memoizeObject = (func) => {
69
70
  var getMemoizedObject = memoizeObject(getObject);
70
71
 
71
72
  // src/color.ts
73
+ var hues = [
74
+ 50,
75
+ 100,
76
+ 200,
77
+ 300,
78
+ 400,
79
+ 500,
80
+ 600,
81
+ 700,
82
+ 800,
83
+ 900,
84
+ 950
85
+ ];
72
86
  var isGray = (colorScheme) => colorScheme === "gray" || colorScheme === "zinc" || colorScheme === "neutral" || colorScheme === "stone";
73
- var getColor = (color, fallback) => (theme, colorMode) => {
87
+ var getColor = (color, fallback) => (theme = {}, colorMode) => {
88
+ var _a, _b, _c;
89
+ const [token, hue] = color.split(".");
90
+ const [, relatedToken] = (_c = Object.entries((_b = (_a = theme.semantics) == null ? void 0 : _a.colorSchemes) != null ? _b : {}).find(
91
+ ([semanticToken]) => token === semanticToken
92
+ )) != null ? _c : [];
93
+ if (relatedToken)
94
+ color = `${relatedToken}.${hue}`;
74
95
  const hex = getMemoizedObject(theme, `colors.${color}`, color);
75
96
  try {
76
97
  if (isArray(hex)) {
77
- const [lightHex, darkHex] = hex;
78
- return (0, import_color2k.toHex)(String(colorMode !== "dark" ? lightHex : darkHex));
98
+ return (0, import_color2k.toHex)(String(colorMode !== "dark" ? hex[0] : hex[1]));
79
99
  } else {
80
100
  return (0, import_color2k.toHex)(String(hex));
81
101
  }
@@ -84,30 +104,30 @@ var getColor = (color, fallback) => (theme, colorMode) => {
84
104
  }
85
105
  };
86
106
  var lightenColor = (color, amount) => (theme, colorMode) => {
87
- const raw = theme ? getColor(color)(theme, colorMode) : color;
107
+ const raw = getColor(color, color)(theme, colorMode);
88
108
  return (0, import_color2k.toHex)((0, import_color2k.lighten)(raw, amount / 100));
89
109
  };
90
110
  var darkenColor = (color, amount) => (theme, colorMode) => {
91
- const raw = theme ? getColor(color)(theme, colorMode) : color;
111
+ const raw = getColor(color, color)(theme, colorMode);
92
112
  return (0, import_color2k.toHex)((0, import_color2k.darken)(raw, amount / 100));
93
113
  };
94
114
  var tintColor = (color, amount) => (theme, colorMode) => {
95
- const raw = theme ? getColor(color)(theme, colorMode) : color;
115
+ const raw = getColor(color, color)(theme, colorMode);
96
116
  return (0, import_color2k.toHex)((0, import_color2k.mix)(raw, "#fff", amount));
97
117
  };
98
118
  var shadeColor = (color, amount) => (theme, colorMode) => {
99
- const raw = theme ? getColor(color)(theme, colorMode) : color;
119
+ const raw = getColor(color, color)(theme, colorMode);
100
120
  return (0, import_color2k.toHex)((0, import_color2k.mix)(raw, "#000", amount / 100));
101
121
  };
102
122
  var transparentizeColor = (color, alpha) => (theme, colorMode) => {
103
- const raw = theme ? getColor(color)(theme, colorMode) : color;
123
+ const raw = getColor(color, color)(theme, colorMode);
104
124
  return (0, import_color2k.transparentize)(raw, 1 - alpha);
105
125
  };
106
- var toneColor = (color, l) => (theme, colorMode) => {
107
- const raw = theme ? getColor(color)(theme, colorMode) : color;
108
- if (l < 0 || 900 < l)
126
+ var toneColor = (color, hue) => (theme, colorMode) => {
127
+ const raw = getColor(color, color)(theme, colorMode);
128
+ if (hue < 50 || 950 < hue)
109
129
  return color;
110
- let n = (l - 500) / 10;
130
+ let n = (hue - 500) / 10;
111
131
  const isLighten = n <= 0;
112
132
  if (isLighten)
113
133
  n *= -1;
@@ -172,6 +192,7 @@ var isDark = (color) => (theme, colorMode) => isTone(color)(theme, colorMode) ==
172
192
  0 && (module.exports = {
173
193
  darkenColor,
174
194
  getColor,
195
+ hues,
175
196
  isDark,
176
197
  isGray,
177
198
  isLight,
package/dist/color.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  darkenColor,
3
3
  getColor,
4
+ hues,
4
5
  isDark,
5
6
  isGray,
6
7
  isLight,
@@ -11,18 +12,19 @@ import {
11
12
  tintColor,
12
13
  toneColor,
13
14
  transparentizeColor
14
- } from "./chunk-32BEUAHK.mjs";
15
+ } from "./chunk-OL4TBQN7.mjs";
15
16
  import "./chunk-SLJ4M7XC.mjs";
16
17
  import "./chunk-VYMGBE25.mjs";
17
18
  import "./chunk-BZAW2D6U.mjs";
18
19
  import "./chunk-PURW64JE.mjs";
19
- import "./chunk-IVGIIDMV.mjs";
20
+ import "./chunk-BU4LEFZY.mjs";
20
21
  import "./chunk-R5OUKGQ5.mjs";
21
22
  import "./chunk-H5VMEQNO.mjs";
22
- import "./chunk-PF7LRFIA.mjs";
23
+ import "./chunk-G7Q2EDJF.mjs";
23
24
  export {
24
25
  darkenColor,
25
26
  getColor,
27
+ hues,
26
28
  isDark,
27
29
  isGray,
28
30
  isLight,
package/dist/event.js CHANGED
@@ -58,13 +58,13 @@ var addDomEvent = (target, type, cb, options) => {
58
58
  target.removeEventListener(type, cb, options);
59
59
  };
60
60
  };
61
- var filter = (cb) => (event) => {
62
- const isMouse = isMouseEvent(event);
63
- if (!isMouse || isMouse && event.button === 0)
64
- cb(event);
61
+ var filter = (cb) => (ev) => {
62
+ const isMouse = isMouseEvent(ev);
63
+ if (!isMouse || isMouse && ev.button === 0)
64
+ cb(ev);
65
65
  };
66
66
  var wrap = (cb, filterPrimary = false) => {
67
- const listener = (event) => cb(event, { point: getEventPoint(event) });
67
+ const listener = (ev) => cb(ev, { point: getEventPoint(ev) });
68
68
  const fn = filterPrimary ? filter(listener) : listener;
69
69
  return fn;
70
70
  };
package/dist/event.mjs CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  isTouchEvent,
9
9
  pointFromMouse,
10
10
  pointFromTouch
11
- } from "./chunk-PF7LRFIA.mjs";
11
+ } from "./chunk-G7Q2EDJF.mjs";
12
12
  export {
13
13
  addDomEvent,
14
14
  addPointerEvent,
package/dist/function.mjs CHANGED
@@ -3,15 +3,15 @@ import {
3
3
  handlerAll,
4
4
  noop,
5
5
  runIfFunc
6
- } from "./chunk-32BEUAHK.mjs";
6
+ } from "./chunk-OL4TBQN7.mjs";
7
7
  import "./chunk-SLJ4M7XC.mjs";
8
8
  import "./chunk-VYMGBE25.mjs";
9
9
  import "./chunk-BZAW2D6U.mjs";
10
10
  import "./chunk-PURW64JE.mjs";
11
- import "./chunk-IVGIIDMV.mjs";
11
+ import "./chunk-BU4LEFZY.mjs";
12
12
  import "./chunk-R5OUKGQ5.mjs";
13
13
  import "./chunk-H5VMEQNO.mjs";
14
- import "./chunk-PF7LRFIA.mjs";
14
+ import "./chunk-G7Q2EDJF.mjs";
15
15
  export {
16
16
  funcAll,
17
17
  handlerAll,
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { Dict, DynamicRecord, Length, Path, StringLiteral, Union } from './index.types.mjs';
1
+ export { Dict, Length, Path, StringLiteral, Union } from './index.types.mjs';
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';
@@ -6,7 +6,7 @@ export { AsyncFnReturn, AsyncState, AsyncStateRetry, DOMAttributes, FunctionRetu
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, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, transparentizeColor } from './color.mjs';
9
+ export { darkenColor, getColor, hues, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, 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
@@ -1,4 +1,4 @@
1
- export { Dict, DynamicRecord, Length, Path, StringLiteral, Union } from './index.types.js';
1
+ export { Dict, Length, Path, StringLiteral, Union } from './index.types.js';
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';
@@ -6,7 +6,7 @@ export { AsyncFnReturn, AsyncState, AsyncStateRetry, DOMAttributes, FunctionRetu
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, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, transparentizeColor } from './color.js';
9
+ export { darkenColor, getColor, hues, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, 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
@@ -66,6 +66,7 @@ __export(src_exports, {
66
66
  handlerAll: () => handlerAll,
67
67
  hasNegativeTabIndex: () => hasNegativeTabIndex,
68
68
  hasTabIndex: () => hasTabIndex,
69
+ hues: () => hues,
69
70
  includesChildren: () => includesChildren,
70
71
  isActiveElement: () => isActiveElement,
71
72
  isApple: () => isApple,
@@ -145,9 +146,9 @@ var isNumeric = (value) => value != null && parseFloat(value.toString()) - parse
145
146
  var isString = (value) => Object.prototype.toString.call(value) === "[object String]";
146
147
  var isUndefined = (value) => typeof value === "undefined" && value === void 0;
147
148
  var isNull = (value) => value === null;
148
- var isObject = (value) => value !== null && (typeof value === "object" || typeof value === "function") && !Array.isArray(value);
149
+ var isObject = (value) => value !== null && (typeof value === "object" || typeof value === "function") && !isArray(value);
149
150
  var isArray = (value) => Array.isArray(value);
150
- var isEmpty = (value) => !Array.isArray(value) || !value.length || value.every((v) => v == null);
151
+ var isEmpty = (value) => !isArray(value) || !value.length || value.every((v) => v == null);
151
152
  var isFunction = (value) => typeof value === "function";
152
153
  var isUnit = (value) => /[0-9].*[px|rem|em|%|vw|vh]$/.test(value);
153
154
  var cast = (value) => value;
@@ -194,16 +195,20 @@ var filterObject = (obj, func) => {
194
195
  var filterUndefined = (obj) => filterObject(obj, (_, val) => val !== null && val !== void 0);
195
196
  var merge = (target, source, overrideArray = false) => {
196
197
  let result = Object.assign({}, target);
197
- if (isObject(target) && isObject(source)) {
198
- for (const [sourceKey, sourceValue] of Object.entries(source)) {
199
- const targetValue = target[sourceKey];
200
- if (overrideArray && Array.isArray(sourceValue) && Array.isArray(targetValue)) {
201
- result[sourceKey] = targetValue.concat(...sourceValue);
202
- } else if (!isFunction(sourceValue) && isObject(sourceValue) && target.hasOwnProperty(sourceKey)) {
203
- result[sourceKey] = merge(targetValue, sourceValue, overrideArray);
204
- } else {
205
- Object.assign(result, { [sourceKey]: sourceValue });
198
+ if (isObject(source)) {
199
+ if (isObject(target)) {
200
+ for (const [sourceKey, sourceValue] of Object.entries(source)) {
201
+ const targetValue = target[sourceKey];
202
+ if (overrideArray && isArray(sourceValue) && isArray(targetValue)) {
203
+ result[sourceKey] = targetValue.concat(...sourceValue);
204
+ } else if (!isFunction(sourceValue) && isObject(sourceValue) && target.hasOwnProperty(sourceKey)) {
205
+ result[sourceKey] = merge(targetValue, sourceValue, overrideArray);
206
+ } else {
207
+ Object.assign(result, { [sourceKey]: sourceValue });
208
+ }
206
209
  }
210
+ } else {
211
+ result = source;
207
212
  }
208
213
  }
209
214
  return result;
@@ -579,13 +584,32 @@ var calc = Object.assign(
579
584
 
580
585
  // src/color.ts
581
586
  var import_color2k = require("color2k");
587
+ var hues = [
588
+ 50,
589
+ 100,
590
+ 200,
591
+ 300,
592
+ 400,
593
+ 500,
594
+ 600,
595
+ 700,
596
+ 800,
597
+ 900,
598
+ 950
599
+ ];
582
600
  var isGray = (colorScheme) => colorScheme === "gray" || colorScheme === "zinc" || colorScheme === "neutral" || colorScheme === "stone";
583
- var getColor = (color, fallback) => (theme, colorMode) => {
601
+ var getColor = (color, fallback) => (theme = {}, colorMode) => {
602
+ var _a, _b, _c;
603
+ const [token, hue] = color.split(".");
604
+ const [, relatedToken] = (_c = Object.entries((_b = (_a = theme.semantics) == null ? void 0 : _a.colorSchemes) != null ? _b : {}).find(
605
+ ([semanticToken]) => token === semanticToken
606
+ )) != null ? _c : [];
607
+ if (relatedToken)
608
+ color = `${relatedToken}.${hue}`;
584
609
  const hex = getMemoizedObject(theme, `colors.${color}`, color);
585
610
  try {
586
611
  if (isArray(hex)) {
587
- const [lightHex, darkHex] = hex;
588
- return (0, import_color2k.toHex)(String(colorMode !== "dark" ? lightHex : darkHex));
612
+ return (0, import_color2k.toHex)(String(colorMode !== "dark" ? hex[0] : hex[1]));
589
613
  } else {
590
614
  return (0, import_color2k.toHex)(String(hex));
591
615
  }
@@ -594,30 +618,30 @@ var getColor = (color, fallback) => (theme, colorMode) => {
594
618
  }
595
619
  };
596
620
  var lightenColor = (color, amount) => (theme, colorMode) => {
597
- const raw = theme ? getColor(color)(theme, colorMode) : color;
621
+ const raw = getColor(color, color)(theme, colorMode);
598
622
  return (0, import_color2k.toHex)((0, import_color2k.lighten)(raw, amount / 100));
599
623
  };
600
624
  var darkenColor = (color, amount) => (theme, colorMode) => {
601
- const raw = theme ? getColor(color)(theme, colorMode) : color;
625
+ const raw = getColor(color, color)(theme, colorMode);
602
626
  return (0, import_color2k.toHex)((0, import_color2k.darken)(raw, amount / 100));
603
627
  };
604
628
  var tintColor = (color, amount) => (theme, colorMode) => {
605
- const raw = theme ? getColor(color)(theme, colorMode) : color;
629
+ const raw = getColor(color, color)(theme, colorMode);
606
630
  return (0, import_color2k.toHex)((0, import_color2k.mix)(raw, "#fff", amount));
607
631
  };
608
632
  var shadeColor = (color, amount) => (theme, colorMode) => {
609
- const raw = theme ? getColor(color)(theme, colorMode) : color;
633
+ const raw = getColor(color, color)(theme, colorMode);
610
634
  return (0, import_color2k.toHex)((0, import_color2k.mix)(raw, "#000", amount / 100));
611
635
  };
612
636
  var transparentizeColor = (color, alpha) => (theme, colorMode) => {
613
- const raw = theme ? getColor(color)(theme, colorMode) : color;
637
+ const raw = getColor(color, color)(theme, colorMode);
614
638
  return (0, import_color2k.transparentize)(raw, 1 - alpha);
615
639
  };
616
- var toneColor = (color, l) => (theme, colorMode) => {
617
- const raw = theme ? getColor(color)(theme, colorMode) : color;
618
- if (l < 0 || 900 < l)
640
+ var toneColor = (color, hue) => (theme, colorMode) => {
641
+ const raw = getColor(color, color)(theme, colorMode);
642
+ if (hue < 50 || 950 < hue)
619
643
  return color;
620
- let n = (l - 500) / 10;
644
+ let n = (hue - 500) / 10;
621
645
  const isLighten = n <= 0;
622
646
  if (isLighten)
623
647
  n *= -1;
@@ -741,13 +765,13 @@ var addDomEvent = (target, type, cb, options) => {
741
765
  target.removeEventListener(type, cb, options);
742
766
  };
743
767
  };
744
- var filter = (cb) => (event) => {
745
- const isMouse = isMouseEvent(event);
746
- if (!isMouse || isMouse && event.button === 0)
747
- cb(event);
768
+ var filter = (cb) => (ev) => {
769
+ const isMouse = isMouseEvent(ev);
770
+ if (!isMouse || isMouse && ev.button === 0)
771
+ cb(ev);
748
772
  };
749
773
  var wrap = (cb, filterPrimary = false) => {
750
- const listener = (event) => cb(event, { point: getEventPoint(event) });
774
+ const listener = (ev) => cb(ev, { point: getEventPoint(ev) });
751
775
  const fn = filterPrimary ? filter(listener) : listener;
752
776
  return fn;
753
777
  };
@@ -790,6 +814,7 @@ var addPointerEvent = (target, type, cb, options) => addDomEvent(target, type, w
790
814
  handlerAll,
791
815
  hasNegativeTabIndex,
792
816
  hasTabIndex,
817
+ hues,
793
818
  includesChildren,
794
819
  isActiveElement,
795
820
  isApple,
package/dist/index.mjs CHANGED
@@ -14,6 +14,7 @@ import {
14
14
  getObject,
15
15
  getValidChildren,
16
16
  handlerAll,
17
+ hues,
17
18
  includesChildren,
18
19
  isDark,
19
20
  isGray,
@@ -49,7 +50,7 @@ import {
49
50
  useSafeLayoutEffect,
50
51
  useUnmountEffect,
51
52
  useUpdateEffect
52
- } from "./chunk-32BEUAHK.mjs";
53
+ } from "./chunk-OL4TBQN7.mjs";
53
54
  import "./chunk-SLJ4M7XC.mjs";
54
55
  import {
55
56
  clampNumber,
@@ -78,7 +79,7 @@ import {
78
79
  isString,
79
80
  isUndefined,
80
81
  isUnit
81
- } from "./chunk-IVGIIDMV.mjs";
82
+ } from "./chunk-BU4LEFZY.mjs";
82
83
  import {
83
84
  calc
84
85
  } from "./chunk-R5OUKGQ5.mjs";
@@ -119,7 +120,7 @@ import {
119
120
  isTouchEvent,
120
121
  pointFromMouse,
121
122
  pointFromTouch
122
- } from "./chunk-PF7LRFIA.mjs";
123
+ } from "./chunk-G7Q2EDJF.mjs";
123
124
  export {
124
125
  addDomEvent,
125
126
  addPointerEvent,
@@ -157,6 +158,7 @@ export {
157
158
  handlerAll,
158
159
  hasNegativeTabIndex,
159
160
  hasTabIndex,
161
+ hues,
160
162
  includesChildren,
161
163
  isActiveElement,
162
164
  isApple,
@@ -7,8 +7,5 @@ type Dict<T = any> = Record<string, T>;
7
7
  type StringLiteral = string & {};
8
8
  type Union<T> = T | StringLiteral;
9
9
  type Length = string | 0 | number;
10
- type DynamicRecord<T> = {
11
- [K in keyof T]-?: T[K] extends Primitive ? string | number : DynamicRecord<T[K]>;
12
- };
13
10
 
14
- export { Dict, DynamicRecord, Length, Path, StringLiteral, Union };
11
+ export { Dict, Length, Path, StringLiteral, Union };
@@ -7,8 +7,5 @@ type Dict<T = any> = Record<string, T>;
7
7
  type StringLiteral = string & {};
8
8
  type Union<T> = T | StringLiteral;
9
9
  type Length = string | 0 | number;
10
- type DynamicRecord<T> = {
11
- [K in keyof T]-?: T[K] extends Primitive ? string | number : DynamicRecord<T[K]>;
12
- };
13
10
 
14
- export { Dict, DynamicRecord, Length, Path, StringLiteral, Union };
11
+ export { Dict, Length, Path, StringLiteral, Union };
package/dist/object.js CHANGED
@@ -38,7 +38,7 @@ __export(object_exports, {
38
38
  module.exports = __toCommonJS(object_exports);
39
39
 
40
40
  // src/assertion.ts
41
- var isObject = (value) => value !== null && (typeof value === "object" || typeof value === "function") && !Array.isArray(value);
41
+ var isObject = (value) => value !== null && (typeof value === "object" || typeof value === "function") && !isArray(value);
42
42
  var isArray = (value) => Array.isArray(value);
43
43
  var isFunction = (value) => typeof value === "function";
44
44
 
@@ -84,16 +84,20 @@ var filterObject = (obj, func) => {
84
84
  var filterUndefined = (obj) => filterObject(obj, (_, val) => val !== null && val !== void 0);
85
85
  var merge = (target, source, overrideArray = false) => {
86
86
  let result = Object.assign({}, target);
87
- if (isObject(target) && isObject(source)) {
88
- for (const [sourceKey, sourceValue] of Object.entries(source)) {
89
- const targetValue = target[sourceKey];
90
- if (overrideArray && Array.isArray(sourceValue) && Array.isArray(targetValue)) {
91
- result[sourceKey] = targetValue.concat(...sourceValue);
92
- } else if (!isFunction(sourceValue) && isObject(sourceValue) && target.hasOwnProperty(sourceKey)) {
93
- result[sourceKey] = merge(targetValue, sourceValue, overrideArray);
94
- } else {
95
- Object.assign(result, { [sourceKey]: sourceValue });
87
+ if (isObject(source)) {
88
+ if (isObject(target)) {
89
+ for (const [sourceKey, sourceValue] of Object.entries(source)) {
90
+ const targetValue = target[sourceKey];
91
+ if (overrideArray && isArray(sourceValue) && isArray(targetValue)) {
92
+ result[sourceKey] = targetValue.concat(...sourceValue);
93
+ } else if (!isFunction(sourceValue) && isObject(sourceValue) && target.hasOwnProperty(sourceKey)) {
94
+ result[sourceKey] = merge(targetValue, sourceValue, overrideArray);
95
+ } else {
96
+ Object.assign(result, { [sourceKey]: sourceValue });
97
+ }
96
98
  }
99
+ } else {
100
+ result = source;
97
101
  }
98
102
  }
99
103
  return result;
package/dist/object.mjs CHANGED
@@ -13,15 +13,15 @@ import {
13
13
  pickObject,
14
14
  replaceObject,
15
15
  splitObject
16
- } from "./chunk-32BEUAHK.mjs";
16
+ } from "./chunk-OL4TBQN7.mjs";
17
17
  import "./chunk-SLJ4M7XC.mjs";
18
18
  import "./chunk-VYMGBE25.mjs";
19
19
  import "./chunk-BZAW2D6U.mjs";
20
20
  import "./chunk-PURW64JE.mjs";
21
- import "./chunk-IVGIIDMV.mjs";
21
+ import "./chunk-BU4LEFZY.mjs";
22
22
  import "./chunk-R5OUKGQ5.mjs";
23
23
  import "./chunk-H5VMEQNO.mjs";
24
- import "./chunk-PF7LRFIA.mjs";
24
+ import "./chunk-G7Q2EDJF.mjs";
25
25
  export {
26
26
  assignAfter,
27
27
  filterObject,
package/dist/react.mjs CHANGED
@@ -19,15 +19,15 @@ import {
19
19
  useSafeLayoutEffect,
20
20
  useUnmountEffect,
21
21
  useUpdateEffect
22
- } from "./chunk-32BEUAHK.mjs";
22
+ } from "./chunk-OL4TBQN7.mjs";
23
23
  import "./chunk-SLJ4M7XC.mjs";
24
24
  import "./chunk-VYMGBE25.mjs";
25
25
  import "./chunk-BZAW2D6U.mjs";
26
26
  import "./chunk-PURW64JE.mjs";
27
- import "./chunk-IVGIIDMV.mjs";
27
+ import "./chunk-BU4LEFZY.mjs";
28
28
  import "./chunk-R5OUKGQ5.mjs";
29
29
  import "./chunk-H5VMEQNO.mjs";
30
- import "./chunk-PF7LRFIA.mjs";
30
+ import "./chunk-G7Q2EDJF.mjs";
31
31
  export {
32
32
  assignRef,
33
33
  createContext,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yamada-ui/utils",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Yamada UI utils",
5
5
  "keywords": [
6
6
  "utils",