@hozo/engine 0.2.0 → 0.4.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 +55 -0
- package/README.md +39 -1
- package/dist/authored-gap.d.ts +11 -0
- package/dist/authored-gap.d.ts.map +1 -0
- package/dist/authored-gap.js +45 -0
- package/dist/authored-gap.js.map +1 -0
- package/dist/class-resolver.d.ts +66 -5
- package/dist/class-resolver.d.ts.map +1 -1
- package/dist/class-resolver.js +203 -29
- package/dist/class-resolver.js.map +1 -1
- package/dist/class-transition.d.ts +32 -0
- package/dist/class-transition.d.ts.map +1 -0
- package/dist/class-transition.js +48 -0
- package/dist/class-transition.js.map +1 -0
- package/dist/color-transition.d.ts +2 -0
- package/dist/color-transition.d.ts.map +1 -1
- package/dist/color-transition.js +10 -0
- package/dist/color-transition.js.map +1 -1
- package/dist/cx.d.ts +4 -0
- package/dist/cx.d.ts.map +1 -0
- package/dist/cx.js +17 -0
- package/dist/cx.js.map +1 -0
- package/dist/dom-style.d.ts +1 -0
- package/dist/dom-style.d.ts.map +1 -1
- package/dist/dom-style.js +4 -0
- package/dist/dom-style.js.map +1 -1
- package/dist/gap-styles.d.ts +3 -0
- package/dist/gap-styles.d.ts.map +1 -0
- package/dist/gap-styles.js +7 -0
- package/dist/gap-styles.js.map +1 -0
- package/dist/generated/animated.d.ts +3 -0
- package/dist/generated/animated.d.ts.map +1 -0
- package/dist/generated/animated.js +7 -0
- package/dist/generated/animated.js.map +1 -0
- package/dist/generated/class-resolver.d.ts +1 -1
- package/dist/generated/class-resolver.d.ts.map +1 -1
- package/dist/generated/class-resolver.js +1 -1
- package/dist/generated/class-resolver.js.map +1 -1
- package/dist/generated/gap-styles.d.ts +3 -0
- package/dist/generated/gap-styles.d.ts.map +1 -0
- package/dist/generated/gap-styles.js +4 -0
- package/dist/generated/gap-styles.js.map +1 -0
- package/dist/generated/safe-area.d.ts +1 -1
- package/dist/generated/safe-area.d.ts.map +1 -1
- package/dist/generated/safe-area.js +1 -1
- package/dist/generated/safe-area.js.map +1 -1
- package/dist/generated/spread-styles.d.ts +2 -0
- package/dist/generated/spread-styles.d.ts.map +1 -0
- package/dist/generated/spread-styles.js +3 -0
- package/dist/generated/spread-styles.js.map +1 -0
- package/dist/generated/text-inheritance-protocol.d.ts +3 -0
- package/dist/generated/text-inheritance-protocol.d.ts.map +1 -0
- package/dist/generated/text-inheritance-protocol.js +3 -0
- package/dist/generated/text-inheritance-protocol.js.map +1 -0
- package/dist/generated/text-size-context.d.ts +2 -0
- package/dist/generated/text-size-context.d.ts.map +1 -0
- package/dist/generated/text-size-context.js +3 -0
- package/dist/generated/text-size-context.js.map +1 -0
- package/dist/generated/transform-slots.d.ts +2 -0
- package/dist/generated/transform-slots.d.ts.map +1 -0
- package/dist/generated/transform-slots.js +4 -0
- package/dist/generated/transform-slots.js.map +1 -0
- package/dist/hooks.native.js +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/interactive.d.ts +2 -0
- package/dist/interactive.d.ts.map +1 -1
- package/dist/interactive.js +4 -0
- package/dist/interactive.js.map +1 -1
- package/dist/presence-context.d.ts +15 -0
- package/dist/presence-context.d.ts.map +1 -0
- package/dist/presence-context.js +11 -0
- package/dist/presence-context.js.map +1 -0
- package/dist/project.d.ts +16 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +16 -0
- package/dist/project.js.map +1 -1
- package/dist/project.native.d.ts +1 -1
- package/dist/project.native.d.ts.map +1 -1
- package/dist/project.native.js +1 -1
- package/dist/project.native.js.map +1 -1
- package/dist/responder.d.ts +34 -0
- package/dist/responder.d.ts.map +1 -1
- package/dist/responder.js +52 -0
- package/dist/responder.js.map +1 -1
- package/dist/runtime-transition.native.d.ts +37 -0
- package/dist/runtime-transition.native.d.ts.map +1 -0
- package/dist/runtime-transition.native.js +252 -0
- package/dist/runtime-transition.native.js.map +1 -0
- package/dist/safe-area.native.d.ts +12 -0
- package/dist/safe-area.native.d.ts.map +1 -1
- package/dist/safe-area.native.js +44 -21
- package/dist/safe-area.native.js.map +1 -1
- package/dist/spread-styles.d.ts +14 -0
- package/dist/spread-styles.d.ts.map +1 -0
- package/dist/spread-styles.js +56 -0
- package/dist/spread-styles.js.map +1 -0
- package/dist/text-inheritance.d.ts +35 -0
- package/dist/text-inheritance.d.ts.map +1 -0
- package/dist/text-inheritance.js +48 -0
- package/dist/text-inheritance.js.map +1 -0
- package/dist/text-style.d.ts +8 -0
- package/dist/text-style.d.ts.map +1 -0
- package/dist/text-style.js +34 -0
- package/dist/text-style.js.map +1 -0
- package/dist/transform-slots.d.ts +22 -0
- package/dist/transform-slots.d.ts.map +1 -0
- package/dist/transform-slots.js +108 -0
- package/dist/transform-slots.js.map +1 -0
- package/dist/view-base-css.d.ts +2 -0
- package/dist/view-base-css.d.ts.map +1 -0
- package/dist/view-base-css.js +20 -0
- package/dist/view-base-css.js.map +1 -0
- package/dist/view-base.d.ts +6 -0
- package/dist/view-base.d.ts.map +1 -0
- package/dist/view-base.js +15 -0
- package/dist/view-base.js.map +1 -0
- package/package.json +26 -2
- package/src/authored-gap.ts +41 -0
- package/src/class-resolver.ts +297 -24
- package/src/class-transition.ts +71 -0
- package/src/color-transition.ts +11 -0
- package/src/cx.ts +18 -0
- package/src/dom-style.ts +3 -0
- package/src/gap-styles.ts +11 -0
- package/src/generated/animated.ts +15 -0
- package/src/generated/class-resolver.ts +7 -1
- package/src/generated/gap-styles.ts +3 -0
- package/src/generated/safe-area.ts +5 -1
- package/src/generated/spread-styles.ts +2 -0
- package/src/generated/text-inheritance-protocol.ts +9 -0
- package/src/generated/text-size-context.ts +2 -0
- package/src/generated/transform-slots.ts +3 -0
- package/src/hooks.native.ts +1 -1
- package/src/index.ts +18 -3
- package/src/interactive.ts +4 -0
- package/src/presence-context.ts +27 -0
- package/src/project.native.ts +1 -1
- package/src/project.ts +20 -0
- package/src/responder.ts +52 -0
- package/src/runtime-transition.native.tsx +324 -0
- package/src/safe-area.native.ts +59 -24
- package/src/spread-styles.ts +74 -0
- package/src/text-inheritance.ts +75 -0
- package/src/text-style.ts +35 -0
- package/src/transform-slots.ts +119 -0
- package/src/view-base-css.ts +19 -0
- package/src/view-base.ts +20 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
# @hozo/engine
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1462](https://github.com/iray-tno/hozo/pull/1462) [`add3e7b`](https://github.com/iray-tno/hozo/commit/add3e7b2c5a152c770eabee7d09d723e925958e1) Thanks [@iray-tno](https://github.com/iray-tno)! - `HozoAnimated` and `PresenceContext` move from `@hozo/primitives` to `@hozo/engine` (`@hozo/engine/generated/animated`), so `@hozo/patterns` can run them. `@hozo/primitives/generated/animated` is gone; compiled output imports them through `@hozo/core/generated/animated` as before.
|
|
8
|
+
|
|
9
|
+
- [#1597](https://github.com/iray-tno/hozo/pull/1597) [`b3df5b7`](https://github.com/iray-tno/hozo/commit/b3df5b73a8ec104fe407d89472e4339411de311d) Thanks [@iray-tno](https://github.com/iray-tno)! - React Native 0.87 is now the lowest supported version (`react-native: >=0.87`), and `@hozo/media`'s Expo peers move to SDK 58 (`expo-video`, `expo-audio` and `expo-asset` `>=58 <59`). Native gradients go under `backgroundImage` again: the `experimental_backgroundImage` spelling existed only for React Native 0.86, which read nothing else.
|
|
10
|
+
|
|
11
|
+
- [#1462](https://github.com/iray-tno/hozo/pull/1462) [`c9a3b4d`](https://github.com/iray-tno/hozo/commit/c9a3b4d61541024c66165c91a4b7e2a75c9a203c) Thanks [@iray-tno](https://github.com/iray-tno)! - The Native candidate module now emits a `hozoClassTransitions` table for transition utilities (`transition-*`, `duration-*`, `delay-*`, `ease-*`, also under `motion-reduce:` / `motion-safe:`) instead of reporting them as Web-only, and `@hozo/engine` adds `createClassTransitions` to read a runtime class string into a `HozoAnimated` transition spec.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#1473](https://github.com/iray-tno/hozo/pull/1473) [`fac2f53`](https://github.com/iray-tno/hozo/commit/fac2f53a7636c7373cf22c4d49fcf5a137bb08ec) Thanks [@iray-tno](https://github.com/iray-tno)! - An interrupted `HozoAnimated` transition now starts from where its numbers had got to (opacity, and the position and size keys its spec names), rather than jumping to the previous target first. A panel closed halfway through opening shrinks from its current height.
|
|
16
|
+
|
|
17
|
+
- [#1348](https://github.com/iray-tno/hozo/pull/1348) [`b59995e`](https://github.com/iray-tno/hozo/commit/b59995e108e4cc9b6d093c2487cebece0d02a707) Thanks [@iray-tno](https://github.com/iray-tno)! - The Native `Menu` sheet clears the home indicator and the Android gesture handle: it adds the bottom inset an app's `<SafeAreaProvider>` reports below its own padding, and nothing in an app without one. `@hozo/engine` gains `useHozoProvidedSafeArea()` for that, which reads zeros instead of throwing when the provider or `react-native-safe-area-context` is missing, and the missing-package warning for a safe-area class now fires when such a class first renders rather than whenever the Native entry loads.
|
|
18
|
+
|
|
19
|
+
- [#1056](https://github.com/iray-tno/hozo/pull/1056) [`c1ca21a`](https://github.com/iray-tno/hozo/commit/c1ca21afee0e3f4dd92110570f3ff3775b01c4cf) Thanks [@iray-tno](https://github.com/iray-tno)! - On Native, a `style` a caller passes through a component's `{...rest}` no longer replaces the styles compiled from its classes: the two compose, classes first and the caller's style after, as the owner itself composes them. Elements whose spreads cannot carry `style` compile as before.
|
|
20
|
+
|
|
21
|
+
- [#1155](https://github.com/iray-tno/hozo/pull/1155) [`416d627`](https://github.com/iray-tno/hozo/commit/416d627e8afc6a3f321c95dbe1f74b630d173d7b) Thanks [@iray-tno](https://github.com/iray-tno)! - On the Web, a spread onto a compiled `View`, `Text` or `Image` keeps the props that need the element.
|
|
22
|
+
|
|
23
|
+
- **`onLayout`** is called on mount and when the layout changes, as it is uncompiled. It is not called again on a re-render.
|
|
24
|
+
- **The responder props** (`onStartShouldSetResponder`, `onResponderGrant`, `onResponderMove`, …) claim and release the pointer on a `View`.
|
|
25
|
+
- **An `Image` whose `src` fails to load falls back to `defaultSource`.**
|
|
26
|
+
|
|
27
|
+
Before this, these reached the DOM raw and did nothing. The spread's translation now adds a callback ref when the spread carries one of them. `@hozo/engine` exports `createSpreadResponder` for it: the responder without a hook.
|
|
28
|
+
|
|
29
|
+
## 0.3.0
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Interrupted colour transitions read the RGBA string produced by their previous
|
|
34
|
+
blend, preserving the intermediate colour when a new transition starts.
|
|
35
|
+
|
|
36
|
+
### Minor Changes
|
|
37
|
+
|
|
38
|
+
- [#923](https://github.com/iray-tno/hozo/pull/923) [`8d58223`](https://github.com/iray-tno/hozo/commit/8d5822322607b6214fa7f57d233a9173a45815b6) Thanks [@iray-tno](https://github.com/iray-tno)! - Resolve Native pattern class-name slots through the project's runtime class resolver. Pattern controls now share the primitive interaction engine and deliver hover, focus, focus-visible and pressed facts to their actual owners instead of reporting pressed alone.
|
|
39
|
+
|
|
40
|
+
Static interaction styles are additionally wired for Chip, ColorPicker swatches, Pagination page controls and CommandPalette pointer-state item slots. Selection slots and nested controls retain their own ownership: a remove button does not inherit its row's focus, and a command item does not borrow the input's focus. Other static state slots and semantic predicates remain subject to their existing diagnostics.
|
|
41
|
+
|
|
42
|
+
Styled Button receives a pressed look; Checkbox and Switch indicators are real elements on both platforms rather than Native-invisible pseudo-elements. Non-transition Native Pressables and their Text children no longer allocate animation values/listeners. Interaction ownership remains mounted when transitions are added or removed. This removes idle animation work, not every initial-mount cost or every platform delivery difference; measured list mount/update tradeoffs remain tracked separately.
|
|
43
|
+
|
|
44
|
+
- [#923](https://github.com/iray-tno/hozo/pull/923) [`8d58223`](https://github.com/iray-tno/hozo/commit/8d5822322607b6214fa7f57d233a9173a45815b6) Thanks [@iray-tno](https://github.com/iray-tno)! - Compile project-defined Tailwind animations and their keyframes for both backends, including keyframes needed by dynamic class candidates. StyleX conditions inside property values now reach the shared condition model.
|
|
45
|
+
|
|
46
|
+
Extend Native negated conditions across supported environment, breakpoint, pixel-width, container, prop, sibling and interaction predicates. Link states use the existing interaction owner, descendant focus-visible follows that owner, and independent transform resets and runtime-state transform families compose without losing their other transform entries. Unsupported predicates are still diagnosed, not assumed false.
|
|
47
|
+
|
|
48
|
+
Respect project radius tokens and built-in radius overrides, discover runtime candidates in quoted class arrays, and preserve separate Native style keys for ternary branches. Caller classes override a component's resting look while explicit state classes retain their precedence. On Web, fallback candidate rules stay below authored Tailwind utilities, and conditional class selection reaches elements that remain components.
|
|
49
|
+
|
|
50
|
+
Native line-breaking utilities that cannot be represented now warn instead of failing the build. This does not implement Android/CJK line-break controls that React Native does not expose.
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- [#923](https://github.com/iray-tno/hozo/pull/923) [`8d58223`](https://github.com/iray-tno/hozo/commit/8d5822322607b6214fa7f57d233a9173a45815b6) Thanks [@iray-tno](https://github.com/iray-tno)! - Uncompiled View, Text and Image forward refs to their platform hosts. Container measurement preserves the host instead of replacing it, and Web View layout defaults agree between compiled output and fallback components.
|
|
55
|
+
|
|
56
|
+
An uncompiled Svg now uses its accessibility label as its name, as the compiled path already did. Web controls, including generated Canvas controls and form/pattern actions, show the shared clickable cursor without giving disabled controls an active pointer.
|
|
57
|
+
|
|
3
58
|
## 0.2.0
|
|
4
59
|
|
|
5
60
|
- Add the Native `useHozoKeyframes` hook and generated animation ABI for the supported project-keyframe subset.
|
package/README.md
CHANGED
|
@@ -13,6 +13,44 @@ platform adapter, because Hozo does not add a native module to every application
|
|
|
13
13
|
|
|
14
14
|
**Contextual variants.** `dark:`, `sm:`/`md:`/`lg:`, and viewport-relative sizes are media queries on Web and subscriptions on Native. `useHozoDark`, `useHozoBreakpoint` and `useHozoViewport` are separate stores on purpose: a component using only `md:` must not re-render on every resize that does not cross a breakpoint.
|
|
15
15
|
|
|
16
|
+
**Native transform controls.** `rotate-none`, `scale-none`, `translate-none`, and
|
|
17
|
+
`transform-none` reset their own CSS transform property, not every transform.
|
|
18
|
+
For example, `rotate-45 scale-95 md:rotate-none` keeps its scale when the rotation
|
|
19
|
+
is reset. `transform`/`transform-cpu` restore the function-slot chain; they do not
|
|
20
|
+
switch Native rendering to a CPU backend. Unconditional controls compile into
|
|
21
|
+
plain StyleSheet values. Conditional controls and dynamic class strings use one
|
|
22
|
+
small slot composer, without extra state or subscriptions; dynamic results stay
|
|
23
|
+
cached by class string. `transform-gpu` still reports a diagnostic because a
|
|
24
|
+
browser compositing hint cannot force a Native hardware layer. Transform controls
|
|
25
|
+
combined with `starting:`/exit animation frames, or used as independent
|
|
26
|
+
`@keyframes` controls, remain explicitly unwired. Use explicit transform values
|
|
27
|
+
for those animation endpoints.
|
|
28
|
+
|
|
29
|
+
**Native negated variants.** `not-disabled:`, `not-enabled:`, `not-aria-*:`,
|
|
30
|
+
negated known sibling predicates such as `not-first:`/`not-last:`, and negated
|
|
31
|
+
supported environment queries such as `not-motion-reduce:` reuse the positive
|
|
32
|
+
predicate, including when stacked with other supported conditions. Prop predicates
|
|
33
|
+
need the same readable driver as their positive form; `not-disabled:` without a
|
|
34
|
+
readable disabled fact or an unreadable ARIA state is still a diagnostic, not a false value
|
|
35
|
+
to invert. `not-enabled:` follows the existing `enabled:` contract: without a
|
|
36
|
+
`disabled` prop, enabled is known true and its negation does not apply. Unknown
|
|
37
|
+
sibling positions and unsupported environment queries remain diagnostics too.
|
|
38
|
+
Boolean ARIA predicates match the literal `true` state; an optional state object
|
|
39
|
+
can be absent at runtime, and `checked: 'mixed'` is not treated as checked=true.
|
|
40
|
+
Known sibling predicates cost no runtime state; environment queries share their
|
|
41
|
+
existing hook. `not-focus:` and `not-focus-visible:` on Pressable/Button reuse
|
|
42
|
+
their existing interaction callback, including stacked conditions and transitions;
|
|
43
|
+
negated focus-visible alone enables the same pointer/keyboard modality inference
|
|
44
|
+
as its positive form. Text in that interaction context uses the owner's state,
|
|
45
|
+
not an independent text focus target, just as positive focus variants do. No new
|
|
46
|
+
store or subscription is added. Other elements without a readable focus driver
|
|
47
|
+
remain diagnostics. Dynamic class maps also carry negated ARIA predicates as
|
|
48
|
+
compiler-owned `!aria-…` keys, prepared once by the resolver from the underlying
|
|
49
|
+
owner facts. Missing facts remain unassessed, including under negation; no new
|
|
50
|
+
owner-state fields or subscriptions are needed. Both ordinary and ordered maps
|
|
51
|
+
use this same matcher. Non-ARIA dynamic selector negations such as `not-hover:`
|
|
52
|
+
remain unwired; their static lowering is a separate capability.
|
|
53
|
+
|
|
16
54
|
**Interaction state infrastructure.** The canonical `HozoPressable` in `@hozo/primitives` tracks
|
|
17
55
|
pressed, hovered, focused and focus-visible state using the shared helpers owned here. Focus-visible
|
|
18
56
|
follows the input modality, so a tap does not draw a focus ring and a Tab key does.
|
|
@@ -73,6 +111,6 @@ rendering boundaries and their layout solvers are owned by `@hozo/primitives`.
|
|
|
73
111
|
|
|
74
112
|
---
|
|
75
113
|
|
|
76
|
-
Part of [Hozo](https://iray-tno.github.io/hozo/), a
|
|
114
|
+
Part of [Hozo](https://iray-tno.github.io/hozo/), a universal UI framework for React Native, compiled by Rust, with native semantics on every platform, first-class accessibility, and diagnostics for humans and AI agents alike. Most applications install [`@hozo/core`](https://www.npmjs.com/package/@hozo/core) and one build integration; see [Getting started](https://iray-tno.github.io/hozo/docs/getting-started/). Source and issues: [github.com/iray-tno/hozo](https://github.com/iray-tno/hozo).
|
|
77
115
|
|
|
78
116
|
<!-- /generated: package-footer -->
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project a flattened author's StyleProp, not a mixture with compiled styles.
|
|
3
|
+
* Yoga prefers an axis gutter to `gap` regardless of object key/array order.
|
|
4
|
+
* CSS needs the effective longhands instead, or a later shorthand erases the
|
|
5
|
+
* axis. The caller owns this flat object; authored objects are never mutated.
|
|
6
|
+
* Keep CSS-only strings untouched rather than pretending RN accepts them.
|
|
7
|
+
*/
|
|
8
|
+
export declare function projectAuthoredGap(style: Record<string, unknown>): void;
|
|
9
|
+
/** Generated Native code calls this before mixing an author with class axes. */
|
|
10
|
+
export declare function hozoAuthoredStyle<T>(input: T): T;
|
|
11
|
+
//# sourceMappingURL=authored-gap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authored-gap.d.ts","sourceRoot":"","sources":["../src/authored-gap.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAcvE;AAED,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAgBhD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project a flattened author's StyleProp, not a mixture with compiled styles.
|
|
3
|
+
* Yoga prefers an axis gutter to `gap` regardless of object key/array order.
|
|
4
|
+
* CSS needs the effective longhands instead, or a later shorthand erases the
|
|
5
|
+
* axis. The caller owns this flat object; authored objects are never mutated.
|
|
6
|
+
* Keep CSS-only strings untouched rather than pretending RN accepts them.
|
|
7
|
+
*/
|
|
8
|
+
export function projectAuthoredGap(style) {
|
|
9
|
+
const gap = style.gap;
|
|
10
|
+
if (gap === undefined)
|
|
11
|
+
return;
|
|
12
|
+
if (!(typeof gap === 'number' && Number.isFinite(gap) && gap >= 0) &&
|
|
13
|
+
!(typeof gap === 'string' && /^(?:\d+(?:\.\d+)?|\.\d+)%$/.test(gap)))
|
|
14
|
+
return;
|
|
15
|
+
if (!Object.hasOwn(style, 'gap'))
|
|
16
|
+
return;
|
|
17
|
+
const row = style.rowGap ?? gap;
|
|
18
|
+
const column = style.columnGap ?? gap;
|
|
19
|
+
delete style.gap;
|
|
20
|
+
style.rowGap = row;
|
|
21
|
+
style.columnGap = column;
|
|
22
|
+
}
|
|
23
|
+
/** Generated Native code calls this before mixing an author with class axes. */
|
|
24
|
+
export function hozoAuthoredStyle(input) {
|
|
25
|
+
if (!input || typeof input !== 'object')
|
|
26
|
+
return input;
|
|
27
|
+
if (!Array.isArray(input) && (!('gap' in input) || !Object.hasOwn(input, 'gap')))
|
|
28
|
+
return input;
|
|
29
|
+
// Flatten only the author's contribution. Reading it once also avoids a
|
|
30
|
+
// pre-scan that would evaluate style accessors again during composition.
|
|
31
|
+
const flat = {};
|
|
32
|
+
function visit(value) {
|
|
33
|
+
if (Array.isArray(value)) {
|
|
34
|
+
for (const item of value)
|
|
35
|
+
visit(item);
|
|
36
|
+
}
|
|
37
|
+
else if (value && typeof value === 'object') {
|
|
38
|
+
Object.assign(flat, value);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
visit(input);
|
|
42
|
+
projectAuthoredGap(flat);
|
|
43
|
+
return flat;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=authored-gap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authored-gap.js","sourceRoot":"","sources":["../src/authored-gap.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAA8B;IAC/D,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAA;IACrB,IAAI,GAAG,KAAK,SAAS;QAAE,OAAM;IAC7B,IACE,CAAC,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;QAC9D,CAAC,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEpE,OAAM;IACR,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC;QAAE,OAAM;IACxC,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,IAAI,GAAG,CAAA;IAC/B,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,IAAI,GAAG,CAAA;IACrC,OAAO,KAAK,CAAC,GAAG,CAAA;IAChB,KAAK,CAAC,MAAM,GAAG,GAAG,CAAA;IAClB,KAAK,CAAC,SAAS,GAAG,MAAM,CAAA;AAC1B,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,iBAAiB,CAAI,KAAQ;IAC3C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IACrD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAAE,OAAO,KAAK,CAAA;IAC9F,wEAAwE;IACxE,yEAAyE;IACzE,MAAM,IAAI,GAA4B,EAAE,CAAA;IACxC,SAAS,KAAK,CAAC,KAAc;QAC3B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,KAAK,MAAM,IAAI,IAAI,KAAK;gBAAE,KAAK,CAAC,IAAI,CAAC,CAAA;QACvC,CAAC;aAAM,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9C,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QAC5B,CAAC;IACH,CAAC;IACD,KAAK,CAAC,KAAK,CAAC,CAAA;IACZ,kBAAkB,CAAC,IAAI,CAAC,CAAA;IACxB,OAAO,IAAS,CAAA;AAClB,CAAC"}
|
package/dist/class-resolver.d.ts
CHANGED
|
@@ -1,26 +1,87 @@
|
|
|
1
1
|
/** A React Native style object, as the compiler emits it. */
|
|
2
2
|
export type StyleObject = Record<string, unknown>;
|
|
3
|
+
/**
|
|
4
|
+
* Compiler-owned text-size fallbacks are not explicit line heights. CSS's
|
|
5
|
+
* --tw-leading register survives a later font-size rule; RN has one numeric
|
|
6
|
+
* slot. The map marks actual generated objects, never class names or private
|
|
7
|
+
* style keys. Only maps containing these fallbacks install this composition.
|
|
8
|
+
*/
|
|
9
|
+
export declare function hozoTextMetricStyles(styles: StyleObject[], defaults: ReadonlyMap<StyleObject, StyleObject>): StyleObject[];
|
|
10
|
+
/**
|
|
11
|
+
* The state an element is in when its runtime classes are resolved: what
|
|
12
|
+
* its pressable reports (`pressed`, `hovered`, `focused`, `focusVisible`)
|
|
13
|
+
* and what its props say: `disabled`, and `aria-checked`, `aria-selected` and
|
|
14
|
+
* the rest under their attribute names, so `aria-pressed` cannot be read as
|
|
15
|
+
* the pointer's `pressed`. Plain data-presence conditions use `data-foo`
|
|
16
|
+
* booleans supplied by the actual owner: true means the attribute is present,
|
|
17
|
+
* false means absent, and a missing key is unassessed (and diagnosed).
|
|
18
|
+
* Simple equality predicates use `data-foo=value` booleans, with case-sensitive
|
|
19
|
+
* safe token values normalized at build time. Presence cannot satisfy equality.
|
|
20
|
+
* These are normalized facts, not raw HTML attribute values or selectors.
|
|
21
|
+
*/
|
|
22
|
+
export type ClassState = Readonly<Record<string, unknown>>;
|
|
23
|
+
/**
|
|
24
|
+
* A class that applies only in a state: the state keys that all have to
|
|
25
|
+
* hold, and the style it applies then. `active:opacity-80` is
|
|
26
|
+
* `[['pressed'], { opacity: 0.8 }]`.
|
|
27
|
+
* Generated Tailwind owner states may append a cached cascade rank; legacy
|
|
28
|
+
* two-entry groups and mixed/unranked conditional domains keep their order.
|
|
29
|
+
* `!aria-…` is compiler-owned negative-predicate data. It still requires the
|
|
30
|
+
* underlying owner fact; an absent fact is not a measured false value.
|
|
31
|
+
*/
|
|
32
|
+
export type StateGroup = readonly [readonly string[], StyleObject, number?];
|
|
3
33
|
/**
|
|
4
34
|
* Resolves whitespace-separated class names to React Native style objects.
|
|
5
35
|
*
|
|
6
36
|
* Returns an array, which is a valid `style` value on its own and also
|
|
7
37
|
* nests inside one -- RN flattens arbitrarily nested style arrays, so
|
|
8
38
|
* callers never have to spread it.
|
|
39
|
+
*
|
|
40
|
+
* `state` is what the element is in. Without it, a class that applies only
|
|
41
|
+
* in a state is reported as it always was; with it, that class applies
|
|
42
|
+
* when its state holds, after the unconditional ones.
|
|
9
43
|
*/
|
|
10
|
-
export type ClassResolver = (value: unknown) => StyleObject[];
|
|
44
|
+
export type ClassResolver = (value: unknown, state?: ClassState) => StyleObject[];
|
|
45
|
+
/** @internal Generated-data ABI, not a utility parser or a public cascade API. */
|
|
46
|
+
export interface ClassResolverPlan {
|
|
47
|
+
schema: 1;
|
|
48
|
+
styles: Record<string, StyleObject>;
|
|
49
|
+
unsupported?: Record<string, string>;
|
|
50
|
+
states?: Record<string, readonly StateGroup[]>;
|
|
51
|
+
ambient?: ClassState;
|
|
52
|
+
compose?: (styles: StyleObject[]) => StyleObject[];
|
|
53
|
+
/** Ordinals from one complete compiler namespace. Missing means barrier. */
|
|
54
|
+
ordering: {
|
|
55
|
+
schema: 1;
|
|
56
|
+
ranks: Readonly<Record<string, readonly number[]>>;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
11
59
|
/**
|
|
12
60
|
* Builds a resolver over one project's candidate map.
|
|
13
61
|
*
|
|
14
62
|
* Called by the generated candidate module rather than by application
|
|
15
|
-
* code: `styles` and `
|
|
16
|
-
* keeps the generated file to data plus one call.
|
|
63
|
+
* code: `styles`, `unsupported` and `states` are build output, and binding
|
|
64
|
+
* them here keeps the generated file to data plus one call.
|
|
17
65
|
*
|
|
18
66
|
* `unsupported` maps a class the compiler *recognized but can't express*
|
|
19
|
-
* as a plain style object -- a
|
|
67
|
+
* as a plain style object -- a utility under a breakpoint or `dark:`, or
|
|
20
68
|
* one that's Web-only -- to the reason. Those are reported when they're
|
|
21
69
|
* actually used rather than at build time, because a class appearing in
|
|
22
70
|
* the project's candidate scan doesn't mean any dynamic expression ever
|
|
23
71
|
* produces it.
|
|
72
|
+
*
|
|
73
|
+
* `states` holds the classes whose only condition is the element's own
|
|
74
|
+
* state (#886). Those need no tracking here: the pressable that renders
|
|
75
|
+
* the element already tracks it and hands it in, so this stays a function
|
|
76
|
+
* of the class string and that state.
|
|
77
|
+
*
|
|
78
|
+
* `ambient` holds facts that cannot change while the app runs, so no
|
|
79
|
+
* element has to supply them: `rtl` and `ltr`, because React Native needs
|
|
80
|
+
* a reload for a direction change to take effect. A class conditioned on
|
|
81
|
+
* them alone is decided once, when its string is first resolved, and then
|
|
82
|
+
* cached like an unconditional one -- after the unconditional ones, which is
|
|
83
|
+
* where Tailwind puts a variant too.
|
|
24
84
|
*/
|
|
25
|
-
export declare function createClassResolver(
|
|
85
|
+
export declare function createClassResolver(plan: ClassResolverPlan): ClassResolver;
|
|
86
|
+
export declare function createClassResolver(styles: Record<string, StyleObject>, unsupported?: Record<string, string>, compose?: (styles: StyleObject[]) => StyleObject[], states?: Record<string, readonly StateGroup[]>, ambient?: ClassState): ClassResolver;
|
|
26
87
|
//# sourceMappingURL=class-resolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-resolver.d.ts","sourceRoot":"","sources":["../src/class-resolver.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEjD
|
|
1
|
+
{"version":3,"file":"class-resolver.d.ts","sourceRoot":"","sources":["../src/class-resolver.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEjD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,WAAW,EAAE,EACrB,QAAQ,EAAE,WAAW,CAAC,WAAW,EAAE,WAAW,CAAC,GAC9C,WAAW,EAAE,CASf;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,M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AU,EAAE,CAAC,EAC9C,OAAO,CAAC,EAAE,UAAU,GACnB,aAAa,CAAA"}
|
package/dist/class-resolver.js
CHANGED
|
@@ -1,56 +1,230 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* keeps the generated file to data plus one call.
|
|
7
|
-
*
|
|
8
|
-
* `unsupported` maps a class the compiler *recognized but can't express*
|
|
9
|
-
* as a plain style object -- a conditional utility (`hover:`, `md:`), or
|
|
10
|
-
* one that's Web-only -- to the reason. Those are reported when they're
|
|
11
|
-
* actually used rather than at build time, because a class appearing in
|
|
12
|
-
* the project's candidate scan doesn't mean any dynamic expression ever
|
|
13
|
-
* produces it.
|
|
2
|
+
* Compiler-owned text-size fallbacks are not explicit line heights. CSS's
|
|
3
|
+
* --tw-leading register survives a later font-size rule; RN has one numeric
|
|
4
|
+
* slot. The map marks actual generated objects, never class names or private
|
|
5
|
+
* style keys. Only maps containing these fallbacks install this composition.
|
|
14
6
|
*/
|
|
15
|
-
export function
|
|
7
|
+
export function hozoTextMetricStyles(styles, defaults) {
|
|
8
|
+
if (!styles.some((style) => defaults.has(style)) ||
|
|
9
|
+
!styles.some((style) => Object.hasOwn(style, 'lineHeight') && !defaults.has(style)))
|
|
10
|
+
return styles;
|
|
11
|
+
// Default-free objects are built once by the generated factory. A state
|
|
12
|
+
// update selects them; it never clones a style object or inspects ranks.
|
|
13
|
+
return styles.map((style) => defaults.get(style) ?? style);
|
|
14
|
+
}
|
|
15
|
+
export function createClassResolver(stylesOrPlan, unsupported = {}, compose, states = {}, ambient = {}) {
|
|
16
|
+
let styles;
|
|
17
|
+
let ranks;
|
|
18
|
+
if (typeof stylesOrPlan.schema === 'number') {
|
|
19
|
+
const plan = stylesOrPlan;
|
|
20
|
+
if (plan.schema !== 1 ||
|
|
21
|
+
plan.ordering?.schema !== 1 ||
|
|
22
|
+
!plan.ordering.ranks ||
|
|
23
|
+
typeof plan.ordering.ranks !== 'object')
|
|
24
|
+
throw new Error('Unsupported Hozo class plan schema');
|
|
25
|
+
styles = plan.styles;
|
|
26
|
+
unsupported = plan.unsupported ?? {};
|
|
27
|
+
compose = plan.compose;
|
|
28
|
+
states = plan.states ?? {};
|
|
29
|
+
ambient = plan.ambient ?? {};
|
|
30
|
+
ranks = plan.ordering.ranks;
|
|
31
|
+
}
|
|
32
|
+
else
|
|
33
|
+
styles = stylesOrPlan;
|
|
34
|
+
const isAmbient = (key) => Object.hasOwn(ambient, key);
|
|
16
35
|
// Class strings repeat constantly across renders and list items, and the
|
|
17
36
|
// result is immutable, so each distinct string is resolved once.
|
|
18
37
|
const cache = new Map();
|
|
19
38
|
// Warn once per class, not once per render -- a warning inside a list's
|
|
20
39
|
// render path would otherwise repeat for every row, every frame.
|
|
21
40
|
const warned = new Set();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
41
|
+
const warn = (name, reason) => {
|
|
42
|
+
if (warned.has(name))
|
|
43
|
+
return;
|
|
44
|
+
warned.add(name);
|
|
45
|
+
// eslint-disable-next-line no-console
|
|
46
|
+
console.warn(`[hozo] ${reason}`);
|
|
47
|
+
};
|
|
48
|
+
// Absent is not false. A focused field must not silently claim that it
|
|
49
|
+
// measured hover/press, or that a spread supplied a disabled driver.
|
|
50
|
+
const supplied = (keys, name, facts) => {
|
|
51
|
+
if (!keys.every((key) => Object.hasOwn(facts, key))) {
|
|
52
|
+
if (!warned.has(name)) {
|
|
53
|
+
const missing = keys.filter((key) => !Object.hasOwn(facts, key));
|
|
54
|
+
warn(name, `\`${name}\` needs state (${missing.join(', ')}) this element does not supply.`);
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
27
57
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
58
|
+
return true;
|
|
59
|
+
};
|
|
60
|
+
const positive = (keys, name, facts) => supplied(keys, name, facts) && keys.every((key) => Boolean(facts[key]));
|
|
61
|
+
// Prepare only negative maps' exceptional groups once, not during state
|
|
62
|
+
// updates or for every authored class lookup. Positive-only maps retain
|
|
63
|
+
// their existing boolean matcher and allocate no predicate side table.
|
|
64
|
+
let negative;
|
|
65
|
+
for (const groups of Object.values(states))
|
|
66
|
+
for (const [keys] of groups)
|
|
67
|
+
if (keys.some((key) => key.startsWith('!aria-')))
|
|
68
|
+
(negative ??= new Map()).set(keys, {
|
|
69
|
+
keys: keys.map((key) => (key.startsWith('!aria-') ? key.slice(1) : key)),
|
|
70
|
+
expected: keys.map((key) => !key.startsWith('!aria-')),
|
|
71
|
+
});
|
|
72
|
+
const negativePredicates = negative;
|
|
73
|
+
const matches = negativePredicates
|
|
74
|
+
? (keys, name, facts) => {
|
|
75
|
+
const predicate = negativePredicates.get(keys);
|
|
76
|
+
return predicate
|
|
77
|
+
? supplied(predicate.keys, name, facts) &&
|
|
78
|
+
predicate.keys.every((key, index) => Boolean(facts[key]) === predicate.expected[index])
|
|
79
|
+
: positive(keys, name, facts);
|
|
31
80
|
}
|
|
32
|
-
|
|
81
|
+
: positive;
|
|
82
|
+
function resolve(value) {
|
|
83
|
+
const base = [];
|
|
84
|
+
const groups = [];
|
|
85
|
+
const groupClasses = [];
|
|
86
|
+
const stateClasses = [];
|
|
87
|
+
const decided = [];
|
|
88
|
+
// Build transient ranked entries only for the generated-plan ABI. A
|
|
89
|
+
// single unassessed object makes this whole string use the old path.
|
|
90
|
+
let ranked = ranks ? [] : undefined;
|
|
91
|
+
const take = ranks
|
|
92
|
+
? (name, index, style, keys) => {
|
|
93
|
+
if (!ranked)
|
|
94
|
+
return;
|
|
95
|
+
const rank = ranks[name]?.[index];
|
|
96
|
+
if (rank === undefined) {
|
|
97
|
+
ranked = undefined;
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (!Number.isSafeInteger(rank) || rank < 0)
|
|
101
|
+
throw new Error('Invalid Hozo class plan rank');
|
|
102
|
+
ranked.push({ rank, entry: { name, style, keys } });
|
|
103
|
+
}
|
|
104
|
+
: undefined;
|
|
33
105
|
for (const name of value.split(/\s+/)) {
|
|
34
106
|
if (name === '') {
|
|
35
107
|
continue;
|
|
36
108
|
}
|
|
37
109
|
const style = styles[name];
|
|
38
110
|
if (style) {
|
|
39
|
-
|
|
111
|
+
base.push(style);
|
|
112
|
+
take?.(name, 0, style, []);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const conditional = states[name];
|
|
116
|
+
if (conditional) {
|
|
117
|
+
let needsState = false;
|
|
118
|
+
for (let index = 0; index < conditional.length; index++) {
|
|
119
|
+
const group = conditional[index];
|
|
120
|
+
take?.(name, index, group[1], group[0]);
|
|
121
|
+
if ((negativePredicates?.get(group[0])?.keys ?? group[0]).every(isAmbient)) {
|
|
122
|
+
if (matches(group[0], name, ambient))
|
|
123
|
+
decided.push(group[1]);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
groups.push(group);
|
|
127
|
+
groupClasses.push(name);
|
|
128
|
+
needsState = true;
|
|
129
|
+
}
|
|
130
|
+
if (needsState)
|
|
131
|
+
stateClasses.push(name);
|
|
40
132
|
continue;
|
|
41
133
|
}
|
|
42
134
|
// An unknown class isn't necessarily a Hozo problem -- it may be an
|
|
43
135
|
// app's own non-Tailwind class, or a testID-ish marker -- so only the
|
|
44
136
|
// ones the compiler recognized and refused are reported.
|
|
45
137
|
const reason = unsupported[name];
|
|
46
|
-
if (reason
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
138
|
+
if (reason)
|
|
139
|
+
warn(name, reason);
|
|
140
|
+
}
|
|
141
|
+
if (ranked) {
|
|
142
|
+
// Stable ties keep input order. Strip rank objects before caching, so
|
|
143
|
+
// neither cache hits nor state-only changes can read/sort priorities.
|
|
144
|
+
ranked.sort((a, b) => a.rank - b.rank);
|
|
145
|
+
const ordered = [];
|
|
146
|
+
for (const { entry } of ranked) {
|
|
147
|
+
if ((negativePredicates?.get(entry.keys)?.keys ?? entry.keys).every(isAmbient)) {
|
|
148
|
+
if (matches(entry.keys, entry.name, ambient))
|
|
149
|
+
ordered.push({ ...entry, keys: [] });
|
|
150
|
+
}
|
|
151
|
+
else
|
|
152
|
+
ordered.push(entry);
|
|
153
|
+
}
|
|
154
|
+
const raw = ordered.filter((entry) => !entry.keys.length).map((entry) => entry.style);
|
|
155
|
+
return {
|
|
156
|
+
base: compose ? compose(raw) : raw,
|
|
157
|
+
raw,
|
|
158
|
+
groups,
|
|
159
|
+
groupClasses,
|
|
160
|
+
stateClasses,
|
|
161
|
+
ordered,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
// Build-time Tailwind owner-state rank, sorted once per cached class string,
|
|
165
|
+
// never on every state update. Mixed/unranked domains are left alone; ties
|
|
166
|
+
// retain authored/caller order. Keep warning provenance beside each group.
|
|
167
|
+
if (groups.length > 1 && groups.every((group) => group[2] !== undefined)) {
|
|
168
|
+
if (groups.some((group, index) => index > 0 && groups[index - 1][2] > group[2])) {
|
|
169
|
+
const sorted = groups
|
|
170
|
+
.map((group, index) => ({ group, name: groupClasses[index] }))
|
|
171
|
+
.sort((a, b) => a.group[2] - b.group[2]);
|
|
172
|
+
for (const [index, entry] of sorted.entries()) {
|
|
173
|
+
groups[index] = entry.group;
|
|
174
|
+
groupClasses[index] = entry.name;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
base.push(...decided);
|
|
179
|
+
return { base: compose ? compose(base) : base, raw: base, groups, groupClasses, stateClasses };
|
|
180
|
+
}
|
|
181
|
+
return function hozoClasses(value, state) {
|
|
182
|
+
// Falsy is the normal case, not an error: `cond && 'p-4'` yields
|
|
183
|
+
// `false` whenever the condition is off.
|
|
184
|
+
if (typeof value !== 'string' || value === '') {
|
|
185
|
+
return [];
|
|
186
|
+
}
|
|
187
|
+
let resolved = cache.get(value);
|
|
188
|
+
if (!resolved) {
|
|
189
|
+
resolved = resolve(value);
|
|
190
|
+
cache.set(value, resolved);
|
|
191
|
+
}
|
|
192
|
+
if (resolved.groups.length === 0)
|
|
193
|
+
return resolved.base;
|
|
194
|
+
if (state === undefined) {
|
|
195
|
+
for (const name of resolved.stateClasses) {
|
|
196
|
+
warn(name, `\`${name}\` applies in a state, and this element hands its classes no state to ` +
|
|
197
|
+
'resolve it against. Put it on an owner that supplies this state, or write it as a static ' +
|
|
198
|
+
'className so it compiles to a real style variant.');
|
|
199
|
+
}
|
|
200
|
+
return resolved.base;
|
|
201
|
+
}
|
|
202
|
+
// A group can name an ambient fact beside the element's own, as
|
|
203
|
+
// `rtl:hover:` does; the element supplies only its part.
|
|
204
|
+
const facts = { ...ambient, ...state };
|
|
205
|
+
if (resolved.ordered) {
|
|
206
|
+
const all = [];
|
|
207
|
+
let active = false;
|
|
208
|
+
for (const entry of resolved.ordered) {
|
|
209
|
+
if (!entry.keys.length)
|
|
210
|
+
all.push(entry.style);
|
|
211
|
+
else if (matches(entry.keys, entry.name, facts)) {
|
|
212
|
+
all.push(entry.style);
|
|
213
|
+
active = true;
|
|
214
|
+
}
|
|
50
215
|
}
|
|
216
|
+
if (!active)
|
|
217
|
+
return resolved.base;
|
|
218
|
+
return compose ? compose(all) : all;
|
|
51
219
|
}
|
|
52
|
-
|
|
53
|
-
|
|
220
|
+
const active = resolved.groups.filter(([keys], index) => matches(keys, resolved.groupClasses[index], facts));
|
|
221
|
+
if (active.length === 0)
|
|
222
|
+
return resolved.base;
|
|
223
|
+
const all = [...resolved.raw, ...active.map(([, style]) => style)];
|
|
224
|
+
// A state style can carry a transform, which `compose` folds into one;
|
|
225
|
+
// so it runs over the whole list, and the result is per render rather
|
|
226
|
+
// than cached -- it changes with the state.
|
|
227
|
+
return compose ? compose(all) : all;
|
|
54
228
|
};
|
|
55
229
|
}
|
|
56
230
|
//# sourceMappingURL=class-resolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-resolver.js","sourceRoot":"","sources":["../src/class-resolver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"class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CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IACrC,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** `HozoAnimated`'s spec, as `@hozo/primitives` defines it. */
|
|
2
|
+
export interface ClassTransitionSpec {
|
|
3
|
+
duration: number;
|
|
4
|
+
delay?: number;
|
|
5
|
+
easing: 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out';
|
|
6
|
+
properties?: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
/** @internal Generated-data ABI: one transition utility's condition and part. */
|
|
9
|
+
export type ClassTransitionTable = Readonly<Record<string, readonly [condition: 'motion-reduce' | 'motion-safe' | null, Partial<ClassTransitionSpec>]>>;
|
|
10
|
+
/**
|
|
11
|
+
* Reads the transition a class string asks for, or `undefined` when it asks
|
|
12
|
+
* for none.
|
|
13
|
+
*
|
|
14
|
+
* `reduceMotion` decides the `motion-reduce:` and `motion-safe:` parts, as
|
|
15
|
+
* the media query does on the Web; the caller reads it, so this stays a pure
|
|
16
|
+
* function of its arguments.
|
|
17
|
+
*/
|
|
18
|
+
export type ClassTransition = (value: unknown, environment: {
|
|
19
|
+
reduceMotion: boolean;
|
|
20
|
+
}) => ClassTransitionSpec | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Builds the reader over one project's transition table.
|
|
23
|
+
*
|
|
24
|
+
* Later classes win, field by field, as later declarations do in a
|
|
25
|
+
* stylesheet. A string with no `transition*` utility asks for no
|
|
26
|
+
* transition, whatever its duration says: on the Web `transition-property`
|
|
27
|
+
* is what turns one on. Its defaults are Tailwind's: 150ms and
|
|
28
|
+
* `ease-in-out`'s curve, which `transition-*` utilities normally set
|
|
29
|
+
* themselves.
|
|
30
|
+
*/
|
|
31
|
+
export declare function createClassTransitions(table: ClassTransitionTable): ClassTransition;
|
|
32
|
+
//# sourceMappingURL=class-transition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class-transition.d.ts","sourceRoot":"","sources":["../src/class-transition.ts"],"names":[],"mappings":"AAUA,+DAA+D;AAC/D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,CAAA;IACzD,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAC/B;AAED,iFAAiF;AACjF,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CACzC,MAAM,CACJ,MAAM,EACN,SAAS,CAAC,SAAS,EAAE,eAAe,GAAG,aAAa,GAAG,IAAI,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAC3F,CACF,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG,CAC5B,KAAK,EAAE,OAAO,EACd,WAAW,EAAE;IAAE,YAAY,EAAE,OAAO,CAAA;CAAE,KACnC,mBAAmB,GAAG,SAAS,CAAA;AAEpC;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,oBAAoB,GAAG,eAAe,CAqBnF"}
|