@pyreon/vue-compat 0.18.0 → 0.19.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/lib/analysis/index.js.html +1 -1
- package/lib/analysis/jsx-runtime.js.html +1 -1
- package/lib/index.js +304 -6
- package/lib/jsx-runtime.js +2 -1
- package/lib/types/index.d.ts +310 -2
- package/package.json +5 -5
- package/src/index.ts +430 -5
- package/src/jsx-runtime.ts +14 -0
- package/src/tests/new-apis.test.ts +359 -6
|
@@ -5386,7 +5386,7 @@ var drawChart = (function (exports) {
|
|
|
5386
5386
|
</script>
|
|
5387
5387
|
<script>
|
|
5388
5388
|
/*<!--*/
|
|
5389
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"uid":"
|
|
5389
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"uid":"5d7b64f5-1","name":"jsx-runtime.ts"},{"uid":"5d7b64f5-3","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"5d7b64f5-1":{"renderedLength":186,"gzipLength":138,"brotliLength":0,"metaUid":"5d7b64f5-0"},"5d7b64f5-3":{"renderedLength":33794,"gzipLength":8644,"brotliLength":0,"metaUid":"5d7b64f5-2"}},"nodeMetas":{"5d7b64f5-0":{"id":"/src/jsx-runtime.ts","moduleParts":{"index.js":"5d7b64f5-1"},"imported":[{"uid":"5d7b64f5-4"},{"uid":"5d7b64f5-5"}],"importedBy":[{"uid":"5d7b64f5-2"}]},"5d7b64f5-2":{"id":"/src/index.ts","moduleParts":{"index.js":"5d7b64f5-3"},"imported":[{"uid":"5d7b64f5-4"},{"uid":"5d7b64f5-5"},{"uid":"5d7b64f5-6"},{"uid":"5d7b64f5-0"}],"importedBy":[],"isEntry":true},"5d7b64f5-4":{"id":"@pyreon/core","moduleParts":{},"imported":[],"importedBy":[{"uid":"5d7b64f5-2"},{"uid":"5d7b64f5-0"}]},"5d7b64f5-5":{"id":"@pyreon/reactivity","moduleParts":{},"imported":[],"importedBy":[{"uid":"5d7b64f5-2"},{"uid":"5d7b64f5-0"}]},"5d7b64f5-6":{"id":"@pyreon/runtime-dom","moduleParts":{},"imported":[],"importedBy":[{"uid":"5d7b64f5-2"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
5390
5390
|
|
|
5391
5391
|
const run = () => {
|
|
5392
5392
|
const width = window.innerWidth;
|
|
@@ -5386,7 +5386,7 @@ var drawChart = (function (exports) {
|
|
|
5386
5386
|
</script>
|
|
5387
5387
|
<script>
|
|
5388
5388
|
/*<!--*/
|
|
5389
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"jsx-runtime.js","children":[{"name":"src","children":[{"uid":"
|
|
5389
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"jsx-runtime.js","children":[{"name":"src","children":[{"uid":"de753381-1","name":"jsx-runtime.ts"},{"uid":"de753381-3","name":"jsx-dev-runtime.ts"}]}]}],"isRoot":true},"nodeParts":{"de753381-1":{"renderedLength":2733,"gzipLength":986,"brotliLength":0,"metaUid":"de753381-0"},"de753381-3":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"de753381-2"}},"nodeMetas":{"de753381-0":{"id":"/src/jsx-runtime.ts","moduleParts":{"jsx-runtime.js":"de753381-1"},"imported":[{"uid":"de753381-4"},{"uid":"de753381-5"}],"importedBy":[{"uid":"de753381-2"}]},"de753381-2":{"id":"/src/jsx-dev-runtime.ts","moduleParts":{"jsx-runtime.js":"de753381-3"},"imported":[{"uid":"de753381-0"}],"importedBy":[],"isEntry":true},"de753381-4":{"id":"@pyreon/core","moduleParts":{},"imported":[],"importedBy":[{"uid":"de753381-0"}]},"de753381-5":{"id":"@pyreon/reactivity","moduleParts":{},"imported":[],"importedBy":[{"uid":"de753381-0"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
5390
5390
|
|
|
5391
5391
|
const run = () => {
|
|
5392
5392
|
const width = window.innerWidth;
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Fragment, Portal, createContext, h as pyreonH, onMount, onUnmount, onUpdate, popContext, pushContext, useContext } from "@pyreon/core";
|
|
1
|
+
import { Fragment, Portal, Suspense as Suspense$1, createContext, h as pyreonH, onMount, onUnmount, onUpdate, popContext, pushContext, useContext } from "@pyreon/core";
|
|
2
2
|
import { batch, computed as computed$1, createStore, effect, nextTick as nextTick$1, signal } from "@pyreon/reactivity";
|
|
3
|
-
import { mount } from "@pyreon/runtime-dom";
|
|
3
|
+
import { KeepAlive as KeepAlive$1, Transition as Transition$1, TransitionGroup as TransitionGroup$1, mount } from "@pyreon/runtime-dom";
|
|
4
4
|
|
|
5
5
|
//#region src/jsx-runtime.ts
|
|
6
6
|
let _currentCtx = null;
|
|
@@ -643,20 +643,40 @@ function inject(key, defaultValue, treatDefaultAsFactory) {
|
|
|
643
643
|
return defaultValue;
|
|
644
644
|
}
|
|
645
645
|
/**
|
|
646
|
+
* Computes Vue's fallthrough `attrs` — every passed prop that is NOT a
|
|
647
|
+
* declared prop (and not the internal `children` slot payload). When the
|
|
648
|
+
* component declared no props (`declared` undefined) the split is unknowable,
|
|
649
|
+
* so the full props object is returned (honest back-compat — matches the
|
|
650
|
+
* pre-split behavior rather than guessing).
|
|
651
|
+
*/
|
|
652
|
+
function splitVueAttrs(props, declared) {
|
|
653
|
+
if (!declared) return props;
|
|
654
|
+
const declaredSet = new Set(declared);
|
|
655
|
+
const attrs = {};
|
|
656
|
+
for (const key of Object.keys(props)) {
|
|
657
|
+
if (key === "children" || declaredSet.has(key)) continue;
|
|
658
|
+
attrs[key] = props[key];
|
|
659
|
+
}
|
|
660
|
+
return attrs;
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
646
663
|
* Defines a component using Vue 3 Composition API style.
|
|
647
664
|
* Only supports the `setup()` function — Options API is not supported.
|
|
648
665
|
*/
|
|
649
666
|
function defineComponent(options) {
|
|
650
667
|
if (typeof options === "function") return options;
|
|
668
|
+
const declaredProps = options.props ? Object.keys(options.props) : void 0;
|
|
651
669
|
const comp = (props) => {
|
|
652
670
|
const children = props.children;
|
|
671
|
+
const rc = getCurrentCtx();
|
|
672
|
+
if (rc && declaredProps) rc._declaredProps = declaredProps;
|
|
653
673
|
const setupCtx = {
|
|
654
674
|
emit: (event, ...args) => {
|
|
655
675
|
const handler = props[`on${event.charAt(0).toUpperCase()}${event.slice(1)}`];
|
|
656
676
|
if (typeof handler === "function") handler(...args);
|
|
657
677
|
},
|
|
658
678
|
slots: { default: children !== void 0 ? (() => children) : void 0 },
|
|
659
|
-
attrs: props
|
|
679
|
+
attrs: splitVueAttrs(props, declaredProps)
|
|
660
680
|
};
|
|
661
681
|
const result = options.setup(props, setupCtx);
|
|
662
682
|
if (typeof result === "function") return result();
|
|
@@ -832,10 +852,288 @@ function Teleport(props) {
|
|
|
832
852
|
});
|
|
833
853
|
}
|
|
834
854
|
/**
|
|
835
|
-
* KeepAlive —
|
|
855
|
+
* KeepAlive — mounts its children once and keeps them alive (state preserved)
|
|
856
|
+
* even when hidden, instead of destroying/recreating them.
|
|
857
|
+
*
|
|
858
|
+
* Wraps `@pyreon/runtime-dom`'s real KeepAlive. Vue's `<KeepAlive>` keeps a
|
|
859
|
+
* cache of inactive component instances; this maps the common single-slot
|
|
860
|
+
* usage to Pyreon's `active`-accessor model.
|
|
861
|
+
*
|
|
862
|
+
* LIMITATIONS vs Vue 3:
|
|
863
|
+
* - Vue's `include` / `exclude` / `max` props are NOT supported. Pyreon's
|
|
864
|
+
* KeepAlive is a single always-mounted slot toggled by an `active`
|
|
865
|
+
* accessor — there is no per-component LRU cache to filter or bound.
|
|
866
|
+
* These props are accepted (so existing Vue code typechecks) but ignored.
|
|
867
|
+
* - Vue toggles activation via the dynamic child (`<component :is>`); here
|
|
868
|
+
* you pass an `active` accessor (`() => boolean`). When omitted, children
|
|
869
|
+
* are always mounted and visible (a faithful default — nothing is
|
|
870
|
+
* destroyed, matching KeepAlive's core guarantee).
|
|
871
|
+
*
|
|
872
|
+
* @example
|
|
873
|
+
* import { KeepAlive, ref } from "@pyreon/vue-compat"
|
|
874
|
+
*
|
|
875
|
+
* function App() {
|
|
876
|
+
* const showA = ref(true)
|
|
877
|
+
* return (
|
|
878
|
+
* <KeepAlive active={() => showA.value}>
|
|
879
|
+
* <ExpensiveTab />
|
|
880
|
+
* </KeepAlive>
|
|
881
|
+
* )
|
|
882
|
+
* }
|
|
836
883
|
*/
|
|
837
884
|
function KeepAlive(props) {
|
|
838
|
-
return
|
|
885
|
+
return KeepAlive$1({
|
|
886
|
+
...props.active !== void 0 ? { active: props.active } : {},
|
|
887
|
+
children: props.children ?? null
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* Transition — adds CSS enter/leave animation classes to a single child,
|
|
892
|
+
* controlled by a reactive `show` accessor.
|
|
893
|
+
*
|
|
894
|
+
* Wraps `@pyreon/runtime-dom`'s Transition. Vue's class-name conventions
|
|
895
|
+
* (`enter-from-class`, `enter-active-class`, …) are mapped onto Pyreon's
|
|
896
|
+
* (`enterFrom`, `enterActive`, …), and Vue's `@before-enter` / `@after-enter`
|
|
897
|
+
* style hooks are mapped onto Pyreon's `onBeforeEnter` / `onAfterEnter`.
|
|
898
|
+
*
|
|
899
|
+
* LIMITATIONS vs Vue 3:
|
|
900
|
+
* - Vue's `<Transition>` infers visibility from a `v-if` / `v-show` on its
|
|
901
|
+
* child. Pyreon has no template directives, so you MUST pass an explicit
|
|
902
|
+
* `show: () => boolean` accessor. Without it the child is shown
|
|
903
|
+
* unconditionally (no enter/leave is ever triggered).
|
|
904
|
+
* - `mode` ("out-in" / "in-out"), `css: false`, and JS-only hook-driven
|
|
905
|
+
* transitions are NOT supported — Pyreon's Transition is CSS-class based.
|
|
906
|
+
* The props are accepted for typechecking but ignored.
|
|
907
|
+
* - The Vue `name` convention (`name="fade"` → `fade-enter-from` …) is
|
|
908
|
+
* preserved 1:1 (Pyreon uses the identical class-name scheme).
|
|
909
|
+
*
|
|
910
|
+
* @example
|
|
911
|
+
* import { Transition, ref } from "@pyreon/vue-compat"
|
|
912
|
+
*
|
|
913
|
+
* function App() {
|
|
914
|
+
* const visible = ref(false)
|
|
915
|
+
* return (
|
|
916
|
+
* <Transition name="fade" show={() => visible.value}>
|
|
917
|
+
* <div class="modal">Hello</div>
|
|
918
|
+
* </Transition>
|
|
919
|
+
* )
|
|
920
|
+
* }
|
|
921
|
+
* // CSS:
|
|
922
|
+
* // .fade-enter-from, .fade-leave-to { opacity: 0; }
|
|
923
|
+
* // .fade-enter-active, .fade-leave-active { transition: opacity 300ms; }
|
|
924
|
+
*/
|
|
925
|
+
function Transition(props) {
|
|
926
|
+
return Transition$1({
|
|
927
|
+
show: props.show ?? (() => true),
|
|
928
|
+
...props.name !== void 0 ? { name: props.name } : {},
|
|
929
|
+
...props.appear !== void 0 ? { appear: props.appear } : {},
|
|
930
|
+
...props.enterFromClass !== void 0 ? { enterFrom: props.enterFromClass } : {},
|
|
931
|
+
...props.enterActiveClass !== void 0 ? { enterActive: props.enterActiveClass } : {},
|
|
932
|
+
...props.enterToClass !== void 0 ? { enterTo: props.enterToClass } : {},
|
|
933
|
+
...props.leaveFromClass !== void 0 ? { leaveFrom: props.leaveFromClass } : {},
|
|
934
|
+
...props.leaveActiveClass !== void 0 ? { leaveActive: props.leaveActiveClass } : {},
|
|
935
|
+
...props.leaveToClass !== void 0 ? { leaveTo: props.leaveToClass } : {},
|
|
936
|
+
...props.onBeforeEnter !== void 0 ? { onBeforeEnter: props.onBeforeEnter } : {},
|
|
937
|
+
...props.onAfterEnter !== void 0 ? { onAfterEnter: props.onAfterEnter } : {},
|
|
938
|
+
...props.onBeforeLeave !== void 0 ? { onBeforeLeave: props.onBeforeLeave } : {},
|
|
939
|
+
...props.onAfterLeave !== void 0 ? { onAfterLeave: props.onAfterLeave } : {},
|
|
940
|
+
children: props.children ?? null
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* TransitionGroup — animates a keyed reactive list with CSS enter/leave plus
|
|
945
|
+
* FLIP move animations.
|
|
946
|
+
*
|
|
947
|
+
* Wraps `@pyreon/runtime-dom`'s TransitionGroup. Vue's class-name props are
|
|
948
|
+
* mapped onto Pyreon's, same as {@link Transition}.
|
|
949
|
+
*
|
|
950
|
+
* LIMITATIONS vs Vue 3:
|
|
951
|
+
* - Vue's `<TransitionGroup>` renders its children via slots and reads keys
|
|
952
|
+
* from the child VNode `key`. Pyreon's API is explicit: pass `items`
|
|
953
|
+
* (a reactive accessor), `keyFn` (stable key extractor), and `render`
|
|
954
|
+
* (returns one DOM-element VNode per item). This is the faithful Pyreon
|
|
955
|
+
* shape — the animation behavior (enter/leave/FLIP-move) is identical.
|
|
956
|
+
* - `mode` and `css: false` are NOT supported (CSS-class transitions only).
|
|
957
|
+
*
|
|
958
|
+
* @example
|
|
959
|
+
* import { TransitionGroup, ref } from "@pyreon/vue-compat"
|
|
960
|
+
*
|
|
961
|
+
* function App() {
|
|
962
|
+
* const items = ref([{ id: 1 }, { id: 2 }])
|
|
963
|
+
* return (
|
|
964
|
+
* <TransitionGroup
|
|
965
|
+
* tag="ul"
|
|
966
|
+
* name="list"
|
|
967
|
+
* items={() => items.value}
|
|
968
|
+
* keyFn={(it) => it.id}
|
|
969
|
+
* render={(it) => <li class="item">{it.id}</li>}
|
|
970
|
+
* />
|
|
971
|
+
* )
|
|
972
|
+
* }
|
|
973
|
+
*/
|
|
974
|
+
function TransitionGroup(props) {
|
|
975
|
+
return TransitionGroup$1({
|
|
976
|
+
items: props.items,
|
|
977
|
+
keyFn: props.keyFn,
|
|
978
|
+
render: props.render,
|
|
979
|
+
...props.tag !== void 0 ? { tag: props.tag } : {},
|
|
980
|
+
...props.name !== void 0 ? { name: props.name } : {},
|
|
981
|
+
...props.appear !== void 0 ? { appear: props.appear } : {},
|
|
982
|
+
...props.enterFromClass !== void 0 ? { enterFrom: props.enterFromClass } : {},
|
|
983
|
+
...props.enterActiveClass !== void 0 ? { enterActive: props.enterActiveClass } : {},
|
|
984
|
+
...props.enterToClass !== void 0 ? { enterTo: props.enterToClass } : {},
|
|
985
|
+
...props.leaveFromClass !== void 0 ? { leaveFrom: props.leaveFromClass } : {},
|
|
986
|
+
...props.leaveActiveClass !== void 0 ? { leaveActive: props.leaveActiveClass } : {},
|
|
987
|
+
...props.leaveToClass !== void 0 ? { leaveTo: props.leaveToClass } : {},
|
|
988
|
+
...props.moveClass !== void 0 ? { moveClass: props.moveClass } : {},
|
|
989
|
+
...props.onBeforeEnter !== void 0 ? { onBeforeEnter: props.onBeforeEnter } : {},
|
|
990
|
+
...props.onAfterEnter !== void 0 ? { onAfterEnter: props.onAfterEnter } : {},
|
|
991
|
+
...props.onBeforeLeave !== void 0 ? { onBeforeLeave: props.onBeforeLeave } : {},
|
|
992
|
+
...props.onAfterLeave !== void 0 ? { onAfterLeave: props.onAfterLeave } : {}
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* Suspense — shows `fallback` content while an async (lazy) child is loading.
|
|
997
|
+
*
|
|
998
|
+
* Re-exports `@pyreon/core`'s Suspense. Vue 3's `<Suspense>` uses named
|
|
999
|
+
* `#default` / `#fallback` slots; this maps the `fallback` slot to Pyreon
|
|
1000
|
+
* Suspense's `fallback` prop and the default slot to `children`.
|
|
1001
|
+
*
|
|
1002
|
+
* LIMITATIONS vs Vue 3:
|
|
1003
|
+
* - Vue resolves `<Suspense>` against any `async setup()` in the subtree and
|
|
1004
|
+
* supports `@resolve` / `@pending` / `@fallback` events plus the `timeout`
|
|
1005
|
+
* prop. Pyreon's Suspense resolves against components carrying a
|
|
1006
|
+
* `__loading` accessor (e.g. {@link defineAsyncComponent} output) and does
|
|
1007
|
+
* not emit those events. The events / `timeout` prop are accepted for
|
|
1008
|
+
* typechecking but ignored.
|
|
1009
|
+
*
|
|
1010
|
+
* @example
|
|
1011
|
+
* import { Suspense, defineAsyncComponent } from "@pyreon/vue-compat"
|
|
1012
|
+
*
|
|
1013
|
+
* const AsyncPage = defineAsyncComponent(() => import("./Page"))
|
|
1014
|
+
*
|
|
1015
|
+
* function App() {
|
|
1016
|
+
* return (
|
|
1017
|
+
* <Suspense fallback={<div>Loading…</div>}>
|
|
1018
|
+
* <AsyncPage />
|
|
1019
|
+
* </Suspense>
|
|
1020
|
+
* )
|
|
1021
|
+
* }
|
|
1022
|
+
*/
|
|
1023
|
+
function Suspense(props) {
|
|
1024
|
+
return Suspense$1({
|
|
1025
|
+
fallback: props.fallback ?? null,
|
|
1026
|
+
children: props.children ?? null
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
let _instanceUid = 0;
|
|
1030
|
+
/**
|
|
1031
|
+
* Returns a handle to the current component instance, or `null` if called
|
|
1032
|
+
* outside a component setup.
|
|
1033
|
+
*
|
|
1034
|
+
* Vue 3's `getCurrentInstance()` is an internal API many composable libraries
|
|
1035
|
+
* (vee-validate, vue-i18n, pinia plugins, …) read for `uid`, `proxy`, `slots`,
|
|
1036
|
+
* `attrs`. This shim returns a minimal stable object with those fields so such
|
|
1037
|
+
* libraries don't crash.
|
|
1038
|
+
*
|
|
1039
|
+
* LIMITATIONS vs Vue 3:
|
|
1040
|
+
* - `proxy` is an empty object — Pyreon components are plain functions with
|
|
1041
|
+
* no `this`-bound Options instance. Code that reads reactive state off
|
|
1042
|
+
* `instance.proxy.$data` / `.$props` will not work; use `props` directly.
|
|
1043
|
+
* - `instance.emit(event, ...args)` IS provided (invokes the matching
|
|
1044
|
+
* `on{Event}` prop handler). `instance.attrs` is the fallthrough split
|
|
1045
|
+
* (declared props excluded) when the component used `defineComponent({
|
|
1046
|
+
* props })`; otherwise it is the full props object.
|
|
1047
|
+
* - `appContext`, `parent`, `vnode`, `expose`, render internals are NOT
|
|
1048
|
+
* provided. Libraries that walk the parent chain are not supported.
|
|
1049
|
+
* - The same `uid` is stable across re-renders of the same instance
|
|
1050
|
+
* (hook-indexed), matching Vue's per-instance-id guarantee.
|
|
1051
|
+
*
|
|
1052
|
+
* @example
|
|
1053
|
+
* import { getCurrentInstance } from "@pyreon/vue-compat"
|
|
1054
|
+
*
|
|
1055
|
+
* function useUid() {
|
|
1056
|
+
* const inst = getCurrentInstance()
|
|
1057
|
+
* return inst ? inst.uid : -1
|
|
1058
|
+
* }
|
|
1059
|
+
*/
|
|
1060
|
+
function getCurrentInstance() {
|
|
1061
|
+
const ctx = getCurrentCtx();
|
|
1062
|
+
if (!ctx) return null;
|
|
1063
|
+
const idx = getHookIndex();
|
|
1064
|
+
if (idx < ctx.hooks.length) return ctx.hooks[idx];
|
|
1065
|
+
const props = ctx._props ?? {};
|
|
1066
|
+
const children = props.children;
|
|
1067
|
+
const instance = {
|
|
1068
|
+
uid: _instanceUid++,
|
|
1069
|
+
proxy: {},
|
|
1070
|
+
slots: { default: children !== void 0 ? () => children : void 0 },
|
|
1071
|
+
attrs: splitVueAttrs(props, ctx._declaredProps),
|
|
1072
|
+
emit: (event, ...args) => {
|
|
1073
|
+
const handler = props[`on${event.charAt(0).toUpperCase()}${event.slice(1)}`];
|
|
1074
|
+
if (typeof handler === "function") handler(...args);
|
|
1075
|
+
},
|
|
1076
|
+
isMounted: true,
|
|
1077
|
+
_ctx: ctx
|
|
1078
|
+
};
|
|
1079
|
+
ctx.hooks[idx] = instance;
|
|
1080
|
+
return instance;
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Returns the current component's slots — a map of slot-name → render
|
|
1084
|
+
* function. Only the `default` slot is populated (derived from `children`),
|
|
1085
|
+
* matching how `@pyreon/vue-compat` models slots elsewhere
|
|
1086
|
+
* ({@link defineComponent}'s setup context).
|
|
1087
|
+
*
|
|
1088
|
+
* LIMITATIONS vs Vue 3:
|
|
1089
|
+
* - Vue supports arbitrary named + scoped slots resolved from the parent
|
|
1090
|
+
* template. Pyreon passes a single `children` payload, so only
|
|
1091
|
+
* `slots.default` is available. Named/scoped slots are not modeled.
|
|
1092
|
+
* - Returns an empty object (no `default`) when there are no children or
|
|
1093
|
+
* when called outside a component.
|
|
1094
|
+
*
|
|
1095
|
+
* @example
|
|
1096
|
+
* import { useSlots } from "@pyreon/vue-compat"
|
|
1097
|
+
*
|
|
1098
|
+
* function Wrapper() {
|
|
1099
|
+
* const slots = useSlots()
|
|
1100
|
+
* return <div class="box">{slots.default?.()}</div>
|
|
1101
|
+
* }
|
|
1102
|
+
*/
|
|
1103
|
+
function useSlots() {
|
|
1104
|
+
const ctx = getCurrentCtx();
|
|
1105
|
+
if (!ctx) return {};
|
|
1106
|
+
const children = (ctx._props ?? {}).children;
|
|
1107
|
+
if (children === void 0) return {};
|
|
1108
|
+
return { default: () => children };
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Returns the current component's non-prop attributes.
|
|
1112
|
+
*
|
|
1113
|
+
* In Vue, `useAttrs()` is the fallthrough attributes NOT declared in `props`.
|
|
1114
|
+
* `@pyreon/vue-compat` does not do declared-prop separation (components are
|
|
1115
|
+
* plain functions receiving one `props` object), so this returns the full
|
|
1116
|
+
* props object — every consumer-supplied attribute is present.
|
|
1117
|
+
*
|
|
1118
|
+
* LIMITATIONS vs Vue 3:
|
|
1119
|
+
* - No declared-vs-fallthrough split: `useAttrs()` here === the full props
|
|
1120
|
+
* object (including any that Vue would have consumed as declared props).
|
|
1121
|
+
* Read the specific keys you need; don't assume the result excludes
|
|
1122
|
+
* declared props.
|
|
1123
|
+
* - Returns an empty object when called outside a component.
|
|
1124
|
+
*
|
|
1125
|
+
* @example
|
|
1126
|
+
* import { useAttrs } from "@pyreon/vue-compat"
|
|
1127
|
+
*
|
|
1128
|
+
* function Passthrough() {
|
|
1129
|
+
* const attrs = useAttrs()
|
|
1130
|
+
* return <input {...attrs} />
|
|
1131
|
+
* }
|
|
1132
|
+
*/
|
|
1133
|
+
function useAttrs() {
|
|
1134
|
+
const ctx = getCurrentCtx();
|
|
1135
|
+
if (!ctx) return {};
|
|
1136
|
+
return splitVueAttrs(ctx._props ?? {}, ctx._declaredProps);
|
|
839
1137
|
}
|
|
840
1138
|
/**
|
|
841
1139
|
* Runs a watchEffect that flushes after DOM updates.
|
|
@@ -876,5 +1174,5 @@ function customRef(factory) {
|
|
|
876
1174
|
const version = "3.5.0-pyreon";
|
|
877
1175
|
|
|
878
1176
|
//#endregion
|
|
879
|
-
export { Fragment, KeepAlive, Teleport, batch, computed, createApp, customRef, defineAsyncComponent, defineComponent, effectScope, getCurrentScope, pyreonH as h, inject, isProxy, isReactive, isReadonly, isRef, markRaw, nextTick, onBeforeMount, onBeforeUnmount, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onUnmounted, onUpdated, provide, reactive, readonly, ref, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, toValue, triggerRef, unref, version, watch, watchEffect, watchPostEffect, watchSyncEffect };
|
|
1177
|
+
export { Fragment, KeepAlive, Suspense, Teleport, Transition, TransitionGroup, batch, computed, createApp, customRef, defineAsyncComponent, defineComponent, effectScope, getCurrentInstance, getCurrentScope, pyreonH as h, inject, isProxy, isReactive, isReadonly, isRef, markRaw, nextTick, onBeforeMount, onBeforeUnmount, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onUnmounted, onUpdated, provide, reactive, readonly, ref, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, toValue, triggerRef, unref, useAttrs, useSlots, version, watch, watchEffect, watchPostEffect, watchSyncEffect };
|
|
880
1178
|
//# sourceMappingURL=index.js.map
|
package/lib/jsx-runtime.js
CHANGED