@zag-js/timer
Advanced tools
+1
-1
@@ -6,5 +6,5 @@ export { anatomy } from './timer.anatomy.mjs'; | ||
| export { props, splitProps } from './timer.props.mjs'; | ||
| export { ActionTriggerProps, TimerApi as Api, ElementIds, ItemProps, TimerMachine as Machine, TimerProps as Props, TimerService as Service, TickDetails, Time, TimePart, TimerAction } from './timer.types.mjs'; | ||
| export { ActionTriggerProps, TimerApi as Api, ElementIds, IntlTranslations, ItemProps, TimerMachine as Machine, TimerProps as Props, TimerService as Service, TickDetails, Time, TimePart, TimerAction } from './timer.types.mjs'; | ||
| import '@zag-js/anatomy'; | ||
| import '@zag-js/core'; | ||
| import '@zag-js/types'; |
+1
-1
@@ -6,5 +6,5 @@ export { anatomy } from './timer.anatomy.js'; | ||
| export { props, splitProps } from './timer.props.js'; | ||
| export { ActionTriggerProps, TimerApi as Api, ElementIds, ItemProps, TimerMachine as Machine, TimerProps as Props, TimerService as Service, TickDetails, Time, TimePart, TimerAction } from './timer.types.js'; | ||
| export { ActionTriggerProps, TimerApi as Api, ElementIds, IntlTranslations, ItemProps, TimerMachine as Machine, TimerProps as Props, TimerService as Service, TickDetails, Time, TimePart, TimerAction } from './timer.types.js'; | ||
| import '@zag-js/anatomy'; | ||
| import '@zag-js/core'; | ||
| import '@zag-js/types'; |
@@ -41,3 +41,4 @@ "use strict"; | ||
| function connect(service, normalize) { | ||
| const { state, send, computed, scope } = service; | ||
| const { state, send, computed, scope, prop } = service; | ||
| const translations = prop("translations"); | ||
| const running = state.matches("running"); | ||
@@ -79,3 +80,3 @@ const paused = state.matches("paused"); | ||
| id: dom.getAreaId(scope), | ||
| "aria-label": `${time.days} days ${formattedTime.hours}:${formattedTime.minutes}:${formattedTime.seconds}`, | ||
| "aria-label": translations.areaLabel?.(time, formattedTime), | ||
| "aria-atomic": true, | ||
@@ -82,0 +83,0 @@ ...import_timer.parts.area.attrs |
@@ -7,3 +7,4 @@ // src/timer.connect.ts | ||
| function connect(service, normalize) { | ||
| const { state, send, computed, scope } = service; | ||
| const { state, send, computed, scope, prop } = service; | ||
| const translations = prop("translations"); | ||
| const running = state.matches("running"); | ||
@@ -45,3 +46,3 @@ const paused = state.matches("paused"); | ||
| id: dom.getAreaId(scope), | ||
| "aria-label": `${time.days} days ${formattedTime.hours}:${formattedTime.minutes}:${formattedTime.seconds}`, | ||
| "aria-label": translations.areaLabel?.(time, formattedTime), | ||
| "aria-atomic": true, | ||
@@ -48,0 +49,0 @@ ...parts.area.attrs |
@@ -34,3 +34,7 @@ "use strict"; | ||
| startMs: 0, | ||
| ...props | ||
| ...props, | ||
| translations: { | ||
| areaLabel: (time, formattedTime) => `${time.days} days ${formattedTime.hours}:${formattedTime.minutes}:${formattedTime.seconds}`, | ||
| ...props.translations | ||
| } | ||
| }; | ||
@@ -37,0 +41,0 @@ }, |
@@ -10,3 +10,7 @@ // src/timer.machine.ts | ||
| startMs: 0, | ||
| ...props | ||
| ...props, | ||
| translations: { | ||
| areaLabel: (time, formattedTime) => `${time.days} days ${formattedTime.hours}:${formattedTime.minutes}:${formattedTime.seconds}`, | ||
| ...props.translations | ||
| } | ||
| }; | ||
@@ -13,0 +17,0 @@ }, |
@@ -39,3 +39,4 @@ "use strict"; | ||
| "startMs", | ||
| "targetMs" | ||
| "targetMs", | ||
| "translations" | ||
| ]); | ||
@@ -42,0 +43,0 @@ var splitProps = (0, import_utils.createSplitProps)(props); |
@@ -14,3 +14,4 @@ // src/timer.props.ts | ||
| "startMs", | ||
| "targetMs" | ||
| "targetMs", | ||
| "translations" | ||
| ]); | ||
@@ -17,0 +18,0 @@ var splitProps = createSplitProps(props); |
@@ -13,2 +13,5 @@ import { Machine, EventObject, Service } from '@zag-js/core'; | ||
| type TimerAction = "start" | "pause" | "resume" | "reset" | "restart"; | ||
| interface IntlTranslations { | ||
| areaLabel?: ((time: Time, formattedTime: Time<string>) => string) | undefined; | ||
| } | ||
| type ElementIds = Partial<{ | ||
@@ -25,2 +28,6 @@ root: string; | ||
| /** | ||
| * Specifies the localized strings that identifies the accessibility elements and their states | ||
| */ | ||
| translations?: IntlTranslations | undefined; | ||
| /** | ||
| * The ids of the timer parts | ||
@@ -59,3 +66,3 @@ */ | ||
| } | ||
| type PropsWithDefault = "interval" | "startMs"; | ||
| type PropsWithDefault = "interval" | "startMs" | "translations"; | ||
| interface Context { | ||
@@ -150,2 +157,2 @@ /** | ||
| export type { ActionTriggerProps, ElementIds, ItemProps, TickDetails, Time, TimePart, TimerAction, TimerApi, TimerMachine, TimerProps, TimerSchema, TimerService }; | ||
| export type { ActionTriggerProps, ElementIds, IntlTranslations, ItemProps, TickDetails, Time, TimePart, TimerAction, TimerApi, TimerMachine, TimerProps, TimerSchema, TimerService }; |
@@ -13,2 +13,5 @@ import { Machine, EventObject, Service } from '@zag-js/core'; | ||
| type TimerAction = "start" | "pause" | "resume" | "reset" | "restart"; | ||
| interface IntlTranslations { | ||
| areaLabel?: ((time: Time, formattedTime: Time<string>) => string) | undefined; | ||
| } | ||
| type ElementIds = Partial<{ | ||
@@ -25,2 +28,6 @@ root: string; | ||
| /** | ||
| * Specifies the localized strings that identifies the accessibility elements and their states | ||
| */ | ||
| translations?: IntlTranslations | undefined; | ||
| /** | ||
| * The ids of the timer parts | ||
@@ -59,3 +66,3 @@ */ | ||
| } | ||
| type PropsWithDefault = "interval" | "startMs"; | ||
| type PropsWithDefault = "interval" | "startMs" | "translations"; | ||
| interface Context { | ||
@@ -150,2 +157,2 @@ /** | ||
| export type { ActionTriggerProps, ElementIds, ItemProps, TickDetails, Time, TimePart, TimerAction, TimerApi, TimerMachine, TimerProps, TimerSchema, TimerService }; | ||
| export type { ActionTriggerProps, ElementIds, IntlTranslations, ItemProps, TickDetails, Time, TimePart, TimerAction, TimerApi, TimerMachine, TimerProps, TimerSchema, TimerService }; |
+6
-6
| { | ||
| "name": "@zag-js/timer", | ||
| "version": "1.35.3", | ||
| "version": "1.36.0", | ||
| "description": "Core logic for the timer widget implemented as a state machine", | ||
@@ -29,7 +29,7 @@ "keywords": [ | ||
| "dependencies": { | ||
| "@zag-js/anatomy": "1.35.3", | ||
| "@zag-js/dom-query": "1.35.3", | ||
| "@zag-js/core": "1.35.3", | ||
| "@zag-js/types": "1.35.3", | ||
| "@zag-js/utils": "1.35.3" | ||
| "@zag-js/anatomy": "1.36.0", | ||
| "@zag-js/dom-query": "1.36.0", | ||
| "@zag-js/core": "1.36.0", | ||
| "@zag-js/types": "1.36.0", | ||
| "@zag-js/utils": "1.36.0" | ||
| }, | ||
@@ -36,0 +36,0 @@ "devDependencies": { |
47578
2.38%1221
1.58%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated
Updated