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
@@ -0,0 +1,112 @@
1
+ import type { Locale } from "date-fns";
2
+ type DurationFormat = "compact" | "full" | "clock" | "fractional";
3
+ type DurationOptions = {
4
+ /** Format style: 'compact' (1h 2m), 'full' (1 hour 2 minutes), 'clock' (01:02:03), 'fractional' (1.4s, 1m4.4s) */
5
+ format?: DurationFormat;
6
+ /** Show zero values for intermediate units (e.g., "1h 0m 30s" vs "1h 30s") */
7
+ showZero?: boolean;
8
+ };
9
+ /**
10
+ * Formats milliseconds into human-readable duration strings
11
+ * Supports compact (1h 2m), full (`1 hour 2 minutes`), clock (`01:02:03`), and fractional (1.4s, 1m4.4s) formats
12
+ *
13
+ * @param {Object} [options={}] - Configuration options
14
+ * @param {string} [options.format="clock"] - format
15
+ * @param {boolean} [options.showZero=false] - show zero prefix
16
+ *
17
+ * @example
18
+ * formatDuration(90000) // "1:30"
19
+ * formatDuration(3661000) // "1:01:01"
20
+ * formatDuration(90000, { format: "compact" }) // "1m 30s"
21
+ * formatDuration(90000, { format: "full" }) // "1 minute 30 seconds"
22
+ * formatDuration(3600000, { format: "compact" }) // "1h"
23
+ * formatDuration(3600000, { format: "compact", showZero: true }) // "1h 0m 0s"
24
+ * formatDuration(3660000, { format: "full", showZero: true }) // "1 hour 1 minute 0 seconds"
25
+ * formatDuration(1400, { format: "fractional" }) // "1.4s"
26
+ * formatDuration(45300, { format: "fractional" }) // "45.3s"
27
+ * formatDuration(64400, { format: "fractional" }) // "1m 4.4s"
28
+ */
29
+ export declare const formatDuration: (ms: number | null | undefined, options?: DurationOptions) => string;
30
+ type DateInput = Date | string | number;
31
+ type DateFormatStyle = "iso" | "short" | "medium" | "long" | "relative" | "year";
32
+ type DateOptions = {
33
+ /** Predefined format style */
34
+ style?: DateFormatStyle;
35
+ /** Custom date-fns format string (overrides style) */
36
+ pattern?: string;
37
+ /** Include time component */
38
+ includeTime?: boolean;
39
+ };
40
+ /**
41
+ * Flexible date formatter that handles multiple input types and format styles
42
+ * Supports ISO strings, timestamps, and Date objects with intelligent defaults
43
+ * @example
44
+ * // Date formatting with smart input handling
45
+ * formatDate(new Date()) // "Dec 1, 2023"
46
+ * formatDate("2023-12-01") // "Dec 1, 2023"
47
+ * formatDate(1701388800000) // "Dec 1, 2023"
48
+ * formatDate(date, { style: "short" }) // "12/1/23"
49
+ * formatDate(date, { style: "long" }) // "December 1, 2023"
50
+ * formatDate(date, { includeTime: true }) // "Dec 1, 2023 3:30 PM"
51
+ * formatDate(date, { pattern: "yyyy-MM-dd" }) // Custom format
52
+ */
53
+ export declare const formatDate: (input: DateInput, options?: DateOptions) => string;
54
+ type DateRangeInput = Date | string | number;
55
+ type DateRangeOptions = {
56
+ /** Reference date for today checks (defaults to new Date()) */
57
+ now?: Date;
58
+ /** Show time segment when start and end are the same day (default: true) */
59
+ showTimeWhenSameDay?: boolean;
60
+ /** If true, appends (today) next to whichever date equals today (default: true) */
61
+ markToday?: boolean;
62
+ /** Custom label for today marker (default: "today") */
63
+ todayLabel?: string;
64
+ /** Separator between start and end segments (default: " - ") */
65
+ separator?: string;
66
+ /** Month text style (default: "short") */
67
+ monthFormat?: "short" | "long";
68
+ /** Lowercase am/pm in time output (default: true) */
69
+ lowercaseAmPm?: boolean;
70
+ /** Locale for date-fns formatter */
71
+ locale?: Locale;
72
+ };
73
+ /**
74
+ * Formats a date range according to thread rules:
75
+ * - Same day: "MMM d (today), h:mma - h:mma" (am/pm lowercase, hyphen between times)
76
+ * - Different day, same month/year: "MMM d - d (today), yyyy"
77
+ * - Different month, same year: "MMM d - MMM d (today), yyyy"
78
+ * - Different year: "MMM d, yyyy - MMM d, yyyy" (append (today) next to the correct day if applicable)
79
+ *
80
+ * Notes:
81
+ * - "(today)" is appended next to whichever date matches today.
82
+ * - Times are shown only when start and end are the same calendar day.
83
+ */
84
+ export declare const formatDateRange: (startInput: DateRangeInput, endInput: DateRangeInput, options?: DateRangeOptions) => string;
85
+ export declare const formatThreadDateRange: (startInput: DateRangeInput, endInput: DateRangeInput, options?: DateRangeOptions) => string;
86
+ type TimeUnit = "seconds" | "minutes" | "hours" | "days" | "weeks" | "months" | "years" | "businessDays";
87
+ type TimeAdjustment = Partial<Record<TimeUnit, number>>;
88
+ /**
89
+ * Creates a new date by adding specified time units to a base date
90
+ * Defaults to current date if no base date provided
91
+ * @example
92
+ * // Date manipulation
93
+ * adjustDate({ hours: 2 }) // 2 hours from now
94
+ * adjustDate({ days: -7, hours: 3 }, someDate) // (7 days ago + 3 hours) from someDate
95
+ */
96
+ export declare const adjustDate: (adjustment: TimeAdjustment, baseDate?: Date) => Date;
97
+ /**
98
+ * Promise-based delay utility for async operations
99
+ */
100
+ export declare const sleep: (ms: number) => Promise<void>;
101
+ /**
102
+ * Gets the current timestamp in milliseconds
103
+ */
104
+ export declare const now: () => number;
105
+ /**
106
+ * Converts various time units to milliseconds
107
+ * @example
108
+ * const ms = toMs(5, "minutes") // Convert 5 minutes to milliseconds
109
+ */
110
+ export declare const toMs: (value: number, unit?: Exclude<TimeUnit, "businessDays">) => number;
111
+ export {};
112
+ //# sourceMappingURL=time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/shared/time.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAMvC,KAAK,cAAc,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,CAAC;AAElE,KAAK,eAAe,GAAG;IACrB,kHAAkH;IAClH,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,8EAA8E;IAC9E,QAAQ,CAA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AqB,WAiF/B,CAAC;AAGF,eAAO,MAAM,qBAAqB,GAChC,YAAY,cAAc,EAC1B,UAAU,cAAc,EACxB,UAAS,gBAAqB,WACmB,CAAC;AAMpD,KAAK,QAAQ,GACT,SAAS,GACT,SAAS,GACT,OAAO,GACP,MAAM,GACN,OAAO,GACP,QAAQ,GACR,OAAO,GACP,cAAc,CAAC;AAEnB,KAAK,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAExD;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GACrB,YAAY,cAAc,EAC1B,WAAU,IAAiB,SAe5B,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,KAAK,GAAI,IAAI,MAAM,KAAG,OAAO,CAAC,IAAI,CACI,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,GAAG,cAAmB,CAAC;AAEpC;;;;GAIG;AACH,eAAO,MAAM,IAAI,GACf,OAAO,MAAM,EACb,OAAM,OAAO,CAAC,QAAQ,EAAE,cAAc,CAAa,WAapD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qstd",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "Standard Block component and utilities library with Panda CSS",
5
5
  "author": "malin1",
6
6
  "license": "MIT",
@@ -41,22 +41,6 @@
41
41
  "sideEffects": [
42
42
  "dist/react/index.css"
43
43
  ],
44
- "scripts": {
45
- "build": "panda codegen && panda cssgen && tsup && node scripts/inject-css-import.js",
46
- "dev": "tsup --watch",
47
- "prepublishOnly": "pnpm build",
48
- "prepare:local": "pnpm build && cd playground && pnpm prepare",
49
- "test": "vitest run",
50
- "test:watch": "vitest",
51
- "test:all": "pnpx tsx tests/test-all.ts",
52
- "test:block": "node tests/test-block.tsx",
53
- "test:playground": "node tests/playground-e2e.mjs",
54
- "typecheck": "tsc --noEmit",
55
- "typecheck:perf": "tsc --noEmit --extendedDiagnostics",
56
- "typecheck:trace": "tsc --noEmit --generateTrace ./performance/ts-trace",
57
- "analyze:tsserver": "bash performance/analyze-tsserver.sh",
58
- "lint": "eslint ."
59
- },
60
44
  "peerDependencies": {
61
45
  "react": "^18.0.0 || ^19.0.0",
62
46
  "react-dom": "^18.0.0 || ^19.0.0"
@@ -112,5 +96,22 @@
112
96
  "bugs": {
113
97
  "url": "https://github.com/55cancri/qstd/issues"
114
98
  },
115
- "homepage": "https://github.com/55cancri/qstd#readme"
116
- }
99
+ "homepage": "https://github.com/55cancri/qstd#readme",
100
+ "scripts": {
101
+ "build": "panda codegen && panda cssgen && tsup && tsc -p tsconfig.build.json && node scripts/inject-css-import.js",
102
+ "build:js": "tsup",
103
+ "build:types": "tsc -p tsconfig.build.json",
104
+ "dev": "tsup --watch",
105
+ "prepare:local": "pnpm build && cd playground && pnpm prepare",
106
+ "test": "vitest run",
107
+ "test:watch": "vitest",
108
+ "test:all": "pnpx tsx tests/test-all.ts",
109
+ "test:block": "node tests/test-block.tsx",
110
+ "test:playground": "node tests/playground-e2e.mjs",
111
+ "typecheck": "tsc --noEmit",
112
+ "typecheck:perf": "tsc --noEmit --extendedDiagnostics",
113
+ "typecheck:trace": "tsc --noEmit --generateTrace ./performance/ts-trace",
114
+ "analyze:tsserver": "bash performance/analyze-tsserver.sh",
115
+ "lint": "eslint ."
116
+ }
117
+ }
@@ -1,75 +0,0 @@
1
- export { d as Dict, f as Flow, i as Int, l as List, a as Log, m as Money, r as Random, s as Str, t as Time } from '../log-ERvLs2Dx.cjs';
2
- import 'date-fns';
3
-
4
- /**
5
- * DOM manipulation utilities
6
- */
7
- /**
8
- * Get element by ID
9
- * @param id
10
- * @returns
11
- */
12
- declare const getElement: (id: string) => HTMLElement | null;
13
- /**
14
- * Query selector
15
- * @param selector
16
- * @returns
17
- */
18
- declare const querySelector: (selector: string) => Element | null;
19
- /**
20
- * Query selector all
21
- * @param selector
22
- * @returns
23
- */
24
- declare const querySelectorAll: (selector: string) => NodeListOf<Element>;
25
- /**
26
- * Scroll to top of page
27
- */
28
- declare const scrollToTop: () => void;
29
- /**
30
- * Scroll to coordinates
31
- * @param x
32
- * @param y
33
- */
34
- declare const scrollTo: (x: number, y: number) => void;
35
- /**
36
- * Get current scroll position
37
- * @returns
38
- */
39
- declare const getScrollPosition: () => {
40
- x: number;
41
- y: number;
42
- };
43
- /**
44
- * Check if element is in viewport
45
- * @param el
46
- * @returns
47
- */
48
- declare const isInViewport: (el: HTMLElement) => boolean;
49
- /**
50
- * Scroll element into view
51
- * @param el
52
- * @param options
53
- */
54
- declare const scrollIntoView: (el: HTMLElement, options?: ScrollIntoViewOptions) => void;
55
- /**
56
- * Copy text to clipboard
57
- * @param text
58
- * @returns
59
- */
60
- declare const copy: (text: string) => Promise<void>;
61
-
62
- declare const dom_copy: typeof copy;
63
- declare const dom_getElement: typeof getElement;
64
- declare const dom_getScrollPosition: typeof getScrollPosition;
65
- declare const dom_isInViewport: typeof isInViewport;
66
- declare const dom_querySelector: typeof querySelector;
67
- declare const dom_querySelectorAll: typeof querySelectorAll;
68
- declare const dom_scrollIntoView: typeof scrollIntoView;
69
- declare const dom_scrollTo: typeof scrollTo;
70
- declare const dom_scrollToTop: typeof scrollToTop;
71
- declare namespace dom {
72
- export { dom_copy as copy, dom_getElement as getElement, dom_getScrollPosition as getScrollPosition, dom_isInViewport as isInViewport, dom_querySelector as querySelector, dom_querySelectorAll as querySelectorAll, dom_scrollIntoView as scrollIntoView, dom_scrollTo as scrollTo, dom_scrollToTop as scrollToTop };
73
- }
74
-
75
- export { dom as Dom };