qstd 0.2.9 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/block/accordion.d.ts +18 -0
  2. package/dist/block/accordion.d.ts.map +1 -0
  3. package/dist/block/checkbox.d.ts +3 -0
  4. package/dist/block/checkbox.d.ts.map +1 -0
  5. package/dist/block/drawer.d.ts +9 -0
  6. package/dist/block/drawer.d.ts.map +1 -0
  7. package/dist/block/fns.d.ts +50 -0
  8. package/dist/block/fns.d.ts.map +1 -0
  9. package/dist/block/icon.d.ts +4 -0
  10. package/dist/block/icon.d.ts.map +1 -0
  11. package/dist/block/index.d.ts +62 -0
  12. package/dist/block/index.d.ts.map +1 -0
  13. package/dist/block/input.d.ts +23 -0
  14. package/dist/block/input.d.ts.map +1 -0
  15. package/dist/block/literals.d.ts +121 -0
  16. package/dist/block/literals.d.ts.map +1 -0
  17. package/dist/block/menu.d.ts +4 -0
  18. package/dist/block/menu.d.ts.map +1 -0
  19. package/dist/block/progress.d.ts +18 -0
  20. package/dist/block/progress.d.ts.map +1 -0
  21. package/dist/block/radio.d.ts +17 -0
  22. package/dist/block/radio.d.ts.map +1 -0
  23. package/dist/block/switch.d.ts +21 -0
  24. package/dist/block/switch.d.ts.map +1 -0
  25. package/dist/block/test-types.d.ts +4 -0
  26. package/dist/block/test-types.d.ts.map +1 -0
  27. package/dist/block/textarea.d.ts +33 -0
  28. package/dist/block/textarea.d.ts.map +1 -0
  29. package/dist/block/tooltip.d.ts +5 -0
  30. package/dist/block/tooltip.d.ts.map +1 -0
  31. package/dist/block/types.d.ts +384 -0
  32. package/dist/block/types.d.ts.map +1 -0
  33. package/dist/block/use-resize-observer.d.ts +24 -0
  34. package/dist/block/use-resize-observer.d.ts.map +1 -0
  35. package/dist/client/browser.d.ts +44 -0
  36. package/dist/client/browser.d.ts.map +1 -0
  37. package/dist/client/dom.d.ts +58 -0
  38. package/dist/client/dom.d.ts.map +1 -0
  39. package/dist/client/index.cjs +28 -1
  40. package/dist/client/index.d.ts +11 -75
  41. package/dist/client/index.d.ts.map +1 -0
  42. package/dist/client/index.js +28 -1
  43. package/dist/client/storage.d.ts +46 -0
  44. package/dist/client/storage.d.ts.map +1 -0
  45. package/dist/preset/index.d.ts +3 -4
  46. package/dist/preset/index.d.ts.map +1 -0
  47. package/dist/react/index.cjs +4 -3
  48. package/dist/react/index.d.ts +10 -21023
  49. package/dist/react/index.d.ts.map +1 -0
  50. package/dist/react/index.js +4 -3
  51. package/dist/react/use-theme/fns.d.ts +5 -0
  52. package/dist/react/use-theme/fns.d.ts.map +1 -0
  53. package/dist/react/use-theme/index.d.ts +13 -0
  54. package/dist/react/use-theme/index.d.ts.map +1 -0
  55. package/dist/react/use-theme/literals.d.ts +4 -0
  56. package/dist/react/use-theme/literals.d.ts.map +1 -0
  57. package/dist/react/use-theme/types.d.ts +6 -0
  58. package/dist/react/use-theme/types.d.ts.map +1 -0
  59. package/dist/server/file.d.ts +8 -0
  60. package/dist/server/file.d.ts.map +1 -0
  61. package/dist/server/index.cjs +28 -1
  62. package/dist/server/index.d.ts +11 -17
  63. package/dist/server/index.d.ts.map +1 -0
  64. package/dist/server/index.js +28 -1
  65. package/dist/shared/dict.d.ts +57 -0
  66. package/dist/shared/dict.d.ts.map +1 -0
  67. package/dist/shared/flow.d.ts +36 -0
  68. package/dist/shared/flow.d.ts.map +1 -0
  69. package/dist/shared/int.d.ts +49 -0
  70. package/dist/shared/int.d.ts.map +1 -0
  71. package/dist/shared/list.d.ts +29 -0
  72. package/dist/shared/list.d.ts.map +1 -0
  73. package/dist/shared/log.d.ts +5 -0
  74. package/dist/shared/log.d.ts.map +1 -0
  75. package/dist/shared/money.d.ts +18 -0
  76. package/dist/shared/money.d.ts.map +1 -0
  77. package/dist/shared/random.d.ts +41 -0
  78. package/dist/shared/random.d.ts.map +1 -0
  79. package/dist/shared/str.d.ts +74 -0
  80. package/dist/shared/str.d.ts.map +1 -0
  81. package/dist/shared/time.d.ts +112 -0
  82. package/dist/shared/time.d.ts.map +1 -0
  83. package/package.json +20 -19
  84. package/dist/client/index.d.cts +0 -75
  85. package/dist/log-ERvLs2Dx.d.cts +0 -460
  86. package/dist/log-ERvLs2Dx.d.ts +0 -460
  87. package/dist/preset/index.d.cts +0 -39
  88. package/dist/react/index.d.cts +0 -21058
  89. package/dist/server/index.d.cts +0 -17
@@ -1,460 +0,0 @@
1
- import { Locale } from 'date-fns';
2
-
3
- /**
4
- * Robust variadic zipWith with full type inference
5
- */
6
- declare function zipWith<T extends readonly any[], R>(fn: (...args: T) => R, ...arrays: {
7
- [K in keyof T]: T[K][];
8
- }): R[];
9
- /**
10
- * Create an array of x length filled with items of type y.
11
- * @param size
12
- * @param fn
13
- * @returns
14
- */
15
- declare const create: <T>(size: number, fn?: (_: unknown, x: number) => T) => T[];
16
- /**
17
- * First list includes items that pass the predicate.
18
- * Second list includes items that failed.
19
- * @param xs
20
- * @param predicate
21
- * @returns
22
- */
23
- declare const partition$1: <T>(xs: T[], predicate: (x: T) => boolean) => [T[], T[]];
24
- /**
25
- * Split an array into chunks of a specific size
26
- * @param list
27
- * @param chunkSize
28
- * @returns
29
- */
30
- declare const chunk: <T>(list: T[], chunkSize: number) => T[][];
31
-
32
- declare const list_chunk: typeof chunk;
33
- declare const list_create: typeof create;
34
- declare const list_zipWith: typeof zipWith;
35
- declare namespace list {
36
- export { list_chunk as chunk, list_create as create, partition$1 as partition, list_zipWith as zipWith };
37
- }
38
-
39
- /**
40
- * dicts are homogeneous- their values must be of the same type
41
- * records can hold values of different types
42
- */
43
- type t = Record<string, unknown> | object;
44
- /**
45
- * Calculate the byte size of an object
46
- * @param o
47
- * @returns
48
- */
49
- declare function byteSizeOfObj(o: any): number;
50
- /**
51
- * Return an object filter with a subset of properties.
52
- * @param r
53
- * @param predicate
54
- */
55
- declare const filter: <R extends t>(r: R, predicate: (value: R[keyof R]) => boolean) => R;
56
- /**
57
- * Transform the values on an object
58
- * @param r
59
- * @param transformFn
60
- */
61
- declare const transform: <R extends t>(r: R, transformFn: (key: keyof R, value: R[keyof R]) => Record<string, any>) => R;
62
- /**
63
- * First object contains key/value pairs that pass the predicate.
64
- * Second object contains key/value pairs that failed.
65
- * @param r
66
- * @param predicate
67
- * @returns
68
- */
69
- declare const partition: <R extends t>(r: R, predicate: (key: keyof R) => boolean) => readonly [R, R];
70
- /**
71
- * Check if an object exists and has keys
72
- * @param obj
73
- * @returns
74
- */
75
- declare const exists: <O>(obj: O) => boolean;
76
- /**
77
- * Determine if an object is empty.
78
- * @param obj
79
- * @returns
80
- */
81
- declare const isEmpty: <T extends t>(obj: T) => boolean;
82
- /**
83
- * Return an object with a subset of properties.
84
- * @param r
85
- * @param paths
86
- */
87
- declare const pick: <R extends t, U extends keyof R>(r: R, paths: Array<U>) => Pick<R, U>;
88
- /**
89
- * Return an object with a subset of properties omitted.
90
- * @param r
91
- * @param paths
92
- */
93
- declare const omit: <R extends Record<string, any>, U extends keyof R>(r: R, paths: Array<U>) => Omit<R, U>;
94
-
95
- declare const dict_byteSizeOfObj: typeof byteSizeOfObj;
96
- declare const dict_exists: typeof exists;
97
- declare const dict_filter: typeof filter;
98
- declare const dict_isEmpty: typeof isEmpty;
99
- declare const dict_omit: typeof omit;
100
- declare const dict_partition: typeof partition;
101
- declare const dict_pick: typeof pick;
102
- declare const dict_transform: typeof transform;
103
- declare namespace dict {
104
- export { dict_byteSizeOfObj as byteSizeOfObj, dict_exists as exists, dict_filter as filter, dict_isEmpty as isEmpty, dict_omit as omit, dict_partition as partition, dict_pick as pick, dict_transform as transform };
105
- }
106
-
107
- type CaseOpts = {
108
- to: "title" | "snake" | "kebab";
109
- clean?: boolean;
110
- };
111
- /**
112
- * Split text into sentences
113
- * @param text
114
- * @returns
115
- */
116
- declare const createSentences: (text?: string) => string[];
117
- /**
118
- * Count words in text
119
- * @param text
120
- * @returns
121
- */
122
- declare const countWords: (text: string) => number;
123
- /**
124
- * Concatenate strings with optional delimiter
125
- * @param xs
126
- * @param delimiter
127
- * @returns
128
- */
129
- declare const concat: (xs: (string | undefined)[], delimiter?: string) => string;
130
- /**
131
- * The number of times a character appears in a string
132
- * @param str
133
- * @param ch
134
- * @returns
135
- */
136
- declare const countChar: (str: string, ch: string) => number;
137
- /**
138
- * Convert a str to specific casing
139
- * @param text
140
- * @param opts
141
- * @returns
142
- */
143
- declare const changeCase: <T extends string>(text: string, opts: CaseOpts) => string;
144
-
145
- declare const str_changeCase: typeof changeCase;
146
- declare const str_concat: typeof concat;
147
- declare const str_countChar: typeof countChar;
148
- declare const str_countWords: typeof countWords;
149
- declare const str_createSentences: typeof createSentences;
150
- declare namespace str {
151
- export { str_changeCase as changeCase, str_concat as concat, str_countChar as countChar, str_countWords as countWords, str_createSentences as createSentences };
152
- }
153
-
154
- type Range = {
155
- min: number;
156
- max: number;
157
- };
158
- /**
159
- * Clamp a number within a range
160
- * @param num
161
- * @param range
162
- * @returns
163
- */
164
- declare const clamp: (num: number, range: Range) => number;
165
- /**
166
- * Format a number with comma-separated thousandths
167
- * @param n
168
- * @returns
169
- */
170
- declare const commaSeparateThousandths: (n: number | string) => string;
171
- /**
172
- * Convert bytes to other units.
173
- * @param bytes
174
- * @param decimals
175
- * @param binaryUnits
176
- * @example
177
- * ```js
178
- * formatBytes(293489203947847, 1); // 293.5 TB
179
- * formatBytes(1234, 0); // 1 KB
180
- * formatBytes(4534634523453678343456, 2); // 4.53 ZB
181
- * formatBytes(4534634523453678343456, 2, true)); // 3.84 ZiB
182
- * formatBytes(4566744, 1); // 4.6 MB
183
- * formatBytes(534, 0); // 534 Bytes
184
- * formatBytes(273403407, 0); // 273 MB
185
- * ```
186
- * @returns
187
- */
188
- declare const formatBytes: (bytes?: number, decimals?: number, binaryUnits?: boolean) => {
189
- value?: undefined;
190
- unit?: undefined;
191
- display?: undefined;
192
- } | {
193
- value: number;
194
- unit: string;
195
- display?: undefined;
196
- } | {
197
- value: number;
198
- unit: string | undefined;
199
- display: string;
200
- };
201
-
202
- declare const int_clamp: typeof clamp;
203
- declare const int_commaSeparateThousandths: typeof commaSeparateThousandths;
204
- declare const int_formatBytes: typeof formatBytes;
205
- declare namespace int {
206
- export { int_clamp as clamp, int_commaSeparateThousandths as commaSeparateThousandths, int_formatBytes as formatBytes };
207
- }
208
-
209
- type Opts = {
210
- symbol?: boolean;
211
- };
212
- /**
213
- * Convert cents to USD currency string
214
- * @param cents
215
- * @param opts
216
- * @returns
217
- */
218
- declare const convertToUsd: (cents?: number | string, opts?: Opts) => string | undefined;
219
- /**
220
- * Convert dollars to cents
221
- * @param dollars
222
- * @returns
223
- */
224
- declare const convertToCents: (dollars: string | number) => number;
225
-
226
- declare const money_convertToCents: typeof convertToCents;
227
- declare const money_convertToUsd: typeof convertToUsd;
228
- declare namespace money {
229
- export { money_convertToCents as convertToCents, money_convertToUsd as convertToUsd };
230
- }
231
-
232
- type DurationFormat = "compact" | "full" | "clock" | "fractional";
233
- type DurationOptions = {
234
- /** Format style: 'compact' (1h 2m), 'full' (1 hour 2 minutes), 'clock' (01:02:03), 'fractional' (1.4s, 1m4.4s) */
235
- format?: DurationFormat;
236
- /** Show zero values for intermediate units (e.g., "1h 0m 30s" vs "1h 30s") */
237
- showZero?: boolean;
238
- };
239
- /**
240
- * Formats milliseconds into human-readable duration strings
241
- * Supports compact (1h 2m), full (`1 hour 2 minutes`), clock (`01:02:03`), and fractional (1.4s, 1m4.4s) formats
242
- *
243
- * @param {Object} [options={}] - Configuration options
244
- * @param {string} [options.format="clock"] - format
245
- * @param {boolean} [options.showZero=false] - show zero prefix
246
- *
247
- * @example
248
- * formatDuration(90000) // "1:30"
249
- * formatDuration(3661000) // "1:01:01"
250
- * formatDuration(90000, { format: "compact" }) // "1m 30s"
251
- * formatDuration(90000, { format: "full" }) // "1 minute 30 seconds"
252
- * formatDuration(3600000, { format: "compact" }) // "1h"
253
- * formatDuration(3600000, { format: "compact", showZero: true }) // "1h 0m 0s"
254
- * formatDuration(3660000, { format: "full", showZero: true }) // "1 hour 1 minute 0 seconds"
255
- * formatDuration(1400, { format: "fractional" }) // "1.4s"
256
- * formatDuration(45300, { format: "fractional" }) // "45.3s"
257
- * formatDuration(64400, { format: "fractional" }) // "1m 4.4s"
258
- */
259
- declare const formatDuration: (ms: number | null | undefined, options?: DurationOptions) => string;
260
- type DateInput = Date | string | number;
261
- type DateFormatStyle = "iso" | "short" | "medium" | "long" | "relative" | "year";
262
- type DateOptions = {
263
- /** Predefined format style */
264
- style?: DateFormatStyle;
265
- /** Custom date-fns format string (overrides style) */
266
- pattern?: string;
267
- /** Include time component */
268
- includeTime?: boolean;
269
- };
270
- /**
271
- * Flexible date formatter that handles multiple input types and format styles
272
- * Supports ISO strings, timestamps, and Date objects with intelligent defaults
273
- * @example
274
- * // Date formatting with smart input handling
275
- * formatDate(new Date()) // "Dec 1, 2023"
276
- * formatDate("2023-12-01") // "Dec 1, 2023"
277
- * formatDate(1701388800000) // "Dec 1, 2023"
278
- * formatDate(date, { style: "short" }) // "12/1/23"
279
- * formatDate(date, { style: "long" }) // "December 1, 2023"
280
- * formatDate(date, { includeTime: true }) // "Dec 1, 2023 3:30 PM"
281
- * formatDate(date, { pattern: "yyyy-MM-dd" }) // Custom format
282
- */
283
- declare const formatDate: (input: DateInput, options?: DateOptions) => string;
284
- type DateRangeInput = Date | string | number;
285
- type DateRangeOptions = {
286
- /** Reference date for today checks (defaults to new Date()) */
287
- now?: Date;
288
- /** Show time segment when start and end are the same day (default: true) */
289
- showTimeWhenSameDay?: boolean;
290
- /** If true, appends (today) next to whichever date equals today (default: true) */
291
- markToday?: boolean;
292
- /** Custom label for today marker (default: "today") */
293
- todayLabel?: string;
294
- /** Separator between start and end segments (default: " - ") */
295
- separator?: string;
296
- /** Month text style (default: "short") */
297
- monthFormat?: "short" | "long";
298
- /** Lowercase am/pm in time output (default: true) */
299
- lowercaseAmPm?: boolean;
300
- /** Locale for date-fns formatter */
301
- locale?: Locale;
302
- };
303
- /**
304
- * Formats a date range according to thread rules:
305
- * - Same day: "MMM d (today), h:mma - h:mma" (am/pm lowercase, hyphen between times)
306
- * - Different day, same month/year: "MMM d - d (today), yyyy"
307
- * - Different month, same year: "MMM d - MMM d (today), yyyy"
308
- * - Different year: "MMM d, yyyy - MMM d, yyyy" (append (today) next to the correct day if applicable)
309
- *
310
- * Notes:
311
- * - "(today)" is appended next to whichever date matches today.
312
- * - Times are shown only when start and end are the same calendar day.
313
- */
314
- declare const formatDateRange: (startInput: DateRangeInput, endInput: DateRangeInput, options?: DateRangeOptions) => string;
315
- declare const formatThreadDateRange: (startInput: DateRangeInput, endInput: DateRangeInput, options?: DateRangeOptions) => string;
316
- type TimeUnit = "seconds" | "minutes" | "hours" | "days" | "weeks" | "months" | "years" | "businessDays";
317
- type TimeAdjustment = Partial<Record<TimeUnit, number>>;
318
- /**
319
- * Creates a new date by adding specified time units to a base date
320
- * Defaults to current date if no base date provided
321
- * @example
322
- * // Date manipulation
323
- * adjustDate({ hours: 2 }) // 2 hours from now
324
- * adjustDate({ days: -7, hours: 3 }, someDate) // (7 days ago + 3 hours) from someDate
325
- */
326
- declare const adjustDate: (adjustment: TimeAdjustment, baseDate?: Date) => Date;
327
- /**
328
- * Promise-based delay utility for async operations
329
- */
330
- declare const sleep$1: (ms: number) => Promise<void>;
331
- /**
332
- * Gets the current timestamp in milliseconds
333
- */
334
- declare const now: () => number;
335
- /**
336
- * Converts various time units to milliseconds
337
- * @example
338
- * const ms = toMs(5, "minutes") // Convert 5 minutes to milliseconds
339
- */
340
- declare const toMs: (value: number, unit?: Exclude<TimeUnit, "businessDays">) => number;
341
-
342
- declare const time_adjustDate: typeof adjustDate;
343
- declare const time_formatDate: typeof formatDate;
344
- declare const time_formatDateRange: typeof formatDateRange;
345
- declare const time_formatDuration: typeof formatDuration;
346
- declare const time_formatThreadDateRange: typeof formatThreadDateRange;
347
- declare const time_now: typeof now;
348
- declare const time_toMs: typeof toMs;
349
- declare namespace time {
350
- export { time_adjustDate as adjustDate, time_formatDate as formatDate, time_formatDateRange as formatDateRange, time_formatDuration as formatDuration, time_formatThreadDateRange as formatThreadDateRange, time_now as now, sleep$1 as sleep, time_toMs as toMs };
351
- }
352
-
353
- /**
354
- * Throttle a function call
355
- * @param fn
356
- * @param ms
357
- * @returns
358
- */
359
- declare const throttle: (fn: any, ms: number) => (...args: any[]) => void;
360
- /**
361
- * Ensure code is only triggered once per user input.
362
- * The debounce forces another function to wait a certain amount of time before running again.
363
- * Its purpose is to prevent a function from being called several times in succession.
364
- * @param fn
365
- * @param timeout
366
- * @returns
367
- */
368
- declare const debounce: <T extends any[]>(fn: (...args: T) => any, timeout: number) => ((...args: T) => void);
369
- /**
370
- * Sleep for x milliseconds.
371
- * @param ms
372
- * @returns
373
- */
374
- declare const sleep: (ms: number) => Promise<void>;
375
- /**
376
- * Async pool for concurrent iteration with concurrency limit
377
- * @example
378
- * ```
379
- * for await (const ms of asyncPool(2, [1000, 5000, 3000, 2000], ms => sleep(ms))) {
380
- * console.log(ms);
381
- * }
382
- * ```
383
- * @param concurrency
384
- * @param iterable
385
- * @param iterator_fn
386
- */
387
- declare function asyncPool<T>(concurrency: number, iterable: T[], iterator_fn: (x: T, xs: T[]) => any): AsyncGenerator<any, void, unknown>;
388
-
389
- declare const flow_asyncPool: typeof asyncPool;
390
- declare const flow_debounce: typeof debounce;
391
- declare const flow_sleep: typeof sleep;
392
- declare const flow_throttle: typeof throttle;
393
- declare namespace flow {
394
- export { flow_asyncPool as asyncPool, flow_debounce as debounce, flow_sleep as sleep, flow_throttle as throttle };
395
- }
396
-
397
- /**
398
- * Randomly pick an item from an array.
399
- * @param xs
400
- * @returns
401
- */
402
- declare const item: <T>(xs: T[]) => T | undefined;
403
- type RandProps = {
404
- min?: number;
405
- max?: number;
406
- };
407
- /**
408
- * Generate a random number (supposedly more random than v1)
409
- * @param props
410
- * @returns
411
- */
412
- declare const num: (props?: RandProps) => number;
413
- /**
414
- * The Fisher-Yates shuffle is the most efficient algorithm for that purpose.
415
- * @param xs
416
- * @returns
417
- */
418
- declare const shuffle: <T>(xs: T[]) => T[];
419
- /**
420
- * Randomly return true or false.
421
- * @returns
422
- */
423
- declare const coinFlip: () => boolean;
424
- /**
425
- * Generate a random date.
426
- * 10000000000 keeps the date to within the current year.
427
- * The more 0s, the greater the range.
428
- * @returns
429
- */
430
- declare const date: () => Date;
431
- /**
432
- * Generate a random hex color.
433
- * @returns
434
- */
435
- declare const hexColor: () => string;
436
-
437
- declare const random_coinFlip: typeof coinFlip;
438
- declare const random_date: typeof date;
439
- declare const random_hexColor: typeof hexColor;
440
- declare const random_item: typeof item;
441
- declare const random_num: typeof num;
442
- declare const random_shuffle: typeof shuffle;
443
- declare namespace random {
444
- export { random_coinFlip as coinFlip, random_date as date, random_hexColor as hexColor, random_item as item, random_num as num, random_shuffle as shuffle };
445
- }
446
-
447
- declare const log: (...values: unknown[]) => void;
448
- declare const info: (...values: unknown[]) => void;
449
- declare const warn: (...values: unknown[]) => void;
450
- declare const error: (...values: unknown[]) => void;
451
-
452
- declare const log$1_error: typeof error;
453
- declare const log$1_info: typeof info;
454
- declare const log$1_log: typeof log;
455
- declare const log$1_warn: typeof warn;
456
- declare namespace log$1 {
457
- export { log$1_error as error, log$1_info as info, log$1_log as log, log$1_warn as warn };
458
- }
459
-
460
- export { log$1 as a, dict as d, flow as f, int as i, list as l, money as m, random as r, str as s, time as t };