@gfazioli/mantine-clock 3.0.0 → 3.1.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.
Files changed (44) hide show
  1. package/README.md +8 -3
  2. package/dist/cjs/Clock.cjs +45 -533
  3. package/dist/cjs/Clock.cjs.map +1 -1
  4. package/dist/cjs/ClockDigital.cjs +21 -23
  5. package/dist/cjs/ClockDigital.cjs.map +1 -1
  6. package/dist/cjs/ClockDigitalMediaVariables.cjs +76 -0
  7. package/dist/cjs/ClockDigitalMediaVariables.cjs.map +1 -0
  8. package/dist/cjs/ClockFaceStatic.cjs +96 -0
  9. package/dist/cjs/ClockFaceStatic.cjs.map +1 -0
  10. package/dist/cjs/RealClock.cjs +379 -0
  11. package/dist/cjs/RealClock.cjs.map +1 -0
  12. package/dist/cjs/clock-utils.cjs +63 -0
  13. package/dist/cjs/clock-utils.cjs.map +1 -0
  14. package/dist/cjs/geometry.cjs +2 -2
  15. package/dist/cjs/geometry.cjs.map +1 -1
  16. package/dist/cjs/hooks/use-clock-count-down.cjs +2 -2
  17. package/dist/cjs/hooks/use-clock-count-down.cjs.map +1 -1
  18. package/dist/cjs/hooks/use-clock.cjs +2 -2
  19. package/dist/cjs/hooks/use-clock.cjs.map +1 -1
  20. package/dist/esm/Clock.mjs +44 -532
  21. package/dist/esm/Clock.mjs.map +1 -1
  22. package/dist/esm/ClockDigital.mjs +22 -24
  23. package/dist/esm/ClockDigital.mjs.map +1 -1
  24. package/dist/esm/ClockDigitalMediaVariables.mjs +74 -0
  25. package/dist/esm/ClockDigitalMediaVariables.mjs.map +1 -0
  26. package/dist/esm/ClockFaceStatic.mjs +94 -0
  27. package/dist/esm/ClockFaceStatic.mjs.map +1 -0
  28. package/dist/esm/RealClock.mjs +377 -0
  29. package/dist/esm/RealClock.mjs.map +1 -0
  30. package/dist/esm/clock-utils.mjs +56 -0
  31. package/dist/esm/clock-utils.mjs.map +1 -0
  32. package/dist/esm/geometry.mjs +2 -2
  33. package/dist/esm/geometry.mjs.map +1 -1
  34. package/dist/esm/hooks/use-clock-count-down.mjs +2 -2
  35. package/dist/esm/hooks/use-clock-count-down.mjs.map +1 -1
  36. package/dist/esm/hooks/use-clock.mjs +2 -2
  37. package/dist/esm/hooks/use-clock.mjs.map +1 -1
  38. package/dist/types/Clock.d.ts +3 -3
  39. package/dist/types/ClockDigital.d.ts +5 -5
  40. package/dist/types/ClockDigitalMediaVariables.d.ts +9 -0
  41. package/dist/types/ClockFaceStatic.d.ts +18 -0
  42. package/dist/types/RealClock.d.ts +12 -0
  43. package/dist/types/clock-utils.d.ts +23 -0
  44. package/package.json +13 -7
package/README.md CHANGED
@@ -229,11 +229,16 @@ function ControllableCountdown() {
229
229
 
230
230
  - **Real-time Updates**: Automatic time synchronization with configurable frequency
231
231
  - **Timezone Support**: Global timezone compatibility with IANA timezone database
232
- - **Customizable Styling**: Full control over appearance and theming
232
+ - **Clock.Digital**: Compound component for digital clock display with AM/PM, date, and custom separators
233
+ - **Responsive Size**: Breakpoint-based responsive sizing (`{ base: "sm", md: "lg" }`) using Mantine's native CSS media queries
234
+ - **Clock Shapes**: Circle and rounded-rectangle (Apple Watch style) with configurable aspect ratio
235
+ - **Sector Arcs**: Visual arcs aligned to seconds, minutes, and hours hands
236
+ - **Custom Hand Rendering**: Full control via render props for hour, minute, and second hands
237
+ - **Mount Animation**: Entrance animation from 12:00 to current time
238
+ - **Countdown Timer**: `useClockCountDown` hook with target dates, durations, and completion callbacks
239
+ - **Customizable Styling**: Full control over appearance via Styles API and CSS variables
233
240
  - **TypeScript Support**: Complete type definitions for better developer experience
234
241
  - **Accessibility**: Built with WCAG compliance and screen reader support
235
- - **Performance Optimized**: Efficient updates with minimal re-renders
236
- - **Responsive Design**: Adapts to different screen sizes automatically
237
242
 
238
243
  ## Sponsor
239
244
 
@@ -2,35 +2,21 @@
2
2
  'use strict';
3
3
 
4
4
  var dayjs = require('dayjs');
5
- var timezonePlugin = require('dayjs/plugin/timezone');
5
+ var timezone = require('dayjs/plugin/timezone');
6
6
  var utc = require('dayjs/plugin/utc');
7
7
  var React = require('react');
8
8
  var core = require('@mantine/core');
9
9
  var hooks = require('@mantine/hooks');
10
+ var clockUtils = require('./clock-utils.cjs');
10
11
  var ClockDigital = require('./ClockDigital.cjs');
12
+ var ClockFaceStatic = require('./ClockFaceStatic.cjs');
11
13
  var geometry = require('./geometry.cjs');
14
+ var RealClock = require('./RealClock.cjs');
12
15
  var Clock_module = require('./Clock.module.css.cjs');
13
16
 
14
17
  dayjs.extend(utc);
15
- dayjs.extend(timezonePlugin);
16
- const TICK_OFFSET_RATIO = 0.028;
17
- const CENTER_DOT_RATIO = 0.034;
18
- const COUNTERWEIGHT_MULTIPLIER = 3;
19
- const round2 = (n) => Math.round(n * 100) / 100;
20
- const defaultProps = {
21
- size: 400,
22
- hourHandSize: 0.017,
23
- minuteHandSize: 0.011,
24
- secondHandSize: 6e-3,
25
- hourHandLength: 0.4,
26
- minuteHandLength: 0.57,
27
- secondHandLength: 0.68,
28
- secondHandOpacity: 1,
29
- minuteHandOpacity: 1,
30
- hourHandOpacity: 1,
31
- secondHandBehavior: "tick",
32
- running: true
33
- };
18
+ dayjs.extend(timezone);
19
+ const defaultProps = clockUtils.defaultClockProps;
34
20
  const defaultClockSizes = {
35
21
  xs: 100,
36
22
  sm: 200,
@@ -38,513 +24,29 @@ const defaultClockSizes = {
38
24
  lg: 480,
39
25
  xl: 512
40
26
  };
41
- const buildCssVars = (theme, clockSizePx, props) => {
27
+ const varsResolver = core.createVarsResolver((theme, props) => {
42
28
  const c = (color) => core.parseThemeColor({ color, theme }).value;
43
29
  return {
44
- "--clock-size": clockSizePx,
45
- "--clock-color": c(props.color || ""),
46
- "--clock-hour-ticks-color": c(props.hourTicksColor || ""),
47
- "--clock-hour-ticks-opacity": round2(props.hourTicksOpacity ?? 1).toString(),
48
- "--clock-minute-ticks-color": c(props.minuteTicksColor || ""),
49
- "--clock-minute-ticks-opacity": round2(props.minuteTicksOpacity ?? 1).toString(),
50
- "--clock-primary-numbers-color": c(props.primaryNumbersColor || ""),
51
- "--clock-primary-numbers-opacity": round2(props.primaryNumbersOpacity ?? 1).toString(),
52
- "--clock-secondary-numbers-color": c(props.secondaryNumbersColor || ""),
53
- "--clock-secondary-numbers-opacity": round2(props.secondaryNumbersOpacity ?? 1).toString(),
54
- "--clock-second-hand-color": c(props.secondHandColor || ""),
55
- "--clock-minute-hand-color": c(props.minuteHandColor || ""),
56
- "--clock-hour-hand-color": c(props.hourHandColor || ""),
57
- "--clock-seconds-arc-color": c(props.secondsArcColor || props.secondHandColor || ""),
58
- "--clock-minutes-arc-color": c(props.minutesArcColor || props.minuteHandColor || ""),
59
- "--clock-hours-arc-color": c(props.hoursArcColor || props.hourHandColor || "")
60
- };
61
- };
62
- const varsResolver = core.createVarsResolver((theme, props) => {
63
- const { size } = props;
64
- if (size === "auto") {
65
- return { root: buildCssVars(theme, "400px", props) };
66
- }
67
- const sizeValue = size || "md";
68
- const clockSize = typeof sizeValue === "string" && sizeValue in defaultClockSizes ? defaultClockSizes[sizeValue] : sizeValue;
69
- const effectiveSize = Math.round(core.px(core.getSize(clockSize, "clock-size")));
70
- return { root: buildCssVars(theme, `${effectiveSize}px`, props) };
71
- });
72
- const parseTimeValue = (value) => {
73
- if (!value) {
74
- return null;
75
- }
76
- if (value instanceof Date) {
77
- return value;
78
- }
79
- if (dayjs.isDayjs(value)) {
80
- return value.toDate();
81
- }
82
- if (typeof value === "string") {
83
- const timeRegex = /^(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/;
84
- const match = value.match(timeRegex);
85
- if (match) {
86
- const hours = parseInt(match[1], 10);
87
- const minutes = parseInt(match[2], 10);
88
- const seconds = parseInt(match[3] || "0", 10);
89
- const date = /* @__PURE__ */ new Date();
90
- date.setHours(hours, minutes, seconds, 0);
91
- return date;
30
+ root: {
31
+ "--clock-size": void 0,
32
+ "--clock-color": c(props.color || ""),
33
+ "--clock-hour-ticks-color": c(props.hourTicksColor || ""),
34
+ "--clock-hour-ticks-opacity": clockUtils.round2(props.hourTicksOpacity ?? 1).toString(),
35
+ "--clock-minute-ticks-color": c(props.minuteTicksColor || ""),
36
+ "--clock-minute-ticks-opacity": clockUtils.round2(props.minuteTicksOpacity ?? 1).toString(),
37
+ "--clock-primary-numbers-color": c(props.primaryNumbersColor || ""),
38
+ "--clock-primary-numbers-opacity": clockUtils.round2(props.primaryNumbersOpacity ?? 1).toString(),
39
+ "--clock-secondary-numbers-color": c(props.secondaryNumbersColor || ""),
40
+ "--clock-secondary-numbers-opacity": clockUtils.round2(props.secondaryNumbersOpacity ?? 1).toString(),
41
+ "--clock-second-hand-color": c(props.secondHandColor || ""),
42
+ "--clock-minute-hand-color": c(props.minuteHandColor || ""),
43
+ "--clock-hour-hand-color": c(props.hourHandColor || ""),
44
+ "--clock-seconds-arc-color": c(props.secondsArcColor || props.secondHandColor || ""),
45
+ "--clock-minutes-arc-color": c(props.minutesArcColor || props.minuteHandColor || ""),
46
+ "--clock-hours-arc-color": c(props.hoursArcColor || props.hourHandColor || "")
92
47
  }
93
- const parsed = new Date(value);
94
- if (!isNaN(parsed.getTime())) {
95
- return parsed;
96
- }
97
- }
98
- return null;
99
- };
100
- const ClockFaceStatic = React.memo(
101
- ({
102
- getStyles,
103
- effectiveSize,
104
- geometry,
105
- hourTicksOpacity,
106
- minuteTicksOpacity,
107
- primaryNumbersOpacity,
108
- secondaryNumbersOpacity,
109
- hourNumbersDistance = 0.75,
110
- primaryNumbersProps,
111
- secondaryNumbersProps
112
- }) => {
113
- const clockRadius = Math.round(effectiveSize / 2);
114
- const numberRadius = Math.round(clockRadius * hourNumbersDistance);
115
- const tickOffset = Math.round(effectiveSize * TICK_OFFSET_RATIO);
116
- return /* @__PURE__ */ React.createElement(core.Box, { ...getStyles("hourMarks") }, (hourTicksOpacity ?? 1) !== 0 && Array.from({ length: 12 }, (_, i) => {
117
- const pos = geometry.tickPosition(i, 12, tickOffset);
118
- const tickStyle = pos.positioning === "absolute" ? {
119
- top: pos.y,
120
- left: pos.x,
121
- transformOrigin: pos.transformOrigin,
122
- transform: `translate(-50%, -50%) rotate(${pos.angle}deg)`
123
- } : {
124
- top: pos.y,
125
- left: "50%",
126
- transformOrigin: pos.transformOrigin,
127
- transform: `translateX(-50%) rotate(${pos.angle}deg)`
128
- };
129
- return /* @__PURE__ */ React.createElement(core.Box, { key: `hour-tick-${i}`, ...getStyles("hourTick", { style: tickStyle }) });
130
- }), (minuteTicksOpacity ?? 1) !== 0 && Array.from({ length: 60 }, (_, i) => {
131
- if (i % 5 === 0) {
132
- return null;
133
- }
134
- const pos = geometry.tickPosition(i, 60, tickOffset);
135
- const tickStyle = pos.positioning === "absolute" ? {
136
- top: pos.y,
137
- left: pos.x,
138
- transformOrigin: pos.transformOrigin,
139
- transform: `translate(-50%, -50%) rotate(${pos.angle}deg)`
140
- } : {
141
- top: pos.y,
142
- left: "50%",
143
- transformOrigin: pos.transformOrigin,
144
- transform: `translateX(-50%) rotate(${pos.angle}deg)`
145
- };
146
- return /* @__PURE__ */ React.createElement(core.Box, { key: `minute-tick-${i}`, ...getStyles("minuteTick", { style: tickStyle }) });
147
- }), (primaryNumbersOpacity ?? 1) !== 0 && [12, 3, 6, 9].map((num) => {
148
- const hourIndex = num === 12 ? 0 : num;
149
- const pos = geometry.numberPosition(hourIndex, numberRadius);
150
- return /* @__PURE__ */ React.createElement(
151
- core.Text,
152
- {
153
- key: `primary-number-${num}`,
154
- ...primaryNumbersProps,
155
- ...getStyles("primaryNumber", {
156
- className: getStyles("number").className,
157
- style: {
158
- left: pos.x,
159
- top: pos.y
160
- }
161
- })
162
- },
163
- num
164
- );
165
- }), (secondaryNumbersOpacity ?? 1) !== 0 && [1, 2, 4, 5, 7, 8, 10, 11].map((num) => {
166
- const pos = geometry.numberPosition(num, numberRadius);
167
- return /* @__PURE__ */ React.createElement(
168
- core.Text,
169
- {
170
- key: `secondary-number-${num}`,
171
- ...secondaryNumbersProps,
172
- ...getStyles("secondaryNumber", {
173
- className: getStyles("number").className,
174
- style: {
175
- left: pos.x,
176
- top: pos.y
177
- }
178
- })
179
- },
180
- num
181
- );
182
- }));
183
- }
184
- );
185
- ClockFaceStatic.displayName = "ClockFaceStatic";
186
- const RealClock = React.memo((props) => {
187
- const {
188
- time,
189
- timezone: timezone2,
190
- getStyles,
191
- effectiveSize,
192
- geometry: geometry$1,
193
- hourHandSize,
194
- minuteHandSize,
195
- secondHandSize,
196
- hourHandLength,
197
- minuteHandLength,
198
- secondHandLength,
199
- secondHandBehavior,
200
- secondHandOpacity,
201
- minuteHandOpacity,
202
- hourHandOpacity,
203
- hourTicksOpacity,
204
- minuteTicksOpacity,
205
- primaryNumbersOpacity,
206
- secondaryNumbersOpacity,
207
- hourNumbersDistance = 0.75,
208
- // Default distance for hour numbers
209
- primaryNumbersProps,
210
- secondaryNumbersProps,
211
- withSecondsArc,
212
- secondsArcFrom,
213
- secondsArcDirection = "clockwise",
214
- withMinutesArc,
215
- minutesArcFrom,
216
- minutesArcDirection = "clockwise",
217
- withHoursArc,
218
- hoursArcFrom,
219
- hoursArcDirection = "clockwise",
220
- secondsArcOpacity,
221
- minutesArcOpacity,
222
- hoursArcOpacity,
223
- renderHourHand,
224
- renderMinuteHand,
225
- renderSecondHand,
226
- sectors,
227
- faceContent,
228
- animateOnMount,
229
- animateOnMountDuration
230
- } = props;
231
- const timezoneTime = timezone2 && timezone2 !== "" ? dayjs(time).tz(timezone2) : dayjs(time);
232
- const hours = timezoneTime.hour() % 12;
233
- const minutes = timezoneTime.minute();
234
- const seconds = timezoneTime.second();
235
- const milliseconds = timezoneTime.millisecond();
236
- const hourAngle = hours * 30 + minutes * 0.5;
237
- const minuteAngle = minutes * 6;
238
- let secondAngle = 0;
239
- switch (secondHandBehavior) {
240
- case "tick-half":
241
- secondAngle = (seconds + Math.floor(milliseconds / 500) * 0.5) * 6;
242
- break;
243
- case "tick-high-freq":
244
- secondAngle = (seconds + Math.floor(milliseconds / 125) * 0.125) * 6;
245
- break;
246
- case "smooth":
247
- secondAngle = (seconds + milliseconds / 1e3) * 6;
248
- break;
249
- case "tick":
250
- default:
251
- secondAngle = seconds * 6;
252
- break;
253
- }
254
- const [mountPhase, setMountPhase] = React.useState(
255
- animateOnMount ? "initial" : "done"
256
- );
257
- React.useEffect(() => {
258
- if (mountPhase === "initial") {
259
- const rafId = requestAnimationFrame(() => {
260
- setMountPhase("animating");
261
- });
262
- return () => cancelAnimationFrame(rafId);
263
- } else if (mountPhase === "animating") {
264
- const timer = setTimeout(
265
- () => {
266
- setMountPhase("done");
267
- },
268
- (animateOnMountDuration ?? 1e3) + 50
269
- );
270
- return () => clearTimeout(timer);
271
- }
272
- }, [mountPhase, animateOnMountDuration]);
273
- const showTransition = mountPhase === "animating";
274
- const handAngles = mountPhase === "initial" ? { hour: 0, minute: 0, second: 0 } : { hour: round2(hourAngle), minute: round2(minuteAngle), second: round2(secondAngle) };
275
- const transitionStyle = showTransition ? {
276
- transition: `transform ${animateOnMountDuration ?? 1e3}ms cubic-bezier(0.34, 1.56, 0.64, 1)`
277
- } : void 0;
278
- const size = effectiveSize;
279
- const { centerX, centerY } = geometry$1;
280
- const calculatedHourHandLength = geometry$1.handLength(
281
- hourHandLength ?? defaultProps.hourHandLength
282
- );
283
- const calculatedMinuteHandLength = geometry$1.handLength(
284
- minuteHandLength ?? defaultProps.minuteHandLength
285
- );
286
- const calculatedSecondHandLength = geometry$1.handLength(
287
- secondHandLength ?? defaultProps.secondHandLength
288
- );
289
- const centerSize = Math.round(size * CENTER_DOT_RATIO);
290
- const showSecArc = withSecondsArc === true && (secondsArcOpacity ?? 1) !== 0;
291
- const showMinArc = withMinutesArc === true && (minutesArcOpacity ?? 1) !== 0;
292
- const showHrArc = withHoursArc === true && (hoursArcOpacity ?? 1) !== 0;
293
- const counterweightWidth = round2(
294
- size * (secondHandSize ?? defaultProps.secondHandSize) * COUNTERWEIGHT_MULTIPLIER
295
- );
296
- return /* @__PURE__ */ React.createElement(
297
- core.Box,
298
- {
299
- ...getStyles("clockContainer", {
300
- style: {
301
- width: geometry$1.width,
302
- height: geometry$1.height
303
- }
304
- })
305
- },
306
- /* @__PURE__ */ React.createElement(
307
- core.Box,
308
- {
309
- ...getStyles("glassWrapper", {
310
- style: { width: geometry$1.width, height: geometry$1.height }
311
- })
312
- },
313
- /* @__PURE__ */ React.createElement(
314
- core.Box,
315
- {
316
- ...getStyles("clockFace", {
317
- style: {
318
- width: geometry$1.width,
319
- height: geometry$1.height,
320
- borderRadius: geometry$1.borderRadius(),
321
- clipPath: geometry$1.clipPath()
322
- }
323
- })
324
- },
325
- faceContent && /* @__PURE__ */ React.createElement(core.Box, { ...getStyles("faceContent") }, faceContent),
326
- (showSecArc || showMinArc || showHrArc || sectors && sectors.length > 0) && /* @__PURE__ */ React.createElement(
327
- "svg",
328
- {
329
- ...getStyles("arcsLayer", {
330
- style: { width: geometry$1.width, height: geometry$1.height }
331
- }),
332
- viewBox: `0 0 ${geometry$1.width} ${geometry$1.height}`
333
- },
334
- sectors && sectors.length > 0 && sectors.map((sector, idx) => {
335
- const fromDate = parseTimeValue(sector.from);
336
- const toDate = parseTimeValue(sector.to);
337
- if (!fromDate || !toDate) {
338
- return null;
339
- }
340
- const startAngle = geometry.hourAngleFromDate(fromDate, timezone2);
341
- const endAngle = geometry.hourAngleFromDate(toDate, timezone2);
342
- const sectorRadius = calculatedMinuteHandLength;
343
- return /* @__PURE__ */ React.createElement(
344
- "path",
345
- {
346
- key: `sector-${idx}`,
347
- d: geometry$1.sectorPath(startAngle, endAngle, sectorRadius, "clockwise"),
348
- fill: sector.color || "var(--clock-second-hand-color-resolved)",
349
- fillOpacity: round2(sector.opacity ?? 0.2),
350
- style: sector.interactive ? { cursor: "pointer" } : void 0,
351
- role: sector.interactive ? "button" : void 0,
352
- tabIndex: sector.interactive ? 0 : void 0,
353
- "aria-label": sector.interactive ? sector.label : void 0,
354
- onClick: sector.interactive && sector.onClick ? () => sector.onClick(sector) : void 0,
355
- onKeyDown: sector.interactive && sector.onClick ? (e) => {
356
- if (e.key === "Enter" || e.key === " ") {
357
- e.preventDefault();
358
- sector.onClick(sector);
359
- }
360
- } : void 0,
361
- onMouseEnter: sector.interactive && sector.onHover ? () => sector.onHover(sector, true) : void 0,
362
- onMouseLeave: sector.interactive && sector.onHover ? () => sector.onHover(sector, false) : void 0
363
- },
364
- sector.label && /* @__PURE__ */ React.createElement("title", null, sector.label)
365
- );
366
- }),
367
- showHrArc && /* @__PURE__ */ React.createElement(
368
- "path",
369
- {
370
- d: geometry$1.sectorPath(
371
- geometry.hourAngleFromDate(parseTimeValue(hoursArcFrom) ?? null, timezone2),
372
- hourAngle,
373
- calculatedHourHandLength,
374
- hoursArcDirection
375
- ),
376
- fill: "var(--clock-hours-arc-color-resolved)",
377
- fillOpacity: round2(hoursArcOpacity ?? 1)
378
- }
379
- ),
380
- showMinArc && /* @__PURE__ */ React.createElement(
381
- "path",
382
- {
383
- d: geometry$1.sectorPath(
384
- geometry.minuteAngleFromDate(parseTimeValue(minutesArcFrom) ?? null, timezone2),
385
- minuteAngle,
386
- calculatedMinuteHandLength,
387
- minutesArcDirection
388
- ),
389
- fill: "var(--clock-minutes-arc-color-resolved)",
390
- fillOpacity: round2(minutesArcOpacity ?? 1)
391
- }
392
- ),
393
- showSecArc && /* @__PURE__ */ React.createElement(
394
- "path",
395
- {
396
- d: geometry$1.sectorPath(
397
- geometry.secondAngleFromDate(parseTimeValue(secondsArcFrom) ?? null, timezone2),
398
- secondAngle,
399
- calculatedSecondHandLength,
400
- secondsArcDirection
401
- ),
402
- fill: "var(--clock-seconds-arc-color-resolved)",
403
- fillOpacity: round2(secondsArcOpacity ?? 1)
404
- }
405
- )
406
- ),
407
- /* @__PURE__ */ React.createElement(
408
- ClockFaceStatic,
409
- {
410
- getStyles,
411
- effectiveSize: size,
412
- geometry: geometry$1,
413
- hourTicksOpacity,
414
- minuteTicksOpacity,
415
- primaryNumbersOpacity,
416
- secondaryNumbersOpacity,
417
- hourNumbersDistance,
418
- primaryNumbersProps,
419
- secondaryNumbersProps
420
- }
421
- ),
422
- (hourHandOpacity ?? defaultProps.hourHandOpacity) !== 0 && (renderHourHand ? renderHourHand({
423
- angle: handAngles.hour,
424
- length: calculatedHourHandLength,
425
- width: round2(size * (hourHandSize ?? defaultProps.hourHandSize)),
426
- centerX: geometry$1.centerX,
427
- centerY: geometry$1.centerY,
428
- clockSize: size
429
- }) : /* @__PURE__ */ React.createElement(
430
- core.Box,
431
- {
432
- ...getStyles("hand", {
433
- className: getStyles("hourHand").className,
434
- style: {
435
- width: round2(size * (hourHandSize ?? defaultProps.hourHandSize)),
436
- height: calculatedHourHandLength,
437
- opacity: round2(hourHandOpacity ?? defaultProps.hourHandOpacity),
438
- bottom: centerY,
439
- left: centerX,
440
- marginLeft: round2(-(size * (hourHandSize ?? defaultProps.hourHandSize)) / 2),
441
- borderRadius: `${round2(size * (hourHandSize ?? defaultProps.hourHandSize))}px`,
442
- transform: `rotate(${handAngles.hour}deg)`,
443
- ...transitionStyle
444
- }
445
- })
446
- }
447
- )),
448
- (minuteHandOpacity ?? defaultProps.minuteHandOpacity) !== 0 && (renderMinuteHand ? renderMinuteHand({
449
- angle: handAngles.minute,
450
- length: calculatedMinuteHandLength,
451
- width: round2(size * (minuteHandSize ?? defaultProps.minuteHandSize)),
452
- centerX: geometry$1.centerX,
453
- centerY: geometry$1.centerY,
454
- clockSize: size
455
- }) : /* @__PURE__ */ React.createElement(
456
- core.Box,
457
- {
458
- ...getStyles("hand", {
459
- className: getStyles("minuteHand").className,
460
- style: {
461
- width: round2(size * (minuteHandSize ?? defaultProps.minuteHandSize)),
462
- height: calculatedMinuteHandLength,
463
- opacity: round2(minuteHandOpacity ?? defaultProps.minuteHandOpacity),
464
- bottom: centerY,
465
- left: centerX,
466
- marginLeft: round2(
467
- -(size * (minuteHandSize ?? defaultProps.minuteHandSize)) / 2
468
- ),
469
- borderRadius: `${round2(size * (minuteHandSize ?? defaultProps.minuteHandSize))}px`,
470
- transform: `rotate(${handAngles.minute}deg)`,
471
- ...transitionStyle
472
- }
473
- })
474
- }
475
- )),
476
- (secondHandOpacity ?? defaultProps.secondHandOpacity) !== 0 && (renderSecondHand ? renderSecondHand({
477
- angle: handAngles.second,
478
- length: calculatedSecondHandLength,
479
- width: round2(size * (secondHandSize ?? defaultProps.secondHandSize)),
480
- centerX: geometry$1.centerX,
481
- centerY: geometry$1.centerY,
482
- clockSize: size
483
- }) : /* @__PURE__ */ React.createElement(
484
- core.Box,
485
- {
486
- ...getStyles("secondHandContainer", {
487
- style: {
488
- width: round2(size * (secondHandSize ?? defaultProps.secondHandSize)),
489
- height: calculatedSecondHandLength,
490
- top: centerY - calculatedSecondHandLength,
491
- left: centerX,
492
- marginLeft: round2(
493
- -(size * (secondHandSize ?? defaultProps.secondHandSize)) / 2
494
- ),
495
- transformOrigin: `${round2(size * (secondHandSize ?? defaultProps.secondHandSize) / 2)}px ${calculatedSecondHandLength}px`,
496
- transform: `rotate(${handAngles.second}deg)`,
497
- ...transitionStyle
498
- }
499
- })
500
- },
501
- /* @__PURE__ */ React.createElement(
502
- core.Box,
503
- {
504
- ...getStyles("secondHand", {
505
- style: {
506
- width: round2(size * (secondHandSize ?? defaultProps.secondHandSize)),
507
- height: calculatedSecondHandLength,
508
- opacity: round2(secondHandOpacity ?? defaultProps.secondHandOpacity)
509
- }
510
- })
511
- }
512
- ),
513
- /* @__PURE__ */ React.createElement(
514
- core.Box,
515
- {
516
- ...getStyles("secondHandCounterweight", {
517
- style: {
518
- width: counterweightWidth,
519
- opacity: round2(secondHandOpacity ?? defaultProps.secondHandOpacity),
520
- left: Math.round(
521
- size * (secondHandSize ?? defaultProps.secondHandSize) / 2 - counterweightWidth / 2
522
- )
523
- }
524
- })
525
- }
526
- )
527
- )),
528
- /* @__PURE__ */ React.createElement(core.Box, { ...getStyles("centerBlur") }),
529
- /* @__PURE__ */ React.createElement(
530
- core.Box,
531
- {
532
- ...getStyles("centerDot", {
533
- style: {
534
- width: centerSize,
535
- height: centerSize,
536
- opacity: round2(secondHandOpacity ?? defaultProps.secondHandOpacity),
537
- top: Math.round(centerY - centerSize / 2),
538
- left: Math.round(centerX - centerSize / 2)
539
- }
540
- })
541
- }
542
- )
543
- )
544
- )
545
- );
48
+ };
546
49
  });
547
- RealClock.displayName = "RealClock";
548
50
  const Clock = core.factory((_props, ref) => {
549
51
  const props = core.useProps("Clock", defaultProps, _props);
550
52
  const [time, setTime] = React.useState(/* @__PURE__ */ new Date());
@@ -636,10 +138,14 @@ const Clock = core.factory((_props, ref) => {
636
138
  vars,
637
139
  varsResolver
638
140
  });
639
- const effectiveSize = size === "auto" ? measuredSize ?? 400 : Math.round(
141
+ const resolvedSize = core.useMatches(
142
+ typeof size === "object" && size !== null && !Array.isArray(size) ? size : { base: size ?? defaultProps.size }
143
+ );
144
+ const isAutoSize = resolvedSize === "auto";
145
+ const effectiveSize = isAutoSize ? measuredSize ?? 400 : Math.round(
640
146
  core.px(
641
147
  core.getSize(
642
- typeof size === "string" && size in defaultClockSizes ? defaultClockSizes[size] : size || defaultProps.size,
148
+ typeof resolvedSize === "string" && resolvedSize in defaultClockSizes ? defaultClockSizes[resolvedSize] : resolvedSize || defaultProps.size,
643
149
  "clock-size"
644
150
  )
645
151
  )
@@ -652,7 +158,7 @@ const Clock = core.factory((_props, ref) => {
652
158
  setHasMounted(true);
653
159
  }, []);
654
160
  React.useEffect(() => {
655
- if (size !== "auto" || !hasMounted) {
161
+ if (!isAutoSize || !hasMounted) {
656
162
  return;
657
163
  }
658
164
  const element = containerRef.current;
@@ -671,9 +177,9 @@ const Clock = core.factory((_props, ref) => {
671
177
  });
672
178
  observer.observe(element);
673
179
  return () => observer.disconnect();
674
- }, [size, hasMounted]);
180
+ }, [isAutoSize, hasMounted]);
675
181
  const getEffectiveTime = () => {
676
- const parsedValue = parseTimeValue(value);
182
+ const parsedValue = clockUtils.parseTimeValue(value);
677
183
  if (!running) {
678
184
  if (parsedValue) {
679
185
  return parsedValue;
@@ -699,7 +205,7 @@ const Clock = core.factory((_props, ref) => {
699
205
  if (!running) {
700
206
  return;
701
207
  }
702
- const parsedValue = parseTimeValue(value);
208
+ const parsedValue = clockUtils.parseTimeValue(value);
703
209
  if (parsedValue) {
704
210
  startTimeRef.current = parsedValue;
705
211
  realStartTimeRef.current = /* @__PURE__ */ new Date();
@@ -760,7 +266,10 @@ const Clock = core.factory((_props, ref) => {
760
266
  core.Box,
761
267
  {
762
268
  ...getStyles("root", {
763
- style: size === "auto" ? { width: "100%", height: "100%", "--clock-size": `${effectiveSize}px` } : { width: geometry$1.width, height: geometry$1.height }
269
+ style: {
270
+ ...{ "--clock-size": `${effectiveSize}px` },
271
+ ...isAutoSize ? { width: "100%", height: "100%" } : { width: geometry$1.width, height: geometry$1.height }
272
+ }
764
273
  }),
765
274
  ref: mergedRef,
766
275
  role: "img",
@@ -798,7 +307,7 @@ const Clock = core.factory((_props, ref) => {
798
307
  },
799
308
  faceContent && /* @__PURE__ */ React.createElement(core.Box, { ...getStyles("faceContent") }, faceContent),
800
309
  /* @__PURE__ */ React.createElement(
801
- ClockFaceStatic,
310
+ ClockFaceStatic.ClockFaceStatic,
802
311
  {
803
312
  getStyles,
804
313
  effectiveSize,
@@ -824,7 +333,10 @@ const Clock = core.factory((_props, ref) => {
824
333
  core.Box,
825
334
  {
826
335
  ...getStyles("root", {
827
- style: size === "auto" ? { width: "100%", height: "100%", "--clock-size": `${effectiveSize}px` } : { width: geometry$1.width, height: geometry$1.height }
336
+ style: {
337
+ ...{ "--clock-size": `${effectiveSize}px` },
338
+ ...isAutoSize ? { width: "100%", height: "100%" } : { width: geometry$1.width, height: geometry$1.height }
339
+ }
828
340
  }),
829
341
  ref: mergedRef,
830
342
  role: "img",
@@ -832,7 +344,7 @@ const Clock = core.factory((_props, ref) => {
832
344
  ...others
833
345
  },
834
346
  /* @__PURE__ */ React.createElement(
835
- RealClock,
347
+ RealClock.RealClock,
836
348
  {
837
349
  time: effectiveTime,
838
350
  getStyles,