akar 2.0.17 → 2.0.18

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.
@@ -1,7 +1,7 @@
1
1
  import "./index2.cjs";
2
2
  import "./index3.cjs";
3
3
  import { MenuArrowProps, MenuCheckboxItemEmits, MenuCheckboxItemProps, MenuContentEmits, MenuContentProps, MenuEmits, MenuGroupProps, MenuItemEmits, MenuItemIndicatorProps, MenuItemProps, MenuLabelProps, MenuPortalProps, MenuProps, MenuRadioGroupEmits, MenuRadioGroupProps, MenuRadioItemEmits, MenuRadioItemProps, MenuSeparatorProps, MenuSubContentEmits, MenuSubContentProps, MenuSubEmits, MenuSubProps, MenuSubTriggerProps, PopperAnchorProps, _default$294 as _default$13, _default$295 as _default$8, _default$296 as _default, _default$297 as _default$6, _default$298 as _default$10, _default$299 as _default$3, _default$300 as _default$14, _default$301 as _default$12, _default$302 as _default$2, _default$303 as _default$1, _default$304 as _default$11, _default$305 as _default$7, _default$307 as _default$9, _default$308 as _default$4, _default$309 as _default$5, injectMenuContext, injectMenuRootContext } from "./index4.cjs";
4
- import * as vue14 from "vue";
4
+ import * as vue19 from "vue";
5
5
 
6
6
  //#region src/Menu/MenuAnchor.vue.d.ts
7
7
  interface MenuAnchorProps extends PopperAnchorProps {}
@@ -9,7 +9,7 @@ declare var __VLS_8: {};
9
9
  type __VLS_Slots = {} & {
10
10
  default?: (props: typeof __VLS_8) => any;
11
11
  };
12
- declare const __VLS_base: vue14.DefineComponent<MenuAnchorProps, {}, {}, {}, {}, vue14.ComponentOptionsMixin, vue14.ComponentOptionsMixin, {}, string, vue14.PublicProps, Readonly<MenuAnchorProps> & Readonly<{}>, {}, {}, {}, {}, string, vue14.ComponentProvideOptions, false, {}, any>;
12
+ declare const __VLS_base: vue19.DefineComponent<MenuAnchorProps, {}, {}, {}, {}, vue19.ComponentOptionsMixin, vue19.ComponentOptionsMixin, {}, string, vue19.PublicProps, Readonly<MenuAnchorProps> & Readonly<{}>, {}, {}, {}, {}, string, vue19.ComponentProvideOptions, false, {}, any>;
13
13
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
14
14
  declare const _default$15: typeof __VLS_export;
15
15
  type __VLS_WithSlots<T, S> = T & {
@@ -1,7 +1,7 @@
1
1
  import "./index2.js";
2
2
  import "./index3.js";
3
3
  import { MenuArrowProps, MenuCheckboxItemEmits, MenuCheckboxItemProps, MenuContentEmits, MenuContentProps, MenuEmits, MenuGroupProps, MenuItemEmits, MenuItemIndicatorProps, MenuItemProps, MenuLabelProps, MenuPortalProps, MenuProps, MenuRadioGroupEmits, MenuRadioGroupProps, MenuRadioItemEmits, MenuRadioItemProps, MenuSeparatorProps, MenuSubContentEmits, MenuSubContentProps, MenuSubEmits, MenuSubProps, MenuSubTriggerProps, PopperAnchorProps, _default$294 as _default$13, _default$295 as _default$8, _default$296 as _default, _default$297 as _default$6, _default$298 as _default$10, _default$299 as _default$3, _default$300 as _default$14, _default$301 as _default$12, _default$302 as _default$2, _default$303 as _default$1, _default$304 as _default$11, _default$305 as _default$7, _default$307 as _default$9, _default$308 as _default$4, _default$309 as _default$5, injectMenuContext, injectMenuRootContext } from "./index4.js";
4
- import * as vue99 from "vue";
4
+ import * as vue19 from "vue";
5
5
 
6
6
  //#region src/Menu/MenuAnchor.vue.d.ts
7
7
  interface MenuAnchorProps extends PopperAnchorProps {}
@@ -9,7 +9,7 @@ declare var __VLS_8: {};
9
9
  type __VLS_Slots = {} & {
10
10
  default?: (props: typeof __VLS_8) => any;
11
11
  };
12
- declare const __VLS_base: vue99.DefineComponent<MenuAnchorProps, {}, {}, {}, {}, vue99.ComponentOptionsMixin, vue99.ComponentOptionsMixin, {}, string, vue99.PublicProps, Readonly<MenuAnchorProps> & Readonly<{}>, {}, {}, {}, {}, string, vue99.ComponentProvideOptions, false, {}, any>;
12
+ declare const __VLS_base: vue19.DefineComponent<MenuAnchorProps, {}, {}, {}, {}, vue19.ComponentOptionsMixin, vue19.ComponentOptionsMixin, {}, string, vue19.PublicProps, Readonly<MenuAnchorProps> & Readonly<{}>, {}, {}, {}, {}, string, vue19.ComponentProvideOptions, false, {}, any>;
13
13
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
14
14
  declare const _default$15: typeof __VLS_export;
15
15
  type __VLS_WithSlots<T, S> = T & {
@@ -93,15 +93,35 @@ function useDateFormatter(initialLocale, opts = {}) {
93
93
  weekday: length
94
94
  }).format(date);
95
95
  }
96
- function dayPeriod(date) {
96
+ /**
97
+ * Resolves the internal `'AM'` / `'PM'` token for a date.
98
+ *
99
+ * The token is derived from the 24-hour clock rather than from the formatted
100
+ * `dayPeriod` part, because locales render that part in forms that cannot be
101
+ * matched reliably: `p. m.` in `es-ES`, `午後` in `ja-JP`, `下午` in `zh-CN`,
102
+ * `오후` in `ko-KR`, and so on. Matching on those strings made every such
103
+ * locale silently fall back to `'AM'`, which then made editing the hour
104
+ * segment convert a PM time into an AM one.
105
+ *
106
+ * `hourCycle`, `hour12` and `numberingSystem` are pinned so the hour always
107
+ * comes back as a Latin-digit 0-23 value, whatever `opts` the caller passed
108
+ * to `useDateFormatter`. `hour12` in particular takes precedence over
109
+ * `hourCycle` in `Intl`, so it has to be cleared rather than just overridden.
110
+ *
111
+ * Pass a `ZonedDateTime`'s own `timeZone` so the hour is read on that value's
112
+ * clock rather than the runtime's local one.
113
+ */
114
+ function dayPeriod(date, timeZone) {
97
115
  const parts = new __internationalized_date.DateFormatter(locale.value, {
98
116
  ...opts,
99
117
  hour: "numeric",
100
- minute: "numeric"
118
+ hourCycle: "h23",
119
+ hour12: void 0,
120
+ numberingSystem: "latn",
121
+ ...timeZone ? { timeZone } : {}
101
122
  }).formatToParts(date);
102
- const value = parts.find((p) => p.type === "dayPeriod")?.value;
103
- if (value === "PM" || value === "pm" || value === "p.m.") return "PM";
104
- return "AM";
123
+ const hour = Number(parts.find((p) => p.type === "hour")?.value);
124
+ return !Number.isNaN(hour) && hour >= 12 ? "PM" : "AM";
105
125
  }
106
126
  const defaultPartOptions = {
107
127
  year: "numeric",
@@ -1 +1 @@
1
- {"version":3,"file":"useDateFormatter.cjs","names":["initialLocale: string","opts: DateFormatterOptions","newLocale: string","date: Date","options: DateFormatterOptions","DateFormatter","date: DateValue","options?: DateFormatterOptions","length: DateFormatterOptions['weekday']","defaultPartOptions: DateFormatterOptions","dateObj: DateValue","type: Intl.DateTimeFormatPartTypes","opts","part"],"sources":["../../src/shared/useDateFormatter.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;AAoCA,SAAgB,iBAAiBA,eAAuBC,OAA6B,CAAE,GAAa;CAClG,MAAM,SAAS,aAAI,cAAc;CAEjC,SAAS,YAAY;AACnB,SAAO,OAAO;CACf;CAED,SAAS,UAAUC,WAAmB;AACpC,SAAO,QAAQ;CAChB;CAED,SAAS,OAAOC,MAAYC,SAA+B;AACzD,SAAO,IAAIC,uCAAc,OAAO,OAAO;GAAE,GAAG;GAAM,GAAG;EAAS,GAAE,OAAO,KAAK;CAC7E;CAED,SAAS,aAAaC,MAAiB,cAAc,MAAM;AACzD,MAAI,iCAAQ,KAAK,IAAI,YACnB,QAAO,OAAO,gCAAO,KAAK,EAAE;GAC1B,WAAW;GACX,WAAW;EACZ,EAAC;MAEF,QAAO,OAAO,gCAAO,KAAK,EAAE,EAC1B,WAAW,OACZ,EAAC;CAEL;CAED,SAAS,iBAAiBH,MAAYC,UAAgC,CAAE,GAAE;AACxE,SAAO,IAAIC,uCAAc,OAAO,OAAO;GAAE,GAAG;GAAM,OAAO;GAAQ,MAAM;GAAW,GAAG;EAAS,GAAE,OAAO,KAAK;CAC7G;CAED,SAAS,UAAUF,MAAYC,UAAgC,CAAE,GAAE;AACjE,SAAO,IAAIC,uCAAc,OAAO,OAAO;GAAE,GAAG;GAAM,OAAO;GAAQ,GAAG;EAAS,GAAE,OAAO,KAAK;CAC5F;CAED,SAAS,YAAY;EACnB,MAAM,cAAc,oCAAM,gDAAkB,CA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MQ,SAAO;GAAE,GAAG;GAAoB,GAAG;EAAS;EAClD,MAAM,QAAQ,QAAQ,SAASA,OAAK;EACpC,MAAMC,SAAO,MAAM,KAAK,CAAC,MAAM,EAAE,SAAS,KAAK;AAC/C,SAAOA,SAAOA,OAAK,QAAQ;CAC5B;AAED,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AACF"}
1
+ {"version":3,"file":"useDateFormatter.cjs","names":["initialLocale: string","opts: DateFormatterOptions","newLocale: string","date: Date","options: DateFormatterOptions","DateFormatter","date: DateValue","options?: DateFormatterOptions","length: DateFormatterOptions['weekday']","timeZone?: string","defaultPartOptions: DateFormatterOptions","dateObj: DateValue","type: Intl.DateTimeFormatPartTypes","opts","part"],"sources":["../../src/shared/useDateFormatter.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;AAoCA,SAAgB,iBAAiBA,eAAuBC,OAA6B,CAAE,GAAa;CAClG,MAAM,SAAS,aAAI,cAAc;CAEjC,SAAS,YAAY;AACnB,SAAO,OAAO;CACf;CAED,SAAS,UAAUC,WAAmB;AACpC,SAAO,QAAQ;CAChB;CAED,SAAS,OAAOC,MAAYC,SAA+B;AACzD,SAAO,IAAIC,uCAAc,OAAO,OAAO;GAAE,GAAG;GAAM,GAAG;EAAS,GAAE,OAAO,KAAK;CAC7E;CAED,SAAS,aAAaC,MAAiB,cAAc,MAAM;AACzD,MAAI,iCAAQ,KAAK,IAAI,YACnB,QAAO,OAAO,gCAAO,KAAK,EAAE;GAC1B,WAAW;GACX,WAAW;EACZ,EAAC;MAEF,QAAO,OAAO,gCAAO,KAAK,EAAE,EAC1B,WAAW,OACZ,EAAC;CAEL;CAED,SAAS,iBAAiBH,MAAYC,UAAgC,CAAE,GAAE;AACxE,SAAO,IAAIC,uCAAc,OAAO,OAAO;GAAE,GAAG;GAAM,OAAO;GAAQ,MAAM;GAAW,GAAG;EAAS,GAAE,OAAO,KAAK;CAC7G;CAED,SA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B,MAAM,OAAO,OAAO,MAAM,KAAK,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,MAAM;AAEhE,UAAQ,OAAO,MAAM,KAAK,IAAI,QAAQ,KAAK,OAAO;CACnD;CAED,MAAMK,qBAA2C;EAC/C,MAAM;EACN,OAAO;EACP,KAAK;EACL,MAAM;EACN,QAAQ;EACR,QAAQ;CACT;CAED,SAAS,KACPC,SACAC,MACAR,UAAgC,CAAE,GAClC;EACA,MAAMS,SAAO;GAAE,GAAG;GAAoB,GAAG;EAAS;EAClD,MAAM,QAAQ,QAAQ,SAASA,OAAK;EACpC,MAAMC,SAAO,MAAM,KAAK,CAAC,MAAM,EAAE,SAAS,KAAK;AAC/C,SAAOA,SAAOA,OAAK,QAAQ;CAC5B;AAED,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AACF"}
@@ -92,15 +92,35 @@ function useDateFormatter(initialLocale, opts = {}) {
92
92
  weekday: length
93
93
  }).format(date);
94
94
  }
95
- function dayPeriod(date) {
95
+ /**
96
+ * Resolves the internal `'AM'` / `'PM'` token for a date.
97
+ *
98
+ * The token is derived from the 24-hour clock rather than from the formatted
99
+ * `dayPeriod` part, because locales render that part in forms that cannot be
100
+ * matched reliably: `p. m.` in `es-ES`, `午後` in `ja-JP`, `下午` in `zh-CN`,
101
+ * `오후` in `ko-KR`, and so on. Matching on those strings made every such
102
+ * locale silently fall back to `'AM'`, which then made editing the hour
103
+ * segment convert a PM time into an AM one.
104
+ *
105
+ * `hourCycle`, `hour12` and `numberingSystem` are pinned so the hour always
106
+ * comes back as a Latin-digit 0-23 value, whatever `opts` the caller passed
107
+ * to `useDateFormatter`. `hour12` in particular takes precedence over
108
+ * `hourCycle` in `Intl`, so it has to be cleared rather than just overridden.
109
+ *
110
+ * Pass a `ZonedDateTime`'s own `timeZone` so the hour is read on that value's
111
+ * clock rather than the runtime's local one.
112
+ */
113
+ function dayPeriod(date, timeZone) {
96
114
  const parts = new DateFormatter(locale.value, {
97
115
  ...opts,
98
116
  hour: "numeric",
99
- minute: "numeric"
117
+ hourCycle: "h23",
118
+ hour12: void 0,
119
+ numberingSystem: "latn",
120
+ ...timeZone ? { timeZone } : {}
100
121
  }).formatToParts(date);
101
- const value = parts.find((p) => p.type === "dayPeriod")?.value;
102
- if (value === "PM" || value === "pm" || value === "p.m.") return "PM";
103
- return "AM";
122
+ const hour = Number(parts.find((p) => p.type === "hour")?.value);
123
+ return !Number.isNaN(hour) && hour >= 12 ? "PM" : "AM";
104
124
  }
105
125
  const defaultPartOptions = {
106
126
  year: "numeric",
@@ -1 +1 @@
1
- {"version":3,"file":"useDateFormatter.js","names":["initialLocale: string","opts: DateFormatterOptions","newLocale: string","date: Date","options: DateFormatterOptions","date: DateValue","options?: DateFormatterOptions","length: DateFormatterOptions['weekday']","defaultPartOptions: DateFormatterOptions","dateObj: DateValue","type: Intl.DateTimeFormatPartTypes","opts","part"],"sources":["../../src/shared/useDateFormatter.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;AAoCA,SAAgB,iBAAiBA,eAAuBC,OAA6B,CAAE,GAAa;CAClG,MAAM,SAAS,IAAI,cAAc;CAEjC,SAAS,YAAY;AACnB,SAAO,OAAO;CACf;CAED,SAAS,UAAUC,WAAmB;AACpC,SAAO,QAAQ;CAChB;CAED,SAAS,OAAOC,MAAYC,SAA+B;AACzD,SAAO,IAAI,cAAc,OAAO,OAAO;GAAE,GAAG;GAAM,GAAG;EAAS,GAAE,OAAO,KAAK;CAC7E;CAED,SAAS,aAAaC,MAAiB,cAAc,MAAM;AACzD,MAAI,QAAQ,KAAK,IAAI,YACnB,QAAO,OAAO,OAAO,KAAK,EAAE;GAC1B,WAAW;GACX,WAAW;EACZ,EAAC;MAEF,QAAO,OAAO,OAAO,KAAK,EAAE,EAC1B,WAAW,OACZ,EAAC;CAEL;CAED,SAAS,iBAAiBF,MAAYC,UAAgC,CAAE,GAAE;AACxE,SAAO,IAAI,cAAc,OA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,MAAM,KAAK,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE;AAEzD,MAAI,UAAU,QAAQ,UAAU,QAAQ,UAAU,OAChD,QAAO;AAGT,SAAO;CACR;CAED,MAAMK,qBAA2C;EAC/C,MAAM;EACN,OAAO;EACP,KAAK;EACL,MAAM;EACN,QAAQ;EACR,QAAQ;CACT;CAED,SAAS,KACPC,SACAC,MACAN,UAAgC,CAAE,GAClC;EACA,MAAMO,SAAO;GAAE,GAAG;GAAoB,GAAG;EAAS;EAClD,MAAM,QAAQ,QAAQ,SAASA,OAAK;EACpC,MAAMC,SAAO,MAAM,KAAK,CAAC,MAAM,EAAE,SAAS,KAAK;AAC/C,SAAOA,SAAOA,OAAK,QAAQ;CAC5B;AAED,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AACF"}
1
+ {"version":3,"file":"useDateFormatter.js","names":["initialLocale: string","opts: DateFormatterOptions","newLocale: string","date: Date","options: DateFormatterOptions","date: DateValue","options?: DateFormatterOptions","length: DateFormatterOptions['weekday']","timeZone?: string","defaultPartOptions: DateFormatterOptions","dateObj: DateValue","type: Intl.DateTimeFormatPartTypes","opts","part"],"sources":["../../src/shared/useDateFormatter.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;AAoCA,SAAgB,iBAAiBA,eAAuBC,OAA6B,CAAE,GAAa;CAClG,MAAM,SAAS,IAAI,cAAc;CAEjC,SAAS,YAAY;AACnB,SAAO,OAAO;CACf;CAED,SAAS,UAAUC,WAAmB;AACpC,SAAO,QAAQ;CAChB;CAED,SAAS,OAAOC,MAAYC,SAA+B;AACzD,SAAO,IAAI,cAAc,OAAO,OAAO;GAAE,GAAG;GAAM,GAAG;EAAS,GAAE,OAAO,KAAK;CAC7E;CAED,SAAS,aAAaC,MAAiB,cAAc,MAAM;AACzD,MAAI,QAAQ,KAAK,IAAI,YACnB,QAAO,OAAO,OAAO,KAAK,EAAE;GAC1B,WAAW;GACX,W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KAAK;CAClF;;;;;;;;;;;;;;;;;;;CAoBD,SAAS,UAAUJ,MAAYK,UAAmB;EAChD,MAAM,QAAQ,IAAI,cAAc,OAAO,OAAO;GAC5C,GAAG;GACH,MAAM;GACN,WAAW;GACX;GACA,iBAAiB;GACjB,GAAI,WAAW,EAAE,SAAU,IAAG,CAAE;EACjC,GAAE,cAAc,KAAK;EACtB,MAAM,OAAO,OAAO,MAAM,KAAK,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,MAAM;AAEhE,UAAQ,OAAO,MAAM,KAAK,IAAI,QAAQ,KAAK,OAAO;CACnD;CAED,MAAMC,qBAA2C;EAC/C,MAAM;EACN,OAAO;EACP,KAAK;EACL,MAAM;EACN,QAAQ;EACR,QAAQ;CACT;CAED,SAAS,KACPC,SACAC,MACAP,UAAgC,CAAE,GAClC;EACA,MAAMQ,SAAO;GAAE,GAAG;GAAoB,GAAG;EAAS;EAClD,MAAM,QAAQ,QAAQ,SAASA,OAAK;EACpC,MAAMC,SAAO,MAAM,KAAK,CAAC,MAAM,EAAE,SAAS,KAAK;AAC/C,SAAOA,SAAOA,OAAK,QAAQ;CAC5B;AAED,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "akar",
3
3
  "type": "module",
4
- "version": "2.0.17",
4
+ "version": "2.0.18",
5
5
  "description": "Vue UI primitives components",
6
6
  "author": "Vinicunca Contributors (https://github.com/vinicunca)",
7
7
  "license": "MIT",
@@ -109,10 +109,10 @@
109
109
  "@tsconfig/node24": "^24.0.0",
110
110
  "@types/jsdom": "^30.0.0",
111
111
  "@types/node": "^24.0.13",
112
- "@vitejs/plugin-vue": "^6.0.8",
112
+ "@vitejs/plugin-vue": "^6.0.9",
113
113
  "@vitest/coverage-istanbul": "^3.2.7",
114
114
  "@vue/server-renderer": "^3.5.17",
115
- "@vue/test-utils": "^2.5.0",
115
+ "@vue/test-utils": "^2.5.1",
116
116
  "@vue/tsconfig": "^0.7.0",
117
117
  "jsdom": "^26.1.0",
118
118
  "size-limit": "^12.0.1",
@@ -3,61 +3,129 @@ import type { Ref } from 'vue';
3
3
  import { NumberFormatter, NumberParser } from '@internationalized/number';
4
4
  import { unrefElement, useEventListener } from '@vueuse/core';
5
5
  import { createEventHook, isClient, reactiveComputed } from '@vueuse/shared';
6
- import { computed, ref } from 'vue';
6
+ import { computed, onScopeDispose, ref } from 'vue';
7
+
8
+ const HOLD_DELAY = 400;
9
+ const REPEAT_INTERVAL = 60;
10
+ const TOUCH_MOVE_TOLERANCE = 10;
7
11
 
8
12
  export function usePressedHold(options: { target?: MaybeComputedElementRef; disabled: Ref<boolean> }) {
9
13
  const { disabled } = options;
10
14
  const timeout = ref<number>();
11
15
  const triggerHook = createEventHook();
12
- const resetTimeout = () => window.clearTimeout(timeout.value);
13
-
14
- const onIncrementPressStart = (delay: number) => {
15
- resetTimeout();
16
- if (disabled.value) {
16
+ const isPressed = ref(false);
17
+ const target = computed(() => unrefElement(options.target));
18
+ let activePointerId: number | undefined;
19
+ let activePointerType = '';
20
+ let startX = 0;
21
+ let startY = 0;
22
+ let holdTriggered = false;
23
+
24
+ const resetTimeout = () => {
25
+ if (timeout.value === undefined) {
17
26
  return;
18
27
  }
19
28
 
20
- triggerHook.trigger();
29
+ window.clearTimeout(timeout.value);
30
+ timeout.value = undefined;
31
+ };
21
32
 
22
- timeout.value = window.setTimeout(() => {
23
- onIncrementPressStart(60);
24
- }, delay);
33
+ const resetPress = () => {
34
+ resetTimeout();
35
+ activePointerId = undefined;
36
+ activePointerType = '';
37
+ holdTriggered = false;
38
+ isPressed.value = false;
25
39
  };
26
40
 
27
- const handlePressStart = () => {
28
- onIncrementPressStart(400);
41
+ const trigger = () => {
42
+ if (disabled.value) {
43
+ resetPress();
44
+ return false;
45
+ }
46
+
47
+ triggerHook.trigger();
48
+ return true;
29
49
  };
30
50
 
31
- const handlePressEnd = () => {
51
+ const scheduleRepeat = (delay: number) => {
32
52
  resetTimeout();
53
+ timeout.value = window.setTimeout(() => {
54
+ holdTriggered = true;
55
+ if (trigger()) {
56
+ scheduleRepeat(REPEAT_INTERVAL);
57
+ }
58
+ }, delay);
33
59
  };
34
60
 
35
61
  // Handle press event, modified version of useMousePressed
36
- const isPressed = ref(false);
37
- const target = computed(() => unrefElement(options.target));
38
-
39
62
  const onPressStart = (event: PointerEvent) => {
40
63
  // Only handle left clicks, and ignore events that bubbled through portals.
41
- if (event.button !== 0 || isPressed.value) {
64
+ if (event.button !== 0 || isPressed.value || disabled.value) {
42
65
  return;
43
66
  }
44
67
 
45
68
  event.preventDefault();
69
+ activePointerId = event.pointerId;
70
+ activePointerType = event.pointerType;
71
+ startX = event.clientX;
72
+ startY = event.clientY;
73
+ holdTriggered = false;
46
74
  isPressed.value = true;
47
- handlePressStart();
75
+
76
+ if (event.pointerType === 'mouse') {
77
+ holdTriggered = true;
78
+ if (trigger()) {
79
+ scheduleRepeat(HOLD_DELAY);
80
+ }
81
+ return;
82
+ }
83
+
84
+ scheduleRepeat(HOLD_DELAY);
48
85
  };
49
86
 
50
- const onPressRelease = () => {
51
- isPressed.value = false;
52
- handlePressEnd();
87
+ const onPressMove = (event: PointerEvent) => {
88
+ if (event.pointerId !== activePointerId || activePointerType === 'mouse') {
89
+ return;
90
+ }
91
+
92
+ const distanceX = event.clientX - startX;
93
+ const distanceY = event.clientY - startY;
94
+ const movedBeyondTolerance = distanceX * distanceX + distanceY * distanceY > TOUCH_MOVE_TOLERANCE ** 2;
95
+
96
+ if (movedBeyondTolerance) {
97
+ resetPress();
98
+ }
99
+ };
100
+
101
+ const onPressRelease = (event: PointerEvent) => {
102
+ if (event.pointerId !== activePointerId) {
103
+ return;
104
+ }
105
+
106
+ const shouldTriggerTap = activePointerType !== 'mouse' && !holdTriggered;
107
+ resetPress();
108
+
109
+ if (shouldTriggerTap) {
110
+ trigger();
111
+ }
112
+ };
113
+
114
+ const onPressCancel = (event: PointerEvent) => {
115
+ if (event.pointerId === activePointerId) {
116
+ resetPress();
117
+ }
53
118
  };
54
119
 
55
120
  if (isClient) {
56
121
  useEventListener(target || window, 'pointerdown', onPressStart);
122
+ useEventListener(window, 'pointermove', onPressMove);
57
123
  useEventListener(window, 'pointerup', onPressRelease);
58
- useEventListener(window, 'pointercancel', onPressRelease);
124
+ useEventListener(window, 'pointercancel', onPressCancel);
59
125
  }
60
126
 
127
+ onScopeDispose(resetPress);
128
+
61
129
  return {
62
130
  isPressed,
63
131
  onTrigger: triggerHook.on,
@@ -193,6 +193,15 @@ function handleKeyDown(event: KeyboardEvent) {
193
193
  event.preventDefault();
194
194
  }
195
195
 
196
+ // Space selects the item when no search is in progress; otherwise it's part of the search
197
+ if (event.code === 'Space') {
198
+ if (search.value === '') {
199
+ return;
200
+ }
201
+ // SelectItem skips Space during a search, so prevent the scroll here
202
+ event.preventDefault();
203
+ }
204
+
196
205
  if (!isModifierKey && event.key.length === 1) {
197
206
  handleTypeaheadSearch(event.key, getItems());
198
207
  }
@@ -20,7 +20,8 @@ type SyncTimeSegmentValuesProps = {
20
20
  export function syncTimeSegmentValues(props: SyncTimeSegmentValuesProps) {
21
21
  return Object.fromEntries(TIME_SEGMENT_PARTS.map((part) => {
22
22
  if (part === 'dayPeriod') {
23
- return [part, props.formatter.dayPeriod(toDate(props.value))];
23
+ const timeZone = isZonedDateTime(props.value) ? props.value.timeZone : undefined;
24
+ return [part, props.formatter.dayPeriod(toDate(props.value), timeZone)];
24
25
  }
25
26
  return [part, props.value[part as keyof DateValue]];
26
27
  })) as SegmentValueObj;
@@ -20,7 +20,7 @@ export type Formatter = {
20
20
  fullMonthAndYear: (date: Date, options?: DateFormatterOptions) => string;
21
21
  fullMonth: (date: Date, options?: DateFormatterOptions) => string;
22
22
  fullYear: (date: Date, options?: DateFormatterOptions) => string;
23
- dayPeriod: (date: Date) => string;
23
+ dayPeriod: (date: Date, timeZone?: string) => string;
24
24
  part: (dateObj: DateValue, type: Intl.DateTimeFormatPartTypes, options?: DateFormatterOptions) => string;
25
25
  toParts: (date: DateValue, options?: DateFormatterOptions) => Array<Intl.DateTimeFormatPart>;
26
26
  getMonths: () => Array<{ label: string; value: number }>;
@@ -96,19 +96,36 @@ export function useDateFormatter(initialLocale: string, opts: DateFormatterOptio
96
96
  return new DateFormatter(locale.value, { ...opts, weekday: length }).format(date);
97
97
  }
98
98
 
99
- function dayPeriod(date: Date) {
99
+ /**
100
+ * Resolves the internal `'AM'` / `'PM'` token for a date.
101
+ *
102
+ * The token is derived from the 24-hour clock rather than from the formatted
103
+ * `dayPeriod` part, because locales render that part in forms that cannot be
104
+ * matched reliably: `p. m.` in `es-ES`, `午後` in `ja-JP`, `下午` in `zh-CN`,
105
+ * `오후` in `ko-KR`, and so on. Matching on those strings made every such
106
+ * locale silently fall back to `'AM'`, which then made editing the hour
107
+ * segment convert a PM time into an AM one.
108
+ *
109
+ * `hourCycle`, `hour12` and `numberingSystem` are pinned so the hour always
110
+ * comes back as a Latin-digit 0-23 value, whatever `opts` the caller passed
111
+ * to `useDateFormatter`. `hour12` in particular takes precedence over
112
+ * `hourCycle` in `Intl`, so it has to be cleared rather than just overridden.
113
+ *
114
+ * Pass a `ZonedDateTime`'s own `timeZone` so the hour is read on that value's
115
+ * clock rather than the runtime's local one.
116
+ */
117
+ function dayPeriod(date: Date, timeZone?: string) {
100
118
  const parts = new DateFormatter(locale.value, {
101
119
  ...opts,
102
120
  hour: 'numeric',
103
- minute: 'numeric',
121
+ hourCycle: 'h23',
122
+ hour12: undefined,
123
+ numberingSystem: 'latn',
124
+ ...(timeZone ? { timeZone } : {}),
104
125
  }).formatToParts(date);
105
- const value = parts.find((p) => p.type === 'dayPeriod')?.value;
106
- // Day period can be "AM"/"PM" or "am"/"pm" or "a.m."/"p.m." in some locales
107
- if (value === 'PM' || value === 'pm' || value === 'p.m.') {
108
- return 'PM';
109
- }
126
+ const hour = Number(parts.find((p) => p.type === 'hour')?.value);
110
127
 
111
- return 'AM';
128
+ return !Number.isNaN(hour) && hour >= 12 ? 'PM' : 'AM';
112
129
  }
113
130
 
114
131
  const defaultPartOptions: DateFormatterOptions = {