@gfazioli/mantine-clock 2.1.16 → 3.0.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 (41) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/Clock.cjs +611 -446
  3. package/dist/cjs/Clock.cjs.map +1 -1
  4. package/dist/cjs/Clock.module.css.cjs +1 -1
  5. package/dist/cjs/ClockDigital.cjs +125 -0
  6. package/dist/cjs/ClockDigital.cjs.map +1 -0
  7. package/dist/cjs/ClockDigital.module.css.cjs +7 -0
  8. package/dist/cjs/ClockDigital.module.css.cjs.map +1 -0
  9. package/dist/cjs/geometry.cjs +217 -0
  10. package/dist/cjs/geometry.cjs.map +1 -0
  11. package/dist/cjs/hooks/use-clock-count-down.cjs +90 -122
  12. package/dist/cjs/hooks/use-clock-count-down.cjs.map +1 -1
  13. package/dist/cjs/hooks/use-clock.cjs +25 -36
  14. package/dist/cjs/hooks/use-clock.cjs.map +1 -1
  15. package/dist/cjs/index.cjs +6 -0
  16. package/dist/cjs/index.cjs.map +1 -1
  17. package/dist/esm/Clock.mjs +613 -448
  18. package/dist/esm/Clock.mjs.map +1 -1
  19. package/dist/esm/Clock.module.css.mjs +1 -1
  20. package/dist/esm/ClockDigital.mjs +123 -0
  21. package/dist/esm/ClockDigital.mjs.map +1 -0
  22. package/dist/esm/ClockDigital.module.css.mjs +5 -0
  23. package/dist/esm/ClockDigital.module.css.mjs.map +1 -0
  24. package/dist/esm/geometry.mjs +208 -0
  25. package/dist/esm/geometry.mjs.map +1 -0
  26. package/dist/esm/hooks/use-clock-count-down.mjs +90 -122
  27. package/dist/esm/hooks/use-clock-count-down.mjs.map +1 -1
  28. package/dist/esm/hooks/use-clock.mjs +25 -36
  29. package/dist/esm/hooks/use-clock.mjs.map +1 -1
  30. package/dist/esm/index.mjs +2 -0
  31. package/dist/esm/index.mjs.map +1 -1
  32. package/dist/styles.css +2 -2
  33. package/dist/styles.layer.css +2 -2
  34. package/dist/types/Clock.d.ts +70 -1
  35. package/dist/types/ClockDigital.d.ts +50 -0
  36. package/dist/types/geometry.d.ts +92 -0
  37. package/dist/types/hooks/use-clock-count-down.d.ts +25 -28
  38. package/dist/types/hooks/use-clock.d.ts +14 -10
  39. package/dist/types/index.d.mts +5 -1
  40. package/dist/types/index.d.ts +5 -1
  41. package/package.json +5 -3
@@ -6,10 +6,17 @@ var timezonePlugin = 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
+ var hooks = require('@mantine/hooks');
10
+ var ClockDigital = require('./ClockDigital.cjs');
11
+ var geometry = require('./geometry.cjs');
9
12
  var Clock_module = require('./Clock.module.css.cjs');
10
13
 
11
14
  dayjs.extend(utc);
12
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;
13
20
  const defaultProps = {
14
21
  size: 400,
15
22
  hourHandSize: 0.017,
@@ -21,6 +28,7 @@ const defaultProps = {
21
28
  secondHandOpacity: 1,
22
29
  minuteHandOpacity: 1,
23
30
  hourHandOpacity: 1,
31
+ secondHandBehavior: "tick",
24
32
  running: true
25
33
  };
26
34
  const defaultClockSizes = {
@@ -30,83 +38,37 @@ const defaultClockSizes = {
30
38
  lg: 480,
31
39
  xl: 512
32
40
  };
33
- const varsResolver = core.createVarsResolver(
34
- (theme, {
35
- size,
36
- color,
37
- hourTicksColor,
38
- hourTicksOpacity,
39
- minuteTicksColor,
40
- minuteTicksOpacity,
41
- primaryNumbersColor,
42
- primaryNumbersOpacity,
43
- secondaryNumbersColor,
44
- secondaryNumbersOpacity,
45
- secondHandColor,
46
- minuteHandColor,
47
- hourHandColor,
48
- secondsArcColor,
49
- minutesArcColor,
50
- hoursArcColor
51
- }) => {
52
- const sizeValue = size || "md";
53
- const clockSize = typeof sizeValue === "string" && sizeValue in defaultClockSizes ? defaultClockSizes[sizeValue] : sizeValue;
54
- const effectiveSize = Math.round(core.px(core.getSize(clockSize, "clock-size")));
55
- return {
56
- root: {
57
- "--clock-size": `${effectiveSize}px`,
58
- "--clock-color": core.parseThemeColor({
59
- color: color || "",
60
- theme
61
- }).value,
62
- "--clock-hour-ticks-color": core.parseThemeColor({
63
- color: hourTicksColor || "",
64
- theme
65
- }).value,
66
- "--clock-hour-ticks-opacity": (Math.round((hourTicksOpacity || 1) * 100) / 100).toString(),
67
- "--clock-minute-ticks-color": core.parseThemeColor({
68
- color: minuteTicksColor || "",
69
- theme
70
- }).value,
71
- "--clock-minute-ticks-opacity": (Math.round((minuteTicksOpacity || 1) * 100) / 100).toString(),
72
- "--clock-primary-numbers-color": core.parseThemeColor({
73
- color: primaryNumbersColor || "",
74
- theme
75
- }).value,
76
- "--clock-primary-numbers-opacity": (Math.round((primaryNumbersOpacity || 1) * 100) / 100).toString(),
77
- "--clock-secondary-numbers-color": core.parseThemeColor({
78
- color: secondaryNumbersColor || "",
79
- theme
80
- }).value,
81
- "--clock-secondary-numbers-opacity": (Math.round((secondaryNumbersOpacity || 1) * 100) / 100).toString(),
82
- "--clock-second-hand-color": core.parseThemeColor({
83
- color: secondHandColor || "",
84
- theme
85
- }).value,
86
- "--clock-minute-hand-color": core.parseThemeColor({
87
- color: minuteHandColor || "",
88
- theme
89
- }).value,
90
- "--clock-hour-hand-color": core.parseThemeColor({
91
- color: hourHandColor || "",
92
- theme
93
- }).value,
94
- "--clock-seconds-arc-color": core.parseThemeColor({
95
- color: secondsArcColor || secondHandColor || "",
96
- theme
97
- }).value,
98
- "--clock-minutes-arc-color": core.parseThemeColor({
99
- color: minutesArcColor || minuteHandColor || "",
100
- theme
101
- }).value,
102
- "--clock-hours-arc-color": core.parseThemeColor({
103
- color: hoursArcColor || hourHandColor || "",
104
- theme
105
- }).value
106
- }
107
- };
41
+ const buildCssVars = (theme, clockSizePx, props) => {
42
+ const c = (color) => core.parseThemeColor({ color, theme }).value;
43
+ 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) };
108
66
  }
109
- );
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
+ });
110
72
  const parseTimeValue = (value) => {
111
73
  if (!value) {
112
74
  return null;
@@ -135,12 +97,99 @@ const parseTimeValue = (value) => {
135
97
  }
136
98
  return null;
137
99
  };
138
- const RealClock = (props) => {
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) => {
139
187
  const {
140
188
  time,
141
189
  timezone: timezone2,
142
190
  getStyles,
143
191
  effectiveSize,
192
+ geometry: geometry$1,
144
193
  hourHandSize,
145
194
  minuteHandSize,
146
195
  secondHandSize,
@@ -170,7 +219,14 @@ const RealClock = (props) => {
170
219
  hoursArcDirection = "clockwise",
171
220
  secondsArcOpacity,
172
221
  minutesArcOpacity,
173
- hoursArcOpacity
222
+ hoursArcOpacity,
223
+ renderHourHand,
224
+ renderMinuteHand,
225
+ renderSecondHand,
226
+ sectors,
227
+ faceContent,
228
+ animateOnMount,
229
+ animateOnMountDuration
174
230
  } = props;
175
231
  const timezoneTime = timezone2 && timezone2 !== "" ? dayjs(time).tz(timezone2) : dayjs(time);
176
232
  const hours = timezoneTime.hour() % 12;
@@ -181,9 +237,6 @@ const RealClock = (props) => {
181
237
  const minuteAngle = minutes * 6;
182
238
  let secondAngle = 0;
183
239
  switch (secondHandBehavior) {
184
- case "tick":
185
- secondAngle = seconds * 6;
186
- break;
187
240
  case "tick-half":
188
241
  secondAngle = (seconds + Math.floor(milliseconds / 500) * 0.5) * 6;
189
242
  break;
@@ -191,303 +244,319 @@ const RealClock = (props) => {
191
244
  secondAngle = (seconds + Math.floor(milliseconds / 125) * 0.125) * 6;
192
245
  break;
193
246
  case "smooth":
194
- default:
195
247
  secondAngle = (seconds + milliseconds / 1e3) * 6;
196
248
  break;
249
+ case "tick":
250
+ default:
251
+ secondAngle = seconds * 6;
252
+ break;
197
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;
198
278
  const size = effectiveSize;
199
- const clockRadius = Math.round(size / 2);
200
- const numberRadius = Math.round(clockRadius * hourNumbersDistance);
201
- const calculatedHourHandLength = Math.round(
202
- clockRadius * (hourHandLength ?? defaultProps.hourHandLength)
279
+ const { centerX, centerY } = geometry$1;
280
+ const calculatedHourHandLength = geometry$1.handLength(
281
+ hourHandLength ?? defaultProps.hourHandLength
203
282
  );
204
- const calculatedMinuteHandLength = Math.round(
205
- clockRadius * (minuteHandLength ?? defaultProps.minuteHandLength)
283
+ const calculatedMinuteHandLength = geometry$1.handLength(
284
+ minuteHandLength ?? defaultProps.minuteHandLength
206
285
  );
207
- const calculatedSecondHandLength = Math.round(
208
- clockRadius * (secondHandLength ?? defaultProps.secondHandLength)
286
+ const calculatedSecondHandLength = geometry$1.handLength(
287
+ secondHandLength ?? defaultProps.secondHandLength
209
288
  );
210
- const centerSize = Math.round(size * 0.034);
211
- const tickOffset = Math.round(size * 0.028);
212
- const toClockAngle = (deg) => (deg % 360 + 360) % 360;
213
- const secAngleFromDate = (d) => {
214
- if (!d) {
215
- return 0;
216
- }
217
- const dt = timezone2 && timezone2 !== "" ? dayjs(d).tz(timezone2) : dayjs(d);
218
- const s = dt.second();
219
- const ms = dt.millisecond();
220
- return toClockAngle((s + ms / 1e3) * 6);
221
- };
222
- const minAngleFromDate = (d) => {
223
- if (!d) {
224
- return 0;
225
- }
226
- const dt = timezone2 && timezone2 !== "" ? dayjs(d).tz(timezone2) : dayjs(d);
227
- const m = dt.minute();
228
- return toClockAngle(m * 6);
229
- };
230
- const hourAngleFromDate = (d) => {
231
- if (!d) {
232
- return 0;
233
- }
234
- const dt = timezone2 && timezone2 !== "" ? dayjs(d).tz(timezone2) : dayjs(d);
235
- const h = dt.hour() % 12;
236
- const m = dt.minute();
237
- return toClockAngle(h * 30 + m * 0.5);
238
- };
239
- const describeSector = (cx, cy, r, startDeg, endDeg, direction) => {
240
- const start = toClockAngle(startDeg);
241
- const end = toClockAngle(endDeg);
242
- let delta = 0;
243
- if (direction === "clockwise") {
244
- delta = end - start;
245
- if (delta < 0) {
246
- delta += 360;
247
- }
248
- } else {
249
- delta = start - end;
250
- if (delta < 0) {
251
- delta += 360;
252
- }
253
- }
254
- const largeArc = delta >= 180 ? 1 : 0;
255
- const sweep = direction === "clockwise" ? 1 : 0;
256
- const aStart = start * Math.PI / 180;
257
- const aEnd = end * Math.PI / 180;
258
- const x1 = cx + r * Math.sin(aStart);
259
- const y1 = cy - r * Math.cos(aStart);
260
- const x2 = cx + r * Math.sin(aEnd);
261
- const y2 = cy - r * Math.cos(aEnd);
262
- const fmt = (n) => Number.isFinite(n) ? n.toFixed(3) : "0";
263
- return `M ${fmt(cx)} ${fmt(cy)} L ${fmt(x1)} ${fmt(y1)} A ${fmt(r)} ${fmt(r)} 0 ${largeArc} ${sweep} ${fmt(x2)} ${fmt(y2)} Z`;
264
- };
289
+ const centerSize = Math.round(size * CENTER_DOT_RATIO);
265
290
  const showSecArc = withSecondsArc === true && (secondsArcOpacity ?? 1) !== 0;
266
291
  const showMinArc = withMinutesArc === true && (minutesArcOpacity ?? 1) !== 0;
267
292
  const showHrArc = withHoursArc === true && (hoursArcOpacity ?? 1) !== 0;
268
- return /* @__PURE__ */ React.createElement(core.Box, { ...getStyles("clockContainer") }, /* @__PURE__ */ React.createElement(core.Box, { ...getStyles("glassWrapper") }, /* @__PURE__ */ React.createElement(core.Box, { ...getStyles("clockFace") }, (showSecArc || showMinArc || showHrArc) && /* @__PURE__ */ React.createElement(
269
- "svg",
270
- {
271
- ...getStyles("arcsLayer", { style: { width: size, height: size } }),
272
- viewBox: `0 0 ${size} ${size}`
273
- },
274
- showHrArc && /* @__PURE__ */ React.createElement(
275
- "path",
276
- {
277
- d: describeSector(
278
- clockRadius,
279
- clockRadius,
280
- calculatedHourHandLength,
281
- hourAngleFromDate(parseTimeValue(hoursArcFrom) ?? null),
282
- hourAngle,
283
- hoursArcDirection
284
- ),
285
- fill: "var(--clock-hours-arc-color-resolved)",
286
- fillOpacity: Math.round((hoursArcOpacity ?? 1) * 100) / 100
287
- }
288
- ),
289
- showMinArc && /* @__PURE__ */ React.createElement(
290
- "path",
291
- {
292
- d: describeSector(
293
- clockRadius,
294
- clockRadius,
295
- calculatedMinuteHandLength,
296
- minAngleFromDate(parseTimeValue(minutesArcFrom) ?? null),
297
- minuteAngle,
298
- minutesArcDirection
299
- ),
300
- fill: "var(--clock-minutes-arc-color-resolved)",
301
- fillOpacity: Math.round((minutesArcOpacity ?? 1) * 100) / 100
302
- }
303
- ),
304
- showSecArc && /* @__PURE__ */ React.createElement(
305
- "path",
306
- {
307
- d: describeSector(
308
- clockRadius,
309
- clockRadius,
310
- calculatedSecondHandLength,
311
- secAngleFromDate(parseTimeValue(secondsArcFrom) ?? null),
312
- secondAngle,
313
- secondsArcDirection
314
- ),
315
- fill: "var(--clock-seconds-arc-color-resolved)",
316
- fillOpacity: Math.round((secondsArcOpacity ?? 1) * 100) / 100
317
- }
318
- )
319
- ), /* @__PURE__ */ React.createElement(core.Box, { ...getStyles("hourMarks") }, hourTicksOpacity !== 0 && Array.from({ length: 12 }, (_, i) => /* @__PURE__ */ React.createElement(
293
+ const counterweightWidth = round2(
294
+ size * (secondHandSize ?? defaultProps.secondHandSize) * COUNTERWEIGHT_MULTIPLIER
295
+ );
296
+ return /* @__PURE__ */ React.createElement(
320
297
  core.Box,
321
298
  {
322
- key: `hour-tick-${i}`,
323
- ...getStyles("hourTick", {
299
+ ...getStyles("clockContainer", {
324
300
  style: {
325
- top: tickOffset,
326
- left: "50%",
327
- transformOrigin: `50% ${clockRadius - tickOffset}px`,
328
- transform: `translateX(-50%) rotate(${i * 30}deg)`
301
+ width: geometry$1.width,
302
+ height: geometry$1.height
329
303
  }
330
304
  })
331
- }
332
- )), minuteTicksOpacity !== 0 && Array.from({ length: 60 }, (_, i) => {
333
- if (i % 5 === 0) {
334
- return null;
335
- }
336
- return /* @__PURE__ */ React.createElement(
305
+ },
306
+ /* @__PURE__ */ React.createElement(
337
307
  core.Box,
338
308
  {
339
- key: `minute-tick-${i}`,
340
- ...getStyles("minuteTick", {
341
- style: {
342
- top: tickOffset,
343
- left: "50%",
344
- transformOrigin: `50% ${clockRadius - tickOffset}px`,
345
- transform: `translateX(-50%) rotate(${i * 6}deg)`
346
- }
347
- })
348
- }
349
- );
350
- }), primaryNumbersOpacity !== 0 && [12, 3, 6, 9].map((num) => {
351
- const i = num === 12 ? 0 : num;
352
- const angle = (i * 30 - 90) * (Math.PI / 180);
353
- const x = Math.round(clockRadius + Math.cos(angle) * numberRadius);
354
- const y = Math.round(clockRadius + Math.sin(angle) * numberRadius);
355
- return /* @__PURE__ */ React.createElement(
356
- core.Text,
357
- {
358
- key: `primary-number-${num}`,
359
- ...primaryNumbersProps,
360
- ...getStyles("primaryNumber", {
361
- className: getStyles("number").className,
362
- style: {
363
- left: x,
364
- top: y
365
- }
309
+ ...getStyles("glassWrapper", {
310
+ style: { width: geometry$1.width, height: geometry$1.height }
366
311
  })
367
312
  },
368
- num
369
- );
370
- }), secondaryNumbersOpacity !== 0 && [1, 2, 4, 5, 7, 8, 10, 11].map((num) => {
371
- const i = num;
372
- const angle = (i * 30 - 90) * (Math.PI / 180);
373
- const x = Math.round(clockRadius + Math.cos(angle) * numberRadius);
374
- const y = Math.round(clockRadius + Math.sin(angle) * numberRadius);
375
- return /* @__PURE__ */ React.createElement(
376
- core.Text,
377
- {
378
- key: `secondary-number-${num}`,
379
- ...secondaryNumbersProps,
380
- ...getStyles("secondaryNumber", {
381
- className: getStyles("number").className,
382
- style: {
383
- left: x,
384
- top: y
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
385
420
  }
386
- })
387
- },
388
- num
389
- );
390
- })), (hourHandOpacity ?? defaultProps.hourHandOpacity) !== 0 && /* @__PURE__ */ React.createElement(
391
- core.Box,
392
- {
393
- ...getStyles("hand", {
394
- className: getStyles("hourHand").className,
395
- style: {
396
- width: Math.round(size * (hourHandSize ?? defaultProps.hourHandSize) * 100) / 100,
397
- height: calculatedHourHandLength,
398
- opacity: Math.round((hourHandOpacity ?? defaultProps.hourHandOpacity) * 100) / 100,
399
- bottom: clockRadius,
400
- left: clockRadius,
401
- marginLeft: Math.round(-(size * (hourHandSize ?? defaultProps.hourHandSize)) / 2 * 100) / 100,
402
- borderRadius: `${Math.round(size * (hourHandSize ?? defaultProps.hourHandSize) * 100) / 100}px`,
403
- transform: `rotate(${Math.round(hourAngle * 100) / 100}deg)`
404
- }
405
- })
406
- }
407
- ), (minuteHandOpacity ?? defaultProps.minuteHandOpacity) !== 0 && /* @__PURE__ */ React.createElement(
408
- core.Box,
409
- {
410
- ...getStyles("hand", {
411
- className: getStyles("minuteHand").className,
412
- style: {
413
- width: Math.round(size * (minuteHandSize ?? defaultProps.minuteHandSize) * 100) / 100,
414
- height: calculatedMinuteHandLength,
415
- opacity: Math.round((minuteHandOpacity ?? defaultProps.minuteHandOpacity) * 100) / 100,
416
- bottom: clockRadius,
417
- left: clockRadius,
418
- marginLeft: Math.round(
419
- -(size * (minuteHandSize ?? defaultProps.minuteHandSize)) / 2 * 100
420
- ) / 100,
421
- borderRadius: `${Math.round(size * (minuteHandSize ?? defaultProps.minuteHandSize) * 100) / 100}px`,
422
- transform: `rotate(${Math.round(minuteAngle * 100) / 100}deg)`
423
- }
424
- })
425
- }
426
- ), (secondHandOpacity ?? defaultProps.secondHandOpacity) !== 0 && /* @__PURE__ */ React.createElement(
427
- core.Box,
428
- {
429
- ...getStyles("secondHandContainer", {
430
- style: {
431
- width: Math.round(size * (secondHandSize ?? defaultProps.secondHandSize) * 100) / 100,
432
- height: calculatedSecondHandLength,
433
- top: clockRadius - calculatedSecondHandLength,
434
- left: clockRadius,
435
- marginLeft: Math.round(
436
- -(size * (secondHandSize ?? defaultProps.secondHandSize)) / 2 * 100
437
- ) / 100,
438
- transformOrigin: `${Math.round(size * (secondHandSize ?? defaultProps.secondHandSize) / 2 * 100) / 100}px ${calculatedSecondHandLength}px`,
439
- transform: `rotate(${Math.round(secondAngle * 100) / 100}deg)`
440
- }
441
- })
442
- },
443
- /* @__PURE__ */ React.createElement(
444
- core.Box,
445
- {
446
- ...getStyles("secondHand", {
447
- style: {
448
- width: Math.round(size * (secondHandSize ?? defaultProps.secondHandSize) * 100) / 100,
449
- height: calculatedSecondHandLength,
450
- opacity: Math.round((secondHandOpacity ?? defaultProps.secondHandOpacity) * 100) / 100
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
+ })
451
446
  }
452
- })
453
- }
454
- ),
455
- /* @__PURE__ */ React.createElement(
456
- core.Box,
457
- {
458
- ...getStyles("secondHandCounterweight", {
459
- style: {
460
- width: Math.round(size * 6e-3 * 3 * 100) / 100,
461
- opacity: Math.round((secondHandOpacity ?? defaultProps.secondHandOpacity) * 100) / 100,
462
- left: Math.round(
463
- size * (secondHandSize ?? defaultProps.secondHandSize) / 2 - size * 6e-3 * 3 / 2
464
- )
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
+ })
465
474
  }
466
- })
467
- }
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
+ )
468
544
  )
469
- ), /* @__PURE__ */ React.createElement(core.Box, { ...getStyles("centerBlur") }), /* @__PURE__ */ React.createElement(
470
- core.Box,
471
- {
472
- ...getStyles("centerDot", {
473
- style: {
474
- width: centerSize,
475
- height: centerSize,
476
- opacity: Math.round((secondHandOpacity ?? defaultProps.secondHandOpacity) * 100) / 100,
477
- top: Math.round(clockRadius - centerSize / 2),
478
- left: Math.round(clockRadius - centerSize / 2)
479
- }
480
- })
481
- }
482
- ))));
483
- };
545
+ );
546
+ });
547
+ RealClock.displayName = "RealClock";
484
548
  const Clock = core.factory((_props, ref) => {
485
549
  const props = core.useProps("Clock", defaultProps, _props);
486
550
  const [time, setTime] = React.useState(/* @__PURE__ */ new Date());
487
551
  const [hasMounted, setHasMounted] = React.useState(false);
488
552
  const intervalRef = React.useRef(null);
553
+ const rafRef = React.useRef(null);
489
554
  const startTimeRef = React.useRef(null);
490
555
  const realStartTimeRef = React.useRef(null);
556
+ const onTimeChange = hooks.useCallbackRef(_props.onTimeChange);
557
+ const containerRef = React.useRef(null);
558
+ const [measuredSize, setMeasuredSize] = React.useState(null);
559
+ const mergedRef = hooks.useMergedRef(ref, containerRef);
491
560
  const {
492
561
  // Clock-specific props that should not be passed to DOM
493
562
  size,
@@ -513,14 +582,13 @@ const Clock = core.factory((_props, ref) => {
513
582
  hourHandOpacity,
514
583
  hourHandSize,
515
584
  hourHandLength,
516
- hourTicksOpacity: _hourTicksOpacity,
517
- minuteTicksOpacity: _minuteTicksOpacity,
518
585
  hourNumbersDistance,
519
586
  primaryNumbersProps,
520
587
  secondaryNumbersProps,
521
588
  timezone: timezone2,
522
589
  running,
523
590
  value,
591
+ ariaLabel,
524
592
  withSecondsArc,
525
593
  secondsArcFrom,
526
594
  secondsArcDirection,
@@ -536,6 +604,17 @@ const Clock = core.factory((_props, ref) => {
536
604
  hoursArcDirection,
537
605
  hoursArcColor,
538
606
  hoursArcOpacity,
607
+ sectors,
608
+ faceContent,
609
+ animateOnMount,
610
+ animateOnMountDuration,
611
+ shape,
612
+ aspectRatio,
613
+ borderRadius,
614
+ onTimeChange: _onTimeChange,
615
+ renderHourHand,
616
+ renderMinuteHand,
617
+ renderSecondHand,
539
618
  // Styles API props
540
619
  classNames,
541
620
  style,
@@ -557,7 +636,7 @@ const Clock = core.factory((_props, ref) => {
557
636
  vars,
558
637
  varsResolver
559
638
  });
560
- const effectiveSize = Math.round(
639
+ const effectiveSize = size === "auto" ? measuredSize ?? 400 : Math.round(
561
640
  core.px(
562
641
  core.getSize(
563
642
  typeof size === "string" && size in defaultClockSizes ? defaultClockSizes[size] : size || defaultProps.size,
@@ -565,9 +644,34 @@ const Clock = core.factory((_props, ref) => {
565
644
  )
566
645
  )
567
646
  );
647
+ const geometry$1 = React.useMemo(
648
+ () => geometry.createGeometry(effectiveSize, shape, { aspectRatio, borderRadius }),
649
+ [effectiveSize, shape, aspectRatio, borderRadius]
650
+ );
568
651
  React.useEffect(() => {
569
652
  setHasMounted(true);
570
653
  }, []);
654
+ React.useEffect(() => {
655
+ if (size !== "auto" || !hasMounted) {
656
+ return;
657
+ }
658
+ const element = containerRef.current;
659
+ if (!element || typeof ResizeObserver === "undefined") {
660
+ return;
661
+ }
662
+ const observer = new ResizeObserver((entries) => {
663
+ const entry = entries[0];
664
+ if (entry) {
665
+ const { width, height } = entry.contentRect;
666
+ const newSize = Math.round(Math.min(width, height));
667
+ if (newSize > 0) {
668
+ setMeasuredSize(newSize);
669
+ }
670
+ }
671
+ });
672
+ observer.observe(element);
673
+ return () => observer.disconnect();
674
+ }, [size, hasMounted]);
571
675
  const getEffectiveTime = () => {
572
676
  const parsedValue = parseTimeValue(value);
573
677
  if (!running) {
@@ -588,6 +692,10 @@ const Clock = core.factory((_props, ref) => {
588
692
  clearInterval(intervalRef.current);
589
693
  intervalRef.current = null;
590
694
  }
695
+ if (rafRef.current !== null) {
696
+ cancelAnimationFrame(rafRef.current);
697
+ rafRef.current = null;
698
+ }
591
699
  if (!running) {
592
700
  return;
593
701
  }
@@ -599,122 +707,179 @@ const Clock = core.factory((_props, ref) => {
599
707
  startTimeRef.current = null;
600
708
  realStartTimeRef.current = null;
601
709
  }
602
- let interval = 1e3;
603
- switch (secondHandBehavior) {
604
- case "smooth":
605
- interval = 16;
606
- break;
607
- case "tick-half":
608
- interval = 500;
609
- break;
610
- case "tick-high-freq":
611
- interval = 125;
612
- break;
613
- case "tick":
614
- default:
615
- interval = 1e3;
616
- break;
617
- }
710
+ const fireOnTimeChange = (now) => {
711
+ const tz = timezone2 && timezone2 !== "" ? dayjs(now).tz(timezone2) : dayjs(now);
712
+ onTimeChange({
713
+ hours: tz.hour(),
714
+ minutes: tz.minute(),
715
+ seconds: tz.second(),
716
+ milliseconds: tz.millisecond()
717
+ });
718
+ };
618
719
  const updateTime = () => {
619
- setTime(/* @__PURE__ */ new Date());
720
+ const now = /* @__PURE__ */ new Date();
721
+ setTime(now);
722
+ fireOnTimeChange(now);
620
723
  };
621
724
  updateTime();
622
- intervalRef.current = setInterval(updateTime, interval);
725
+ if (secondHandBehavior === "smooth") {
726
+ const animate = () => {
727
+ const now = /* @__PURE__ */ new Date();
728
+ setTime(now);
729
+ fireOnTimeChange(now);
730
+ rafRef.current = requestAnimationFrame(animate);
731
+ };
732
+ animate();
733
+ } else {
734
+ let interval = 1e3;
735
+ switch (secondHandBehavior) {
736
+ case "tick-half":
737
+ interval = 500;
738
+ break;
739
+ case "tick-high-freq":
740
+ interval = 125;
741
+ break;
742
+ case "tick":
743
+ default:
744
+ interval = 1e3;
745
+ break;
746
+ }
747
+ intervalRef.current = setInterval(updateTime, interval);
748
+ }
623
749
  return () => {
624
750
  if (intervalRef.current) {
625
751
  clearInterval(intervalRef.current);
626
752
  }
753
+ if (rafRef.current !== null) {
754
+ cancelAnimationFrame(rafRef.current);
755
+ }
627
756
  };
628
- }, [running, value, secondHandBehavior, secondHandOpacity]);
757
+ }, [running, value, secondHandBehavior, timezone2]);
629
758
  if (!hasMounted) {
630
- return /* @__PURE__ */ React.createElement(core.Box, { ...getStyles("root"), ref, ...others }, /* @__PURE__ */ React.createElement(core.Box, { ...getStyles("clockContainer") }, /* @__PURE__ */ React.createElement(core.Box, { ...getStyles("glassWrapper") }, /* @__PURE__ */ React.createElement(core.Box, { ...getStyles("clockFace") }, /* @__PURE__ */ React.createElement(core.Box, { ...getStyles("hourMarks") }, (hourTicksOpacity || 1) !== 0 && Array.from({ length: 12 }, (_, i) => /* @__PURE__ */ React.createElement(
759
+ return /* @__PURE__ */ React.createElement(
631
760
  core.Box,
632
761
  {
633
- key: `hour-tick-${i}`,
634
- ...getStyles("hourTick", {
635
- style: {
636
- top: Math.round(effectiveSize * 0.028),
637
- left: "50%",
638
- transformOrigin: `50% ${Math.round(effectiveSize / 2) - Math.round(effectiveSize * 0.028)}px`,
639
- transform: `translateX(-50%) rotate(${i * 30}deg)`
640
- }
641
- })
642
- }
643
- )), (minuteTicksOpacity || 1) !== 0 && Array.from({ length: 60 }, (_, i) => {
644
- if (i % 5 === 0) {
645
- return null;
646
- }
647
- return /* @__PURE__ */ React.createElement(
762
+ ...getStyles("root", {
763
+ style: size === "auto" ? { width: "100%", height: "100%", "--clock-size": `${effectiveSize}px` } : { width: geometry$1.width, height: geometry$1.height }
764
+ }),
765
+ ref: mergedRef,
766
+ role: "img",
767
+ "aria-label": ariaLabel || "Clock",
768
+ ...others
769
+ },
770
+ /* @__PURE__ */ React.createElement(
648
771
  core.Box,
649
772
  {
650
- key: `minute-tick-${i}`,
651
- ...getStyles("minuteTick", {
652
- style: {
653
- top: Math.round(effectiveSize * 0.028),
654
- left: "50%",
655
- transformOrigin: `50% ${Math.round(effectiveSize / 2) - Math.round(effectiveSize * 0.028)}px`,
656
- transform: `translateX(-50%) rotate(${i * 6}deg)`
657
- }
658
- })
659
- }
660
- );
661
- }), (primaryNumbersOpacity || 1) !== 0 && [12, 3, 6, 9].map((num) => {
662
- const i = num === 12 ? 0 : num;
663
- const angle = (i * 30 - 90) * (Math.PI / 180);
664
- const clockRadius = Math.round(effectiveSize / 2);
665
- const numberRadius = Math.round(clockRadius * (hourNumbersDistance || 0.75));
666
- const x = Math.round(clockRadius + Math.cos(angle) * numberRadius);
667
- const y = Math.round(clockRadius + Math.sin(angle) * numberRadius);
668
- return /* @__PURE__ */ React.createElement(
669
- core.Text,
670
- {
671
- key: `primary-number-${num}`,
672
- ...primaryNumbersProps,
673
- ...getStyles("primaryNumber", {
674
- className: getStyles("number").className,
675
- style: {
676
- left: x,
677
- top: y
678
- }
679
- })
680
- },
681
- num
682
- );
683
- }), (secondaryNumbersOpacity || 1) !== 0 && [1, 2, 4, 5, 7, 8, 10, 11].map((num) => {
684
- const i = num;
685
- const angle = (i * 30 - 90) * (Math.PI / 180);
686
- const clockRadius = Math.round(effectiveSize / 2);
687
- const numberRadius = Math.round(clockRadius * (hourNumbersDistance || 0.75));
688
- const x = Math.round(clockRadius + Math.cos(angle) * numberRadius);
689
- const y = Math.round(clockRadius + Math.sin(angle) * numberRadius);
690
- return /* @__PURE__ */ React.createElement(
691
- core.Text,
692
- {
693
- key: `secondary-number-${num}`,
694
- ...secondaryNumbersProps,
695
- ...getStyles("secondaryNumber", {
696
- className: getStyles("number").className,
773
+ ...getStyles("clockContainer", {
697
774
  style: {
698
- left: x,
699
- top: y
775
+ width: geometry$1.width,
776
+ height: geometry$1.height
700
777
  }
701
778
  })
702
779
  },
703
- num
704
- );
705
- }))))));
780
+ /* @__PURE__ */ React.createElement(
781
+ core.Box,
782
+ {
783
+ ...getStyles("glassWrapper", {
784
+ style: { width: geometry$1.width, height: geometry$1.height }
785
+ })
786
+ },
787
+ /* @__PURE__ */ React.createElement(
788
+ core.Box,
789
+ {
790
+ ...getStyles("clockFace", {
791
+ style: {
792
+ width: geometry$1.width,
793
+ height: geometry$1.height,
794
+ borderRadius: geometry$1.borderRadius(),
795
+ clipPath: geometry$1.clipPath()
796
+ }
797
+ })
798
+ },
799
+ faceContent && /* @__PURE__ */ React.createElement(core.Box, { ...getStyles("faceContent") }, faceContent),
800
+ /* @__PURE__ */ React.createElement(
801
+ ClockFaceStatic,
802
+ {
803
+ getStyles,
804
+ effectiveSize,
805
+ geometry: geometry$1,
806
+ hourTicksOpacity,
807
+ minuteTicksOpacity,
808
+ primaryNumbersOpacity,
809
+ secondaryNumbersOpacity,
810
+ hourNumbersDistance,
811
+ primaryNumbersProps,
812
+ secondaryNumbersProps
813
+ }
814
+ )
815
+ )
816
+ )
817
+ )
818
+ );
706
819
  }
707
820
  const effectiveTime = getEffectiveTime();
708
- return /* @__PURE__ */ React.createElement(core.Box, { ...getStyles("root"), ref, ...others }, /* @__PURE__ */ React.createElement(
709
- RealClock,
821
+ const timezoneTime = timezone2 && timezone2 !== "" ? dayjs(effectiveTime).tz(timezone2) : dayjs(effectiveTime);
822
+ const computedAriaLabel = ariaLabel || `Clock showing ${String(timezoneTime.hour()).padStart(2, "0")}:${String(timezoneTime.minute()).padStart(2, "0")}:${String(timezoneTime.second()).padStart(2, "0")}`;
823
+ return /* @__PURE__ */ React.createElement(
824
+ core.Box,
710
825
  {
711
- time: effectiveTime,
712
- getStyles,
713
- effectiveSize,
714
- ...props
715
- }
716
- ));
826
+ ...getStyles("root", {
827
+ style: size === "auto" ? { width: "100%", height: "100%", "--clock-size": `${effectiveSize}px` } : { width: geometry$1.width, height: geometry$1.height }
828
+ }),
829
+ ref: mergedRef,
830
+ role: "img",
831
+ "aria-label": computedAriaLabel,
832
+ ...others
833
+ },
834
+ /* @__PURE__ */ React.createElement(
835
+ RealClock,
836
+ {
837
+ time: effectiveTime,
838
+ getStyles,
839
+ effectiveSize,
840
+ geometry: geometry$1,
841
+ timezone: timezone2,
842
+ hourHandSize,
843
+ minuteHandSize,
844
+ secondHandSize,
845
+ hourHandLength,
846
+ minuteHandLength,
847
+ secondHandLength,
848
+ secondHandBehavior,
849
+ secondHandOpacity,
850
+ minuteHandOpacity,
851
+ hourHandOpacity,
852
+ hourTicksOpacity,
853
+ minuteTicksOpacity,
854
+ primaryNumbersOpacity,
855
+ secondaryNumbersOpacity,
856
+ hourNumbersDistance,
857
+ primaryNumbersProps,
858
+ secondaryNumbersProps,
859
+ withSecondsArc,
860
+ secondsArcFrom,
861
+ secondsArcDirection,
862
+ secondsArcOpacity,
863
+ withMinutesArc,
864
+ minutesArcFrom,
865
+ minutesArcDirection,
866
+ minutesArcOpacity,
867
+ withHoursArc,
868
+ hoursArcFrom,
869
+ hoursArcDirection,
870
+ hoursArcOpacity,
871
+ sectors,
872
+ faceContent,
873
+ animateOnMount,
874
+ animateOnMountDuration,
875
+ renderHourHand,
876
+ renderMinuteHand,
877
+ renderSecondHand
878
+ }
879
+ )
880
+ );
717
881
  });
882
+ Clock.Digital = ClockDigital.ClockDigital;
718
883
  Clock.classes = Clock_module;
719
884
  Clock.displayName = "Clock";
720
885