@jsenv/navi 0.26.18 → 0.26.20
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/dist/jsenv_navi.js +61 -93
- package/dist/jsenv_navi.js.map +8 -9
- package/package.json +1 -1
package/dist/jsenv_navi.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { installImportMetaCssBuild } from "./jsenv_navi_side_effects.js";
|
|
2
|
-
import { isValidElement, createContext, h,
|
|
2
|
+
import { isValidElement, createContext, h, toChildArray, render, cloneElement } from "preact";
|
|
3
3
|
import { useErrorBoundary, useLayoutEffect, useEffect, useContext, useMemo, useRef, useState, useCallback, useImperativeHandle, useId } from "preact/hooks";
|
|
4
4
|
import { jsxs, jsx, Fragment } from "preact/jsx-runtime";
|
|
5
5
|
import { signal, effect, computed, batch, useSignal } from "@preact/signals";
|
|
@@ -8041,72 +8041,42 @@ const updateStyle = (element, style, preventInitialTransition) => {
|
|
|
8041
8041
|
styleKeySetWeakMap.set(element, styleKeySet);
|
|
8042
8042
|
};
|
|
8043
8043
|
|
|
8044
|
-
// Implementation notes:
|
|
8045
|
-
//
|
|
8046
|
-
// options.__r fires before each component render — we capture the current
|
|
8047
|
-
// component instance (vnode.__c) so useEarlyDOMEffect can register itself.
|
|
8048
|
-
//
|
|
8049
|
-
// options.__c (commitRoot) fires after refs are assigned and before any
|
|
8050
|
-
// useLayoutEffect runs. We flush all pending effects there.
|
|
8051
|
-
// The DOM node is read from component.__v.__e (vnode → root DOM node),
|
|
8052
|
-
// which Preact sets during diffing, before options.__c fires.
|
|
8053
|
-
//
|
|
8054
|
-
// stateMap (WeakMap) stores { cleanup, deps } per component instance.
|
|
8055
|
-
// It's auto-GC'd when a component is destroyed; options.unmount also
|
|
8056
|
-
// deletes entries eagerly to release cleanup functions sooner.
|
|
8057
|
-
//
|
|
8058
|
-
// pendingMap (Map) holds effects registered during the current render pass.
|
|
8059
|
-
// It is always fully cleared in options.__c — bounded to one commit, no leak.
|
|
8060
|
-
|
|
8061
8044
|
/**
|
|
8062
|
-
*
|
|
8063
|
-
*
|
|
8064
|
-
*
|
|
8065
|
-
*
|
|
8066
|
-
*
|
|
8067
|
-
*
|
|
8068
|
-
*
|
|
8069
|
-
*
|
|
8070
|
-
*
|
|
8071
|
-
* Supports deps and cleanup return, same as useLayoutEffect.
|
|
8045
|
+
* Keeps a DOM element in sync with `syncElement(el)` whenever deps change.
|
|
8046
|
+
* - If element is already mounted: runs syncElement immediately during render.
|
|
8047
|
+
* - If not yet mounted: runs syncElement in the ref callback when element arrives.
|
|
8048
|
+
* - Calls cleanup (if returned by syncElement) before each re-run and on unmount.
|
|
8049
|
+
*
|
|
8050
|
+
* @param {function|object|null} externalRef - Optional ref to forward to
|
|
8051
|
+
* @param {function} syncElement - Called with the DOM element when deps change
|
|
8052
|
+
* @param {Array} deps - syncElement is re-called only when deps change
|
|
8072
8053
|
*/
|
|
8073
|
-
const
|
|
8074
|
-
const
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
};
|
|
8079
|
-
|
|
8080
|
-
// Populated during render, consumed + cleared in options.__c each commit.
|
|
8081
|
-
const pendingMap = new Map(); // component → { fn, deps, ref }
|
|
8082
|
-
|
|
8083
|
-
// Persists across commits. WeakMap → no leak when component is destroyed.
|
|
8084
|
-
const stateMap = new WeakMap(); // component → { cleanup, deps }
|
|
8054
|
+
const useElementRefEffect = (externalRef, syncElement, deps) => {
|
|
8055
|
+
const cleanupRef = useRef(null);
|
|
8056
|
+
const elRef = useRef(null);
|
|
8057
|
+
const prevDepsRef = useRef(undefined);
|
|
8058
|
+
const refCallbackRef = useRef(null);
|
|
8085
8059
|
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
if (_prevBeforeRender) {
|
|
8091
|
-
_prevBeforeRender(vnode);
|
|
8092
|
-
}
|
|
8093
|
-
};
|
|
8094
|
-
|
|
8095
|
-
const _prevCommit = options.__c;
|
|
8096
|
-
options.__c = (root, commitQueue) => {
|
|
8097
|
-
for (const [component, { fn, deps, needDOMNode }] of pendingMap) {
|
|
8098
|
-
// component.__v is the component's vnode; __e is its root DOM node.
|
|
8099
|
-
// Both are set during diff, before options.__c fires.
|
|
8100
|
-
const element = component.__v && component.__v.__e;
|
|
8101
|
-
if (needDOMNode && !element) {
|
|
8102
|
-
continue;
|
|
8060
|
+
const runSync = (el) => {
|
|
8061
|
+
if (cleanupRef.current) {
|
|
8062
|
+
cleanupRef.current();
|
|
8063
|
+
cleanupRef.current = null;
|
|
8103
8064
|
}
|
|
8104
|
-
|
|
8105
|
-
const
|
|
8065
|
+
prevDepsRef.current = deps;
|
|
8066
|
+
const cleanup = syncElement(el);
|
|
8067
|
+
if (typeof cleanup === "function") {
|
|
8068
|
+
cleanupRef.current = cleanup;
|
|
8069
|
+
}
|
|
8070
|
+
};
|
|
8071
|
+
|
|
8072
|
+
// If element already mounted, check deps and sync during render.
|
|
8073
|
+
if (elRef.current) {
|
|
8074
|
+
const prevDeps = prevDepsRef.current;
|
|
8106
8075
|
let depsChanged;
|
|
8107
|
-
if (!prevDeps ||
|
|
8076
|
+
if (!prevDeps || prevDeps.length !== deps.length) {
|
|
8108
8077
|
depsChanged = true;
|
|
8109
8078
|
} else {
|
|
8079
|
+
depsChanged = false;
|
|
8110
8080
|
for (let i = 0; i < deps.length; i++) {
|
|
8111
8081
|
if (!Object.is(deps[i], prevDeps[i])) {
|
|
8112
8082
|
depsChanged = true;
|
|
@@ -8115,35 +8085,35 @@ options.__c = (root, commitQueue) => {
|
|
|
8115
8085
|
}
|
|
8116
8086
|
}
|
|
8117
8087
|
if (depsChanged) {
|
|
8118
|
-
|
|
8119
|
-
prev.cleanup();
|
|
8120
|
-
}
|
|
8121
|
-
const result = fn(element);
|
|
8122
|
-
const cleanup = typeof result === "function" ? result : undefined;
|
|
8123
|
-
stateMap.set(component, { cleanup, deps });
|
|
8088
|
+
runSync(elRef.current);
|
|
8124
8089
|
}
|
|
8125
8090
|
}
|
|
8126
|
-
pendingMap.clear();
|
|
8127
|
-
if (_prevCommit) {
|
|
8128
|
-
_prevCommit(root, commitQueue);
|
|
8129
|
-
}
|
|
8130
|
-
};
|
|
8131
8091
|
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
|
|
8092
|
+
if (!refCallbackRef.current) {
|
|
8093
|
+
refCallbackRef.current = (el) => {
|
|
8094
|
+
elRef.current = el;
|
|
8095
|
+
if (externalRef) {
|
|
8096
|
+
if (typeof externalRef === "function") {
|
|
8097
|
+
externalRef(el);
|
|
8098
|
+
} else {
|
|
8099
|
+
externalRef.current = el;
|
|
8100
|
+
}
|
|
8101
|
+
}
|
|
8102
|
+
if (el) {
|
|
8103
|
+
runSync(el);
|
|
8104
|
+
} else {
|
|
8105
|
+
if (cleanupRef.current) {
|
|
8106
|
+
cleanupRef.current();
|
|
8107
|
+
cleanupRef.current = null;
|
|
8108
|
+
}
|
|
8109
|
+
prevDepsRef.current = undefined;
|
|
8110
|
+
}
|
|
8111
|
+
};
|
|
8146
8112
|
}
|
|
8113
|
+
|
|
8114
|
+
const refCallback = refCallbackRef.current;
|
|
8115
|
+
refCallback.current = elRef.current;
|
|
8116
|
+
return refCallback;
|
|
8147
8117
|
};
|
|
8148
8118
|
|
|
8149
8119
|
installImportMetaCssBuild(import.meta);/**
|
|
@@ -8323,8 +8293,7 @@ const Box = props => {
|
|
|
8323
8293
|
separator,
|
|
8324
8294
|
...rest
|
|
8325
8295
|
} = props;
|
|
8326
|
-
|
|
8327
|
-
const ref = props.ref || defaultRef;
|
|
8296
|
+
let ref;
|
|
8328
8297
|
const TagName = as;
|
|
8329
8298
|
const defaultDisplay = getDefaultDisplay(TagName);
|
|
8330
8299
|
// Read the parent flow early so we can use it when display="inherit" is requested.
|
|
@@ -8677,9 +8646,7 @@ const Box = props => {
|
|
|
8677
8646
|
styleDeps.push(...pseudoClasses);
|
|
8678
8647
|
}
|
|
8679
8648
|
}
|
|
8680
|
-
|
|
8681
|
-
// we need to implent our styleDeps tracking but that's likely very easy
|
|
8682
|
-
useEarlyDOMEffect(boxEl => {
|
|
8649
|
+
ref = useElementRefEffect(props.ref, boxEl => {
|
|
8683
8650
|
const pseudoStateEl = pseudoStateSelector ? boxEl.querySelector(pseudoStateSelector) : boxEl;
|
|
8684
8651
|
const visualEl = visualSelector ? boxEl.querySelector(visualSelector) : null;
|
|
8685
8652
|
return initPseudoStyles(pseudoStateEl, {
|
|
@@ -29293,6 +29260,7 @@ const InputTextualUI = props => {
|
|
|
29293
29260
|
autoFocusVisible,
|
|
29294
29261
|
autoSelect,
|
|
29295
29262
|
basePseudoState,
|
|
29263
|
+
icon,
|
|
29296
29264
|
children,
|
|
29297
29265
|
...rest
|
|
29298
29266
|
} = props;
|
|
@@ -29364,7 +29332,7 @@ const InputTextualUI = props => {
|
|
|
29364
29332
|
if (children === undefined) {
|
|
29365
29333
|
if (type === "search") {
|
|
29366
29334
|
innerChildren = jsxs(Fragment, {
|
|
29367
|
-
children: [jsx(InputLeftSlot, {
|
|
29335
|
+
children: [icon === undefined && jsx(InputLeftSlot, {
|
|
29368
29336
|
children: jsx(Icon, {
|
|
29369
29337
|
color: "rgba(28, 43, 52, 0.5)",
|
|
29370
29338
|
children: jsx(SearchSvg, {})
|
|
@@ -29385,14 +29353,14 @@ const InputTextualUI = props => {
|
|
|
29385
29353
|
})]
|
|
29386
29354
|
});
|
|
29387
29355
|
} else if (type === "email") {
|
|
29388
|
-
innerChildren = jsx(InputLeftSlot, {
|
|
29356
|
+
innerChildren = icon === undefined && jsx(InputLeftSlot, {
|
|
29389
29357
|
children: jsx(Icon, {
|
|
29390
29358
|
color: "rgba(28, 43, 52, 0.5)",
|
|
29391
29359
|
children: jsx(EmailSvg, {})
|
|
29392
29360
|
})
|
|
29393
29361
|
});
|
|
29394
29362
|
} else if (type === "tel") {
|
|
29395
|
-
innerChildren = jsx(InputLeftSlot, {
|
|
29363
|
+
innerChildren = icon === undefined && jsx(InputLeftSlot, {
|
|
29396
29364
|
children: jsx(Icon, {
|
|
29397
29365
|
color: "rgba(28, 43, 52, 0.5)",
|
|
29398
29366
|
children: jsx(PhoneSvg, {})
|