@piying/view-vue2-legacy 2.4.1 → 2.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,12 @@
1
1
  import * as v from 'valibot';
2
+ import type { Injector } from 'static-injector';
2
3
  type __VLS_Props = {
3
4
  schema: v.BaseSchema<any, any, any> | v.SchemaWithPipe<any>;
4
5
  modelValue?: any;
5
- options: any;
6
+ options: {
7
+ injector?: Injector;
8
+ [name: string]: any;
9
+ };
6
10
  };
7
11
  declare const __VLS_export: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
8
12
  "update:modelValue": (...args: any[]) => void;
package/index.js CHANGED
@@ -6796,7 +6796,7 @@ function signalToRef(value) {
6796
6796
  dataRef.value = currentValue;
6797
6797
  }
6798
6798
  },
6799
- { injector }
6799
+ { injector: injector.value }
6800
6800
  );
6801
6801
  onWatcherCleanup(() => {
6802
6802
  ref2.destroy();
@@ -6918,11 +6918,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
6918
6918
  const isControl = isFieldControl(field.value.form.control);
6919
6919
  let dispose;
6920
6920
  watch(
6921
- [childRef, field],
6922
- ([childRef2, field2]) => {
6921
+ [childRef, field, injector],
6922
+ ([childRef2, field2, injector2]) => {
6923
6923
  dispose?.();
6924
6924
  if (isControl && childRef2) {
6925
- dispose = createViewControlLink((() => field2.form.control), childRef2["cva"], injector);
6925
+ dispose = createViewControlLink((() => field2.form.control), childRef2["cva"], injector2);
6926
6926
  }
6927
6927
  },
6928
6928
  { immediate: true }
@@ -6945,7 +6945,7 @@ var __component__$2 = /* @__PURE__ */ normalizeComponent(
6945
6945
  _sfc_staticRenderFns$2,
6946
6946
  false,
6947
6947
  null,
6948
- "ed62cd7c"
6948
+ "97958aee"
6949
6949
  );
6950
6950
  const FieldTemplate = __component__$2.exports;
6951
6951
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
@@ -6958,13 +6958,15 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
6958
6958
  emits: ["update:modelValue"],
6959
6959
  setup(__props, { emit }) {
6960
6960
  const inputs = __props;
6961
- const rootInjector = createRootInjector({
6962
- providers: [
6963
- {
6964
- provide: ChangeDetectionScheduler,
6965
- useClass: ChangeDetectionSchedulerImpl
6966
- }
6967
- ]
6961
+ const rootInjector = computed(() => {
6962
+ return inputs.options.injector ?? inject(PI_VIEW_FIELD_TOKEN, void 0)?.value.injector ?? createRootInjector({
6963
+ providers: [
6964
+ {
6965
+ provide: ChangeDetectionScheduler,
6966
+ useClass: ChangeDetectionSchedulerImpl
6967
+ }
6968
+ ]
6969
+ });
6968
6970
  });
6969
6971
  provide(InjectorToken, rootInjector);
6970
6972
  provide(
@@ -6982,16 +6984,16 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
6982
6984
  let injectorDispose;
6983
6985
  const initResult = computed(() => {
6984
6986
  injectorDispose?.();
6985
- const subInjector = createInjector({ providers: [], parent: rootInjector });
6987
+ const subInjector = createInjector({ providers: [], parent: rootInjector.value });
6986
6988
  injectorDispose = () => {
6987
6989
  subInjector.destroy();
6988
6990
  injectorDispose = void 0;
6989
6991
  };
6990
6992
  const field2 = convert(inputs.schema, {
6993
+ ...inputs.options,
6991
6994
  handle: VueSchemaHandle,
6992
6995
  builder: VueFormBuilder,
6993
- injector: subInjector,
6994
- ...inputs.options
6996
+ injector: subInjector
6995
6997
  });
6996
6998
  return [field2, subInjector];
6997
6999
  });
@@ -7033,7 +7035,7 @@ var __component__$1 = /* @__PURE__ */ normalizeComponent(
7033
7035
  _sfc_staticRenderFns$1,
7034
7036
  false,
7035
7037
  null,
7036
- "d4636b16"
7038
+ "73b707a5"
7037
7039
  );
7038
7040
  const piyingView = __component__$1.exports;
7039
7041
  function useControlValueAccessor(autoChange = true) {