@hozo/behaviors 0.1.0 → 0.3.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.
- package/CHANGELOG.md +49 -0
- package/README.md +16 -2
- package/dist/accessibility-focus.native.d.ts +23 -0
- package/dist/accessibility-focus.native.d.ts.map +1 -0
- package/dist/accessibility-focus.native.js +81 -0
- package/dist/accessibility-focus.native.js.map +1 -0
- package/dist/command-shortcut.d.ts +23 -0
- package/dist/command-shortcut.d.ts.map +1 -0
- package/dist/command-shortcut.js +47 -0
- package/dist/command-shortcut.js.map +1 -0
- package/dist/command-shortcut.native.d.ts +11 -0
- package/dist/command-shortcut.native.d.ts.map +1 -0
- package/dist/command-shortcut.native.js +11 -0
- package/dist/command-shortcut.native.js.map +1 -0
- package/dist/focus-scope.d.ts +9 -1
- package/dist/focus-scope.d.ts.map +1 -1
- package/dist/focus-scope.js +43 -11
- package/dist/focus-scope.js.map +1 -1
- package/dist/i18n.d.ts +140 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/i18n.js +144 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/index.native.d.ts +3 -0
- package/dist/index.native.d.ts.map +1 -1
- package/dist/index.native.js +3 -0
- package/dist/index.native.js.map +1 -1
- package/dist/native.d.ts +3 -0
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js +3 -0
- package/dist/native.js.map +1 -1
- package/dist/presence.d.ts +19 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +96 -0
- package/dist/presence.js.map +1 -0
- package/dist/presence.native.d.ts +10 -0
- package/dist/presence.native.d.ts.map +1 -0
- package/dist/presence.native.js +18 -0
- package/dist/presence.native.js.map +1 -0
- package/dist/pressable-interaction.d.ts +30 -0
- package/dist/pressable-interaction.d.ts.map +1 -0
- package/dist/pressable-interaction.js +64 -0
- package/dist/pressable-interaction.js.map +1 -0
- package/package.json +7 -2
- package/src/accessibility-focus.native.ts +88 -0
- package/src/command-shortcut.native.ts +15 -0
- package/src/command-shortcut.ts +51 -0
- package/src/focus-scope.tsx +49 -8
- package/src/i18n.ts +198 -0
- package/src/index.native.ts +20 -0
- package/src/index.ts +24 -0
- package/src/native.ts +22 -0
- package/src/presence.native.ts +27 -0
- package/src/presence.ts +118 -0
- package/src/pressable-interaction.ts +79 -0
package/dist/i18n.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// How Hozo's own strings and locale reach an application's i18n library
|
|
2
|
+
// (decision 008).
|
|
3
|
+
//
|
|
4
|
+
// Hozo does not translate. Applications already have a library for that --
|
|
5
|
+
// i18next, react-intl, Lingui -- with plural rules, interpolation and
|
|
6
|
+
// catalogues, and Hozo's strings belong in the same catalogue as the rest.
|
|
7
|
+
// So this is only the connection: a context carrying `locale`, `dir` and a
|
|
8
|
+
// `translate` function, the English every component falls back to, and two
|
|
9
|
+
// adapters that are a few lines each and typed structurally, so no
|
|
10
|
+
// `@hozo/*` package depends on any library.
|
|
11
|
+
//
|
|
12
|
+
// Platform-neutral on purpose: one file, imported by both entry points, so a
|
|
13
|
+
// provider on one side is the same object on the other.
|
|
14
|
+
import { createContext, createElement, useCallback, useContext } from 'react';
|
|
15
|
+
/**
|
|
16
|
+
* Every string Hozo's components show or announce, in English, by key.
|
|
17
|
+
*
|
|
18
|
+
* Exported so a project can seed its catalogue from it, and so a test can
|
|
19
|
+
* check none is missing. Parameters are named (`{remaining}`), because every
|
|
20
|
+
* library this connects to interpolates by name.
|
|
21
|
+
*/
|
|
22
|
+
export const hozoMessages = {
|
|
23
|
+
'hozo.avatar.label': '{name}, {status}',
|
|
24
|
+
'hozo.avatar.statusBusy': 'busy',
|
|
25
|
+
'hozo.avatar.statusOffline': 'offline',
|
|
26
|
+
'hozo.avatar.statusOnline': 'online',
|
|
27
|
+
'hozo.badge.overflow': 'more than {max}',
|
|
28
|
+
'hozo.bottomSheet.handle': 'Resize',
|
|
29
|
+
'hozo.calendar.nextMonth': 'Next month',
|
|
30
|
+
'hozo.calendar.previousMonth': 'Previous month',
|
|
31
|
+
'hozo.calendar.rangeEnd': 'end of range',
|
|
32
|
+
'hozo.calendar.rangeStart': 'start of range',
|
|
33
|
+
'hozo.calendar.today': 'today',
|
|
34
|
+
'hozo.chip.remove': 'Remove {label}',
|
|
35
|
+
'hozo.color.black': 'black',
|
|
36
|
+
'hozo.color.blue': 'blue',
|
|
37
|
+
'hozo.color.cyan': 'cyan',
|
|
38
|
+
'hozo.color.dark': 'dark {color}',
|
|
39
|
+
'hozo.color.gray': 'gray',
|
|
40
|
+
'hozo.color.green': 'green',
|
|
41
|
+
'hozo.color.light': 'light {color}',
|
|
42
|
+
'hozo.color.orange': 'orange',
|
|
43
|
+
'hozo.color.pink': 'pink',
|
|
44
|
+
'hozo.color.purple': 'purple',
|
|
45
|
+
'hozo.color.red': 'red',
|
|
46
|
+
'hozo.color.white': 'white',
|
|
47
|
+
'hozo.color.yellow': 'yellow',
|
|
48
|
+
'hozo.colorPicker.alpha': 'Opacity',
|
|
49
|
+
'hozo.colorPicker.alphaValue': '{value}% opaque',
|
|
50
|
+
'hozo.colorPicker.described': '{name}, {hex}',
|
|
51
|
+
'hozo.colorPicker.eyeDropper': 'Pick a colour from the screen',
|
|
52
|
+
'hozo.colorPicker.hex': 'Hex colour',
|
|
53
|
+
'hozo.colorPicker.hue': 'Hue',
|
|
54
|
+
'hozo.colorPicker.hueValue': '{degrees} degrees, {name}',
|
|
55
|
+
'hozo.colorPicker.lightness': 'Lightness',
|
|
56
|
+
'hozo.colorPicker.percent': '{value}%',
|
|
57
|
+
'hozo.colorPicker.presets': 'Presets',
|
|
58
|
+
'hozo.colorPicker.saturation': 'Saturation',
|
|
59
|
+
'hozo.commandPalette.empty': 'No results',
|
|
60
|
+
'hozo.commandPalette.label': 'Command palette',
|
|
61
|
+
'hozo.commandPalette.oneResult': '1 result',
|
|
62
|
+
'hozo.commandPalette.results': '{count} results',
|
|
63
|
+
'hozo.datePicker.dialog': 'Choose a date',
|
|
64
|
+
'hozo.dateRangePicker.dialog': 'Choose a range of dates',
|
|
65
|
+
'hozo.dateTimePicker.dialog': 'Choose a date and time',
|
|
66
|
+
'hozo.dateTimePicker.done': 'Done',
|
|
67
|
+
'hozo.fileDropzone.selectedMany': '{count} files selected',
|
|
68
|
+
'hozo.fileDropzone.selectedOne': '{name} selected, {size}',
|
|
69
|
+
'hozo.fileDropzone.tooLarge': '{name} is too large: {size}, and the limit is {limit}',
|
|
70
|
+
'hozo.fileDropzone.tooMany': '{name} was not added: one pick takes {max}',
|
|
71
|
+
'hozo.fileDropzone.tooSmall': '{name} is too small: {size}',
|
|
72
|
+
'hozo.fileDropzone.unavailable': 'No file picker is available',
|
|
73
|
+
'hozo.fileDropzone.wrongType': '{name} is not an accepted kind of file',
|
|
74
|
+
'hozo.nativeSelect.cancel': 'Cancel',
|
|
75
|
+
'hozo.otpInput.hint': '{length} characters',
|
|
76
|
+
'hozo.pagination.label': 'Pagination',
|
|
77
|
+
'hozo.pagination.next': 'Next page',
|
|
78
|
+
'hozo.pagination.page': 'Page {page}',
|
|
79
|
+
'hozo.pagination.previous': 'Previous page',
|
|
80
|
+
'hozo.stepper.completed': 'completed',
|
|
81
|
+
'hozo.stepper.current': 'current',
|
|
82
|
+
'hozo.stepper.error': 'has an error',
|
|
83
|
+
'hozo.stepper.label': 'Progress',
|
|
84
|
+
'hozo.stepper.step': 'Step {step} of {count}: {label}, {status}',
|
|
85
|
+
'hozo.stepper.upcoming': 'not started',
|
|
86
|
+
'hozo.textArea.remaining': '{remaining} of {maxLength} characters left',
|
|
87
|
+
'hozo.timePicker.decrease': 'Decrease',
|
|
88
|
+
'hozo.timePicker.empty': '--',
|
|
89
|
+
'hozo.timePicker.hour': 'Hour',
|
|
90
|
+
'hozo.timePicker.increase': 'Increase',
|
|
91
|
+
'hozo.timePicker.minute': 'Minute',
|
|
92
|
+
'hozo.timePicker.period': 'AM or PM',
|
|
93
|
+
};
|
|
94
|
+
const HozoI18nContext = createContext({});
|
|
95
|
+
/**
|
|
96
|
+
* Puts a project's i18n where Hozo's components can read it.
|
|
97
|
+
*
|
|
98
|
+
* Give it a new `value` when the language changes -- `useMemo` on the
|
|
99
|
+
* language -- and every Hozo string below re-renders in it.
|
|
100
|
+
*/
|
|
101
|
+
export function HozoI18nProvider({ value, children }) {
|
|
102
|
+
return createElement(HozoI18nContext.Provider, { value }, children);
|
|
103
|
+
}
|
|
104
|
+
export function useHozoI18n() {
|
|
105
|
+
return useContext(HozoI18nContext);
|
|
106
|
+
}
|
|
107
|
+
function interpolate(template, params) {
|
|
108
|
+
return template.replace(/\{(\w+)\}/g, (whole, name) => name in params ? String(params[name]) : whole);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* A function resolving one of Hozo's strings: the component's own prop if
|
|
112
|
+
* there is one, then the project's translation, then Hozo's English.
|
|
113
|
+
*/
|
|
114
|
+
export function useHozoMessage() {
|
|
115
|
+
const { translate } = useHozoI18n();
|
|
116
|
+
return useCallback((key, params = {}, explicit) => {
|
|
117
|
+
if (explicit !== undefined)
|
|
118
|
+
return explicit;
|
|
119
|
+
const fallback = interpolate(hozoMessages[key], params);
|
|
120
|
+
return translate ? translate(key, params, fallback) : fallback;
|
|
121
|
+
}, [translate]);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Hozo's i18n from an i18next instance: Hozo's keys are i18next keys, and
|
|
125
|
+
* Hozo's English is i18next's `defaultValue`.
|
|
126
|
+
*/
|
|
127
|
+
export function fromI18next(i18n) {
|
|
128
|
+
return {
|
|
129
|
+
locale: i18n.language,
|
|
130
|
+
dir: i18n.dir?.(i18n.language),
|
|
131
|
+
translate: (key, params, fallback) => i18n.t(key, { ...params, defaultValue: fallback }),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Hozo's i18n from react-intl: Hozo's keys are message ids, and Hozo's
|
|
136
|
+
* English is the `defaultMessage`.
|
|
137
|
+
*/
|
|
138
|
+
export function fromReactIntl(intl) {
|
|
139
|
+
return {
|
|
140
|
+
locale: intl.locale,
|
|
141
|
+
translate: (key, params, fallback) => intl.formatMessage({ id: key, defaultMessage: fallback }, params),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=i18n.js.map
|
package/dist/i18n.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,kBAAkB;AAClB,EAAE;AACF,2EAA2E;AAC3E,sEAAsE;AACtE,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,mEAAmE;AACnE,4CAA4C;AAC5C,EAAE;AACF,6EAA6E;AAC7E,wDAAwD;AAExD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAkB,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAE7F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,mBAAmB,EAAE,kBAAkB;IACvC,wBAAwB,EAAE,MAAM;IAChC,2BAA2B,EAAE,SAAS;IACtC,0BAA0B,EAAE,QAAQ;IACpC,qBAAqB,EAAE,iBAAiB;IACxC,yBAAyB,EAAE,QAAQ;IACnC,yBAAyB,EAAE,YAAY;IACvC,6BAA6B,EAAE,gBAAgB;IAC/C,wBAAwB,EAAE,cAAc;IACxC,0BAA0B,EAAE,gBAAgB;IAC5C,qBAAqB,EAAE,OAAO;IAC9B,kBAAkB,EAAE,gBAAgB;IACpC,kBAAkB,EAAE,OAAO;IAC3B,iBAAiB,EAAE,MAAM;IACzB,iBAAiB,EAAE,MAAM;IACzB,iBAAiB,EAAE,cAAc;IACjC,iBAAiB,EAAE,MAAM;IACzB,kBAAkB,EAAE,OAAO;IAC3B,kBAAkB,EAAE,eAAe;IACnC,mBAA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,SAAS,CAAC,CACZ,CAAA;AACH,CAAC;AASD;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAiB;IAC3C,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,QAAQ;QACrB,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC9B,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,GAAG,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;KACzF,CAAA;AACH,CAAC;AAWD;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,IAAmB;IAC/C,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CACnC,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,MAAM,CAAC;KACpE,CAAA;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
export { type CommandShortcutOptions, isApplePlatform, useCommandShortcut, } from './command-shortcut.ts';
|
|
1
2
|
export { DismissableLayer, type DismissableLayerProps, } from './dismissable-layer.tsx';
|
|
2
3
|
export { type Alignment, type BasePlacement, type ComputePositionOptions, computePosition, type Placement, type PositionResult, parsePlacement, type Rect, type Viewport, } from './floating-geometry.ts';
|
|
3
4
|
export { FloatingPositioner, type FloatingPositionerProps, type UseFloatingPositionOptions, useFloatingPosition, } from './floating-positioner.tsx';
|
|
4
5
|
export { type FocusCandidate, FocusScope, type FocusScopeProps, initialFocusIndex, shouldRestoreFocus, } from './focus-scope.tsx';
|
|
5
6
|
export { computeSafePolygon, type DelayGroupConfig, DelayGroupMachine, isPointInPolygon, type Point, type Polygon, } from './hover-geometry.ts';
|
|
6
7
|
export { type ContentProps, TooltipGroupProvider, type TooltipGroupProviderProps, type TriggerProps, type UseHoverTriggerOptions, type UseHoverTriggerReturn, useHoverTrigger, useTooltipGroup, } from './hover-trigger.tsx';
|
|
8
|
+
export { fromI18next, fromReactIntl, type HozoI18n, HozoI18nProvider, type HozoI18nProviderProps, type HozoMessageKey, type HozoMessageParams, hozoMessages, type I18nextLike, type ReactIntlLike, useHozoI18n, useHozoMessage, } from './i18n.ts';
|
|
7
9
|
export { LiveRegion, type LiveRegionMode, type LiveRegionProps, useAnnounce, } from './live-region.tsx';
|
|
8
10
|
export { Portal, PortalHost, type PortalProps, PortalProvider, } from './portal.tsx';
|
|
11
|
+
export { type PresenceBinding, type PresenceState, usePresence, } from './presence.ts';
|
|
9
12
|
export { nextIndex, type Orientation, RovingFocusGroup, type RovingFocusGroupProps, type RovingKey, type RovingOptions, tabStops, useRovingItem, } from './roving-focus.tsx';
|
|
10
13
|
export { hozoTextChildren } from './text-child.ts';
|
|
11
14
|
export { isTypeaheadKey, nextSearch, searchIndex, TYPEAHEAD_TIMEOUT_MS, type TypeaheadOptions, useTypeahead, } from './typeahead.ts';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,eAAe,EACf,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,cAAc,EACd,KAAK,IAAI,EACT,KAAK,QAAQ,GACd,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAC/B,mBAAmB,GACpB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,KAAK,cAAc,EACnB,UAAU,EACV,KAAK,eAAe,EACpB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,KAAK,EACV,KAAK,OAAO,GACb,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,KAAK,YAAY,EACjB,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,eAAe,EACf,eAAe,GAChB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,WAAW,GACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,MAAM,EACN,UAAU,EACV,KAAK,WAAW,EAChB,cAAc,GACf,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,SAAS,EACT,KAAK,WAAW,EAChB,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,QAAQ,EACR,aAAa,GACd,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EACL,cAAc,EACd,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,KAAK,gBAAgB,EACrB,YAAY,GACb,MAAM,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,sBAAsB,EAC3B,eAAe,EACf,kBAAkB,GACnB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,eAAe,EACf,KAAK,SAA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AAQ,EACR,aAAa,GACd,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EACL,cAAc,EACd,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,KAAK,gBAAgB,EACrB,YAAY,GACb,MAAM,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
export { isApplePlatform, useCommandShortcut, } from './command-shortcut.js';
|
|
1
2
|
export { DismissableLayer, } from './dismissable-layer.js';
|
|
2
3
|
export { computePosition, parsePlacement, } from './floating-geometry.js';
|
|
3
4
|
export { FloatingPositioner, useFloatingPosition, } from './floating-positioner.js';
|
|
4
5
|
export { FocusScope, initialFocusIndex, shouldRestoreFocus, } from './focus-scope.js';
|
|
5
6
|
export { computeSafePolygon, DelayGroupMachine, isPointInPolygon, } from './hover-geometry.js';
|
|
6
7
|
export { TooltipGroupProvider, useHoverTrigger, useTooltipGroup, } from './hover-trigger.js';
|
|
8
|
+
export { fromI18next, fromReactIntl, HozoI18nProvider, hozoMessages, useHozoI18n, useHozoMessage, } from './i18n.js';
|
|
7
9
|
export { LiveRegion, useAnnounce, } from './live-region.js';
|
|
8
10
|
export { Portal, PortalHost, PortalProvider, } from './portal.js';
|
|
11
|
+
export { usePresence, } from './presence.js';
|
|
9
12
|
export { nextIndex, RovingFocusGroup, tabStops, useRovingItem, } from './roving-focus.js';
|
|
10
13
|
export { hozoTextChildren } from './text-child.js';
|
|
11
14
|
export { isTypeaheadKey, nextSearch, searchIndex, TYPEAHEAD_TIMEOUT_MS, useTypeahead, } from './typeahead.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,GAEjB,MAAM,wBAAyB,CAAA;AAChC,OAAO,EAIL,eAAe,EAGf,cAAc,GAGf,M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GAChB,MAAM,oBAAqB,CAAA;AAC5B,OAAO,EACL,WAAW,EACX,aAAa,EAEb,gBAAgB,EAIhB,YAAY,EAGZ,WAAW,EACX,cAAc,GACf,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,UAAU,EAGV,WAAW,GACZ,MAAM,kBAAmB,CAAA;AAC1B,OAAO,EACL,MAAM,EACN,UAAU,EAEV,cAAc,GACf,MAAM,aAAc,CAAA;AACrB,OAAO,EAGL,WAAW,GACZ,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,SAAS,EAET,gBAAgB,EAIhB,QAAQ,EACR,aAAa,GACd,MAAM,mBAAoB,CAAA;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EACL,cAAc,EACd,UAAU,EACV,WAAW,EACX,oBAAoB,EAEpB,YAAY,GACb,MAAM,gBAAgB,CAAA"}
|
package/dist/index.native.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
export { type CommandShortcutOptions, isApplePlatform, useCommandShortcut, } from './command-shortcut.native.ts';
|
|
1
2
|
export { DismissableLayer, type DismissableLayerProps, } from './dismissable-layer.native.tsx';
|
|
2
3
|
export { type Alignment, type BasePlacement, type ComputePositionOptions, computePosition, type Placement, type PositionResult, parsePlacement, type Rect, type Viewport, } from './floating-geometry.ts';
|
|
3
4
|
export { FloatingPositioner, type FloatingPositionerProps, type UseFloatingPositionOptions, useFloatingPosition, } from './floating-positioner.native.tsx';
|
|
4
5
|
export { type FocusCandidate, FocusScope, type FocusScopeProps, initialFocusIndex, shouldRestoreFocus, } from './focus-scope.native.tsx';
|
|
5
6
|
export { computeSafePolygon, type DelayGroupConfig, DelayGroupMachine, isPointInPolygon, type Point, type Polygon, } from './hover-geometry.ts';
|
|
6
7
|
export { type NativeContentProps as ContentProps, type NativeTriggerProps as TriggerProps, TooltipGroupProvider, type TooltipGroupProviderProps, type UseHoverTriggerOptions, type UseHoverTriggerReturn, useHoverTrigger, useTooltipGroup, } from './hover-trigger.native.tsx';
|
|
8
|
+
export { fromI18next, fromReactIntl, type HozoI18n, HozoI18nProvider, type HozoI18nProviderProps, type HozoMessageKey, type HozoMessageParams, hozoMessages, type I18nextLike, type ReactIntlLike, useHozoI18n, useHozoMessage, } from './i18n.ts';
|
|
7
9
|
export { LiveRegion, type LiveRegionMode, type LiveRegionProps, useAnnounce, } from './live-region.native.tsx';
|
|
8
10
|
export { Portal, PortalHost, type PortalProps, PortalProvider, } from './portal.native.tsx';
|
|
11
|
+
export { type PresenceBinding, type PresenceState, usePresence } from './presence.native.ts';
|
|
9
12
|
export { nextIndex, type Orientation, RovingFocusGroup, type RovingFocusGroupProps, type RovingKey, type RovingOptions, tabStops, useRovingItem, } from './roving-focus.native.tsx';
|
|
10
13
|
export { hozoTextChildren } from './text-child.native.tsx';
|
|
11
14
|
export { isTypeaheadKey, nextSearch, searchIndex, TYPEAHEAD_TIMEOUT_MS, type TypeaheadOptions, useTypeahead, } from './typeahead.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../src/index.native.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,eAAe,EACf,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,cAAc,EACd,KAAK,IAAI,EACT,KAAK,QAAQ,GACd,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAC/B,mBAAmB,GACpB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACL,KAAK,cAAc,EACnB,UAAU,EACV,KAAK,eAAe,EACpB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,KAAK,EACV,KAAK,OAAO,GACb,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,KAAK,kBAAkB,IAAI,YAAY,EACvC,KAAK,kBAAkB,IAAI,YAAY,EACvC,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,eAAe,EACf,eAAe,GAChB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACL,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,WAAW,GACZ,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,MAAM,EACN,UAAU,EACV,KAAK,WAAW,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,SAAS,EACT,KAAK,WAAW,EAChB,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,QAAQ,EACR,aAAa,GACd,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EACL,cAAc,EACd,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,KAAK,gBAAgB,EACrB,YAAY,GACb,MAAM,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../src/index.native.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,sBAAsB,EAC3B,eAAe,EACf,kBAAkB,GACnB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,eAAe,EACf,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,cAAc,EACd,KAAK,IAAI,EACT,KAAK,QAAQ,GACd,MAAM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AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EACL,cAAc,EACd,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,KAAK,gBAAgB,EACrB,YAAY,GACb,MAAM,gBAAgB,CAAA"}
|
package/dist/index.native.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
export { isApplePlatform, useCommandShortcut, } from './command-shortcut.native.js';
|
|
1
2
|
export { DismissableLayer, } from './dismissable-layer.native.js';
|
|
2
3
|
export { computePosition, parsePlacement, } from './floating-geometry.js';
|
|
3
4
|
export { FloatingPositioner, useFloatingPosition, } from './floating-positioner.native.js';
|
|
4
5
|
export { FocusScope, initialFocusIndex, shouldRestoreFocus, } from './focus-scope.native.js';
|
|
5
6
|
export { computeSafePolygon, DelayGroupMachine, isPointInPolygon, } from './hover-geometry.js';
|
|
6
7
|
export { TooltipGroupProvider, useHoverTrigger, useTooltipGroup, } from './hover-trigger.native.js';
|
|
8
|
+
export { fromI18next, fromReactIntl, HozoI18nProvider, hozoMessages, useHozoI18n, useHozoMessage, } from './i18n.js';
|
|
7
9
|
export { LiveRegion, useAnnounce, } from './live-region.native.js';
|
|
8
10
|
export { Portal, PortalHost, PortalProvider, } from './portal.native.js';
|
|
11
|
+
export { usePresence } from './presence.native.js';
|
|
9
12
|
export { nextIndex, RovingFocusGroup, tabStops, useRovingItem, } from './roving-focus.native.js';
|
|
10
13
|
export { hozoTextChildren } from './text-child.native.js';
|
|
11
14
|
export { isTypeaheadKey, nextSearch, searchIndex, TYPEAHEAD_TIMEOUT_MS, useTypeahead, } from './typeahead.js';
|
package/dist/index.native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.native.js","sourceRoot":"","sources":["../src/index.native.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,GAEjB,MAAM,+BAAgC,CAAA;AACvC,OAAO,EAIL,eAAe,EAGf,cAAc,GAGf,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,kBAAkB,EAGlB,mBAAmB,GACpB,MAAM,iCAAkC,CAAA;AACzC,OAAO,EAEL,UAAU,EAEV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,yBAA0B,CAAA;AACjC,OAAO,EACL,kBAAkB,EAElB,iBAAiB,EACjB,gBAAgB,GAGjB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAGL,oBAAoB,EAIpB,eAAe,EACf,eAAe,GAChB,MAAM,2BAA4B,CAAA;AACnC,OAAO,EACL,UAAU,EAGV,WAAW,GACZ,MAAM,yBAA0B,CAAA;AACjC,OAAO,EACL,MAAM,EACN,UAAU,EAEV,cAAc,GACf,MAAM,oBAAqB,CAAA;AAC5B,OAAO,EACL,SAAS,EAET,gBAAgB,EAIhB,QAAQ,EACR,aAAa,GACd,MAAM,0BAA2B,CAAA;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAyB,CAAA;AAC1D,OAAO,EACL,cAAc,EACd,UAAU,EACV,WAAW,EACX,oBAAoB,EAEpB,YAAY,GACb,MAAM,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.native.js","sourceRoot":"","sources":["../src/index.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EACf,kBAAkB,GACnB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,gBAAgB,GAEjB,MAAM,+BAAgC,CAAA;AACvC,OAAO,EAIL,eAAe,EAGf,cAAc,GAGf,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,kBAAkB,EAGlB,mBAAmB,GACpB,MAAM,iCAAkC,CAAA;AACzC,OAAO,EAEL,UAAU,EAEV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,yBAA0B,CAAA;AACjC,OAAO,EACL,kBAAkB,EAElB,iBAAiB,EACjB,gBAAgB,GAGjB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAGL,oBAAoB,EAIpB,eAAe,EACf,eAAe,GAChB,MAAM,2BAA4B,CAAA;AACnC,OAAO,EACL,WAAW,EACX,aAAa,EAEb,gBAAgB,EAIhB,YAAY,EAGZ,WAAW,EACX,cAAc,GACf,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,UAAU,EAGV,WAAW,GACZ,MAAM,yBAA0B,CAAA;AACjC,OAAO,EACL,MAAM,EACN,UAAU,EAEV,cAAc,GACf,MAAM,oBAAqB,CAAA;AAC5B,OAAO,EAA4C,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAC5F,OAAO,EACL,SAAS,EAET,gBAAgB,EAIhB,QAAQ,EACR,aAAa,GACd,MAAM,0BAA2B,CAAA;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAyB,CAAA;AAC1D,OAAO,EACL,cAAc,EACd,UAAU,EACV,WAAW,EACX,oBAAoB,EAEpB,YAAY,GACb,MAAM,gBAAgB,CAAA"}
|
package/dist/native.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
export { type HozoFocusMover, type HozoFocusTarget, hasAccessibilityFocusMover, moveAccessibilityFocus, setAccessibilityFocusMover, } from './accessibility-focus.native.ts';
|
|
1
2
|
export type { Placement } from './floating-geometry.ts';
|
|
2
3
|
export { FloatingPositioner, type FloatingPositionerProps, type UseFloatingPositionOptions, useFloatingPosition, } from './floating-positioner.native.tsx';
|
|
3
4
|
export { type NativeContentProps, type NativeTriggerProps, type UseHoverTriggerOptions, type UseHoverTriggerReturn, useHoverTrigger, } from './hover-trigger.native.tsx';
|
|
5
|
+
export { fromI18next, fromReactIntl, type HozoI18n, HozoI18nProvider, type HozoI18nProviderProps, type HozoMessageKey, type HozoMessageParams, hozoMessages, type I18nextLike, type ReactIntlLike, useHozoI18n, useHozoMessage, } from './i18n.ts';
|
|
4
6
|
export { Portal, PortalHost, type PortalProps, PortalProvider } from './portal.native.tsx';
|
|
7
|
+
export { type PresenceBinding, type PresenceState, usePresence } from './presence.native.ts';
|
|
5
8
|
//# sourceMappingURL=native.d.ts.map
|
package/dist/native.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAC/B,mBAAmB,GACpB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,eAAe,GAChB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,iCAAiC,CAAA;AACxC,YAAY,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAC/B,mBAAmB,GACpB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,eAAe,GAChB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACL,WAAW,EACX,aAAa,EACb,KAAK,QAAQ,EACb,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,YAAY,EACZ,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,WAAW,EACX,cAAc,GACf,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAC1F,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA"}
|
package/dist/native.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
export { hasAccessibilityFocusMover, moveAccessibilityFocus, setAccessibilityFocusMover, } from './accessibility-focus.native.js';
|
|
1
2
|
export { FloatingPositioner, useFloatingPosition, } from './floating-positioner.native.js';
|
|
2
3
|
export { useHoverTrigger, } from './hover-trigger.native.js';
|
|
4
|
+
export { fromI18next, fromReactIntl, HozoI18nProvider, hozoMessages, useHozoI18n, useHozoMessage, } from './i18n.js';
|
|
3
5
|
export { Portal, PortalHost, PortalProvider } from './portal.native.js';
|
|
6
|
+
export { usePresence } from './presence.native.js';
|
|
4
7
|
//# sourceMappingURL=native.js.map
|
package/dist/native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.js","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"native.js","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,0BAA0B,EAC1B,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,iCAAiC,CAAA;AAExC,OAAO,EACL,kBAAkB,EAGlB,mBAAmB,GACpB,MAAM,iCAAkC,CAAA;AACzC,OAAO,EAKL,eAAe,GAChB,MAAM,2BAA4B,CAAA;AACnC,OAAO,EACL,WAAW,EACX,aAAa,EAEb,gBAAgB,EAIhB,YAAY,EAGZ,WAAW,EACX,cAAc,GACf,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAoB,cAAc,EAAE,MAAM,oBAAqB,CAAA;AAC1F,OAAO,EAA4C,WAAW,EAAE,MAAM,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type PresenceState = 'open' | 'closed';
|
|
2
|
+
export interface PresenceBinding {
|
|
3
|
+
/** Whether to render the element at all. */
|
|
4
|
+
mounted: boolean;
|
|
5
|
+
/** For the element's `data-state`. */
|
|
6
|
+
state: PresenceState;
|
|
7
|
+
/** The element whose transition is the exit. */
|
|
8
|
+
ref: (node: Element | null) => void;
|
|
9
|
+
onTransitionEnd: (event: {
|
|
10
|
+
target: EventTarget;
|
|
11
|
+
currentTarget: EventTarget;
|
|
12
|
+
}) => void;
|
|
13
|
+
onAnimationEnd: (event: {
|
|
14
|
+
target: EventTarget;
|
|
15
|
+
currentTarget: EventTarget;
|
|
16
|
+
}) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare function usePresence(show: boolean): PresenceBinding;
|
|
19
|
+
//# sourceMappingURL=presence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../src/presence.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,CAAA;AAE7C,MAAM,WAAW,eAAe;IAC9B,4CAA4C;IAC5C,OAAO,EAAE,OAAO,CAAA;IAChB,sCAAsC;IACtC,KAAK,EAAE,aAAa,CAAA;IACpB,gDAAgD;IAChD,GAAG,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAA;IACnC,eAAe,EAAE,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,WAAW,CAAC;QAAC,aAAa,EAAE,WAAW,CAAA;KAAE,KAAK,IAAI,CAAA;IACrF,cAAc,EAAE,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,WAAW,CAAC;QAAC,aAAa,EAAE,WAAW,CAAA;KAAE,KAAK,IAAI,CAAA;CACrF;AAgCD,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,CAyD1D"}
|
package/dist/presence.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Keeping an element mounted while it animates out, on the Web
|
|
2
|
+
// (decision 007, slice 2).
|
|
3
|
+
//
|
|
4
|
+
// React removes an element the moment it stops being rendered, so nothing
|
|
5
|
+
// can animate after that. This holds on to it after `show` turns false,
|
|
6
|
+
// reports `state: 'closed'` for the caller to put on the element as
|
|
7
|
+
// `data-state`, and lets it go when the element's transition or animation
|
|
8
|
+
// ends. The exit itself is CSS -- a `data-[state=closed]:` class and a
|
|
9
|
+
// `transition-*` one -- so it costs no script beyond this.
|
|
10
|
+
//
|
|
11
|
+
// A hook rather than only a component because Hozo's overlays cannot wrap
|
|
12
|
+
// their panel in one: the panel sits inside a positioner, a dismiss layer
|
|
13
|
+
// and a focus scope, and it is the panel that leaves. `Presence` in
|
|
14
|
+
// `@hozo/primitives` is this hook around one child.
|
|
15
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
16
|
+
/** How long past the computed end to wait for an event that never fires. */
|
|
17
|
+
const GRACE_MS = 100;
|
|
18
|
+
/** The longest `duration + delay` across a comma-separated pair of lists. */
|
|
19
|
+
function longest(durations, delays) {
|
|
20
|
+
const ms = (value) => {
|
|
21
|
+
const number = Number.parseFloat(value);
|
|
22
|
+
if (Number.isNaN(number))
|
|
23
|
+
return 0;
|
|
24
|
+
return value.trim().endsWith('ms') ? number : number * 1000;
|
|
25
|
+
};
|
|
26
|
+
const d = durations.split(',');
|
|
27
|
+
const l = delays.split(',');
|
|
28
|
+
// CSS repeats the shorter list to the length of the longer one.
|
|
29
|
+
const length = Math.max(d.length, l.length);
|
|
30
|
+
let out = 0;
|
|
31
|
+
for (let i = 0; i < length; i++) {
|
|
32
|
+
out = Math.max(out, ms(d[i % d.length] ?? '0s') + ms(l[i % l.length] ?? '0s'));
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
/** How long the element's exit runs, from its computed style. */
|
|
37
|
+
function exitDuration(element) {
|
|
38
|
+
const style = getComputedStyle(element);
|
|
39
|
+
return Math.max(longest(style.transitionDuration, style.transitionDelay), style.animationName === 'none' ? 0 : longest(style.animationDuration, style.animationDelay));
|
|
40
|
+
}
|
|
41
|
+
export function usePresence(show) {
|
|
42
|
+
const [mounted, setMounted] = useState(show);
|
|
43
|
+
// Set during render rather than in an effect, so an element that is shown
|
|
44
|
+
// again appears in the same commit instead of one frame late.
|
|
45
|
+
if (show && !mounted)
|
|
46
|
+
setMounted(true);
|
|
47
|
+
const element = useRef(null);
|
|
48
|
+
const ending = useRef(null);
|
|
49
|
+
const finish = useCallback(() => {
|
|
50
|
+
if (ending.current)
|
|
51
|
+
clearTimeout(ending.current.timer);
|
|
52
|
+
ending.current = null;
|
|
53
|
+
setMounted(false);
|
|
54
|
+
}, []);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (show || !mounted)
|
|
57
|
+
return;
|
|
58
|
+
// Read after the commit that set `data-state="closed"`, so the
|
|
59
|
+
// computed style is the one the element is leaving with -- including
|
|
60
|
+
// `motion-reduce:transition-none`, which makes this zero.
|
|
61
|
+
const target = element.current;
|
|
62
|
+
const duration = target ? exitDuration(target) : 0;
|
|
63
|
+
if (duration === 0) {
|
|
64
|
+
finish();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const at = performance.now() + duration;
|
|
68
|
+
ending.current = { at, timer: setTimeout(finish, duration + GRACE_MS) };
|
|
69
|
+
return () => {
|
|
70
|
+
if (ending.current)
|
|
71
|
+
clearTimeout(ending.current.timer);
|
|
72
|
+
ending.current = null;
|
|
73
|
+
};
|
|
74
|
+
}, [show, mounted, finish]);
|
|
75
|
+
// `transitionend` fires once per property, and the properties may end
|
|
76
|
+
// at different times. Only the one that ends last finishes the exit.
|
|
77
|
+
const onEnd = useCallback((event) => {
|
|
78
|
+
if (event.target !== event.currentTarget)
|
|
79
|
+
return;
|
|
80
|
+
const pending = ending.current;
|
|
81
|
+
if (!pending || performance.now() < pending.at - 20)
|
|
82
|
+
return;
|
|
83
|
+
finish();
|
|
84
|
+
}, [finish]);
|
|
85
|
+
const ref = useCallback((node) => {
|
|
86
|
+
element.current = node;
|
|
87
|
+
}, []);
|
|
88
|
+
return {
|
|
89
|
+
mounted,
|
|
90
|
+
state: show ? 'open' : 'closed',
|
|
91
|
+
ref,
|
|
92
|
+
onTransitionEnd: onEnd,
|
|
93
|
+
onAnimationEnd: onEnd,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=presence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presence.js","sourceRoot":"","sources":["../src/presence.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,2BAA2B;AAC3B,EAAE;AACF,0EAA0E;AAC1E,wEAAwE;AACxE,oEAAoE;AACpE,0EAA0E;AAC1E,uEAAuE;AACvE,2DAA2D;AAC3D,EAAE;AACF,0EAA0E;AAC1E,0EAA0E;AAC1E,oEAAoE;AACpE,oDAAoD;AAEpD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAehE,4EAA4E;AAC5E,MAAM,QAAQ,GAAG,GAAG,CAAA;AAEpB,6EAA6E;AAC7E,SAAS,OAAO,CAAC,SAAiB,EAAE,MAAc;IAChD,MAAM,EAAE,GAAG,CAAC,KAAa,EAAE,EAAE;QAC3B,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;QACvC,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;YAAE,OAAO,CAAC,CAAA;QAClC,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,IAAI,CAAA;IAC7D,CAAC,CAAA;IACD,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC9B,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,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OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAC9B,IAAI,CAAC,OAAO,IAAI,WAAW,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,EAAE,GAAG,EAAE;YAAE,OAAM;QAC3D,MAAM,EAAE,CAAA;IACV,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAA;IAED,MAAM,GAAG,GAAG,WAAW,CAAC,CAAC,IAAoB,EAAE,EAAE;QAC/C,OAAO,CAAC,OAAO,GAAG,IAAI,CAAA;IACxB,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO;QACL,OAAO;QACP,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ;QAC/B,GAAG;QACH,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,KAAK;KACtB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type PresenceState = 'open' | 'closed';
|
|
2
|
+
export interface PresenceBinding {
|
|
3
|
+
/** Whether to render the element at all. */
|
|
4
|
+
mounted: boolean;
|
|
5
|
+
state: PresenceState;
|
|
6
|
+
/** Ends the exit. Ignored once the element is shown again. */
|
|
7
|
+
done: () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare function usePresence(show: boolean): PresenceBinding;
|
|
10
|
+
//# sourceMappingURL=presence.native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presence.native.d.ts","sourceRoot":"","sources":["../src/presence.native.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,CAAA;AAE7C,MAAM,WAAW,eAAe;IAC9B,4CAA4C;IAC5C,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,aAAa,CAAA;IACpB,8DAA8D;IAC9D,IAAI,EAAE,MAAM,IAAI,CAAA;CACjB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,CAO1D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Keeping an element mounted while it animates out, on React Native
|
|
2
|
+
// (decision 007, slice 2). The Web half is `./presence.ts`.
|
|
3
|
+
//
|
|
4
|
+
// There is no computed style to read an exit's length from here, so the
|
|
5
|
+
// caller says when it is over: it runs its own `Animated` exit while
|
|
6
|
+
// `state` is `'closed'` and calls `done` from the completion callback.
|
|
7
|
+
import { useCallback, useState } from 'react';
|
|
8
|
+
export function usePresence(show) {
|
|
9
|
+
const [mounted, setMounted] = useState(show);
|
|
10
|
+
if (show && !mounted)
|
|
11
|
+
setMounted(true);
|
|
12
|
+
const done = useCallback(() => {
|
|
13
|
+
if (!show)
|
|
14
|
+
setMounted(false);
|
|
15
|
+
}, [show]);
|
|
16
|
+
return { mounted, state: show ? 'open' : 'closed', done };
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=presence.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presence.native.js","sourceRoot":"","sources":["../src/presence.native.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,4DAA4D;AAC5D,EAAE;AACF,wEAAwE;AACxE,qEAAqE;AACrE,uEAAuE;AAEvE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAY7C,MAAM,UAAU,WAAW,CAAC,IAAa;IACvC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC5C,IAAI,IAAI,IAAI,CAAC,OAAO;QAAE,UAAU,CAAC,IAAI,CAAC,CAAA;IACtC,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE;QAC5B,IAAI,CAAC,IAAI;YAAE,UAAU,CAAC,KAAK,CAAC,CAAA;IAC9B,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IACV,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAA;AAC3D,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface HozoPressableInteractionState {
|
|
2
|
+
pressed: boolean;
|
|
3
|
+
hovered: boolean;
|
|
4
|
+
focused: boolean;
|
|
5
|
+
focusVisible: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The Native pressable's event-driven facts, shared with patterns (#897).
|
|
9
|
+
* No subscriptions, animation nodes or global modality listeners. Hosts own
|
|
10
|
+
* event delivery and compose their caller's handlers after these callbacks.
|
|
11
|
+
* onChange runs synchronously for the existing native animation driver;
|
|
12
|
+
* React state drives the ordinary style/children callbacks.
|
|
13
|
+
*/
|
|
14
|
+
export declare function usePressableInteraction({ focusVisible, onChange, }?: {
|
|
15
|
+
focusVisible?: boolean;
|
|
16
|
+
onChange?: (state: HozoPressableInteractionState) => void;
|
|
17
|
+
}): {
|
|
18
|
+
state: HozoPressableInteractionState;
|
|
19
|
+
handlers: {
|
|
20
|
+
hoverIn: () => void;
|
|
21
|
+
hoverOut: () => void;
|
|
22
|
+
focus: () => void;
|
|
23
|
+
blur: () => void;
|
|
24
|
+
pointerDown: () => void;
|
|
25
|
+
keyDown: () => void;
|
|
26
|
+
pressIn: () => void;
|
|
27
|
+
pressOut: () => void;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=pressable-interaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pressable-interaction.d.ts","sourceRoot":"","sources":["../src/pressable-interaction.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,OAAO,CAAA;CACtB;AAaD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,YAAoB,EACpB,QAAQ,GACT,GAAE;IACD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,6BAA6B,KAAK,IAAI,CAAA;CACrD;;;;;;;;;;;;EA6CL"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
2
|
+
const HOVERED = 1;
|
|
3
|
+
const FOCUSED = 2;
|
|
4
|
+
const PRESSED = 4;
|
|
5
|
+
const FOCUS_VISIBLE = 8;
|
|
6
|
+
const read = (mask) => ({
|
|
7
|
+
pressed: (mask & PRESSED) !== 0,
|
|
8
|
+
hovered: (mask & HOVERED) !== 0,
|
|
9
|
+
focused: (mask & FOCUSED) !== 0,
|
|
10
|
+
focusVisible: (mask & FOCUS_VISIBLE) !== 0,
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* The Native pressable's event-driven facts, shared with patterns (#897).
|
|
14
|
+
* No subscriptions, animation nodes or global modality listeners. Hosts own
|
|
15
|
+
* event delivery and compose their caller's handlers after these callbacks.
|
|
16
|
+
* onChange runs synchronously for the existing native animation driver;
|
|
17
|
+
* React state drives the ordinary style/children callbacks.
|
|
18
|
+
*/
|
|
19
|
+
export function usePressableInteraction({ focusVisible = false, onChange, } = {}) {
|
|
20
|
+
const [mask, setMask] = useState(0);
|
|
21
|
+
const live = useRef(0);
|
|
22
|
+
// Matches the primitive's existing policy: initial focus is keyboard-like;
|
|
23
|
+
// a pointer/press clears it, and a key makes a currently focused host visible.
|
|
24
|
+
const modality = useRef('keyboard');
|
|
25
|
+
const set = useCallback((flag, active) => {
|
|
26
|
+
const next = active ? live.current | flag : live.current & ~flag;
|
|
27
|
+
live.current = next;
|
|
28
|
+
onChange?.(read(next));
|
|
29
|
+
setMask(next);
|
|
30
|
+
}, [onChange]);
|
|
31
|
+
const handlers = useMemo(() => ({
|
|
32
|
+
hoverIn: () => set(HOVERED, true),
|
|
33
|
+
hoverOut: () => set(HOVERED, false),
|
|
34
|
+
focus: () => {
|
|
35
|
+
set(FOCUSED, true);
|
|
36
|
+
if (focusVisible)
|
|
37
|
+
set(FOCUS_VISIBLE, modality.current === 'keyboard');
|
|
38
|
+
},
|
|
39
|
+
blur: () => {
|
|
40
|
+
set(FOCUSED, false);
|
|
41
|
+
if (focusVisible)
|
|
42
|
+
set(FOCUS_VISIBLE, false);
|
|
43
|
+
},
|
|
44
|
+
pointerDown: () => {
|
|
45
|
+
modality.current = 'pointer';
|
|
46
|
+
if (focusVisible)
|
|
47
|
+
set(FOCUS_VISIBLE, false);
|
|
48
|
+
},
|
|
49
|
+
keyDown: () => {
|
|
50
|
+
modality.current = 'keyboard';
|
|
51
|
+
if (focusVisible && (live.current & FOCUSED) !== 0)
|
|
52
|
+
set(FOCUS_VISIBLE, true);
|
|
53
|
+
},
|
|
54
|
+
pressIn: () => {
|
|
55
|
+
modality.current = 'pointer';
|
|
56
|
+
if (focusVisible)
|
|
57
|
+
set(FOCUS_VISIBLE, false);
|
|
58
|
+
set(PRESSED, true);
|
|
59
|
+
},
|
|
60
|
+
pressOut: () => set(PRESSED, false),
|
|
61
|
+
}), [focusVisible, set]);
|
|
62
|
+
return { state: useMemo(() => read(mask), [mask]), handlers };
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=pressable-interaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pressable-interaction.js","sourceRoot":"","sources":["../src/pressable-interaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAS9D,MAAM,OAAO,GAAG,CAAC,CAAA;AACjB,MAAM,OAAO,GAAG,CAAC,CAAA;AACjB,MAAM,OAAO,GAAG,CAAC,CAAA;AACjB,MAAM,aAAa,GAAG,CAAC,CAAA;AACvB,MAAM,IAAI,GAAG,CAAC,IAAY,EAAiC,EAAE,CAAC,CAAC;IAC7D,OAAO,EAAE,C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": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Hozo's accessibility and internationalisation behaviours (FocusScope, RovingFocus, LiveRegion, Portal, DismissableLayer, FloatingPositioner), shared by Web and React Native.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
7
7
|
"behaviors",
|
|
@@ -40,9 +40,14 @@
|
|
|
40
40
|
"types": "./dist/native.d.ts",
|
|
41
41
|
"default": "./dist/native.js"
|
|
42
42
|
},
|
|
43
|
+
"./pressable-interaction": {
|
|
44
|
+
"types": "./dist/pressable-interaction.d.ts",
|
|
45
|
+
"default": "./dist/pressable-interaction.js"
|
|
46
|
+
},
|
|
43
47
|
"./package.json": "./package.json"
|
|
44
48
|
},
|
|
45
49
|
"files": [
|
|
50
|
+
"CHANGELOG.md",
|
|
46
51
|
"dist",
|
|
47
52
|
"src",
|
|
48
53
|
"!src/**/*.test.ts",
|