@piying/view-svelte 1.4.0 → 1.4.1

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/builder.js CHANGED
@@ -1,24 +1,3 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
1
  import { FormBuilder } from '@piying/view-core';
17
- var SvelteFormBuilder = /** @class */ (function (_super) {
18
- __extends(SvelteFormBuilder, _super);
19
- function SvelteFormBuilder() {
20
- return _super !== null && _super.apply(this, arguments) || this;
21
- }
22
- return SvelteFormBuilder;
23
- }(FormBuilder));
24
- export { SvelteFormBuilder };
2
+ export class SvelteFormBuilder extends FormBuilder {
3
+ }
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import type { PiResolvedViewFieldConfig } from '../type/group';
3
- import { signalToRef } from '../util/signal-convert.svelte';
3
+ import { signalToState } from '../util/signal-convert.svelte';
4
4
  import { PI_VIEW_FIELD_TOKEN, InjectorToken } from '../token';
5
5
  import { createViewControlLink, getLazyImport, isLazyMark } from '@piying/view-core';
6
6
  import { getContext, setContext } from 'svelte';
@@ -10,7 +10,7 @@
10
10
  field: PiResolvedViewFieldConfig;
11
11
  } = $props();
12
12
  const injector = getContext<Injector>(InjectorToken)!;
13
- const fieldInputs = signalToRef(() => {
13
+ const fieldInputs = signalToState(() => {
14
14
  return {
15
15
  ...props.field.attributes(),
16
16
  ...props.field.inputs(),
@@ -19,7 +19,7 @@
19
19
  };
20
20
  });
21
21
  let controlRef = $state<any>();
22
- const renderConfig = signalToRef(() => props.field.renderConfig());
22
+ const renderConfig = signalToState(() => props.field.renderConfig());
23
23
  const control = $derived.by(() => props.field.form.control);
24
24
  $effect.pre(() => {
25
25
  let dispose: (() => any) | undefined;
@@ -31,9 +31,9 @@
31
31
  dispose = undefined;
32
32
  };
33
33
  });
34
- const fieldChildren = signalToRef(() => props.field.children?.());
34
+ const fieldChildren = signalToState(() => props.field.children?.());
35
35
 
36
- const wrappers = signalToRef(() => props.field.wrappers());
36
+ const wrappers = signalToState(() => props.field.wrappers());
37
37
  const ComponentType = $derived.by(() => {
38
38
  return props.field.define?.type;
39
39
  });
@@ -2,10 +2,10 @@
2
2
  import FieldTemplate from './field-template.svelte';
3
3
  import { getContext } from 'svelte';
4
4
  import { PI_VIEW_FIELD_TOKEN } from '../token';
5
- import { signalToRef } from '../util/signal-convert.svelte';
5
+ import { signalToState } from '../util/signal-convert.svelte';
6
6
 
7
7
  const field = getContext<PI_VIEW_FIELD_TOKEN>(PI_VIEW_FIELD_TOKEN);
8
- const children = signalToRef(() => field().children!())!;
8
+ const children = signalToState(() => field().children!())!;
9
9
  </script>
10
10
 
11
11
  {#each children()! as field, i (i)}
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import type { CoreResolvedWrapperConfig } from '@piying/view-core';
3
- import { signalToRef } from '../util/signal-convert.svelte';
3
+ import { signalToState } from '../util/signal-convert.svelte';
4
4
  import PiWrapper from './wrapper.svelte';
5
5
  const dProps: {
6
6
  wrappers: CoreResolvedWrapperConfig[];
@@ -8,7 +8,7 @@
8
8
  } = $props();
9
9
  const restWrappers = $derived.by(() => dProps.wrappers!.slice(1));
10
10
  const wrapper = $derived.by(() => dProps.wrappers?.[0]);
11
- const inputs = signalToRef(() => ({
11
+ const inputs = signalToState(() => ({
12
12
  ...wrapper?.inputs(),
13
13
  ...wrapper?.attributes(),
14
14
  ...wrapper?.outputs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piying/view-svelte",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Piying view For Svelte;Valibot to Component",
5
5
  "type": "module",
6
6
  "homepage": "https://piying-org.github.io/website/docs/client/intro",
@@ -34,14 +34,13 @@
34
34
  ],
35
35
  "license": "MIT",
36
36
  "dependencies": {
37
- "@piying/view-core": "^1.4.0",
38
- "fast-equals": "^5.2.2",
39
- "static-injector": "^6.1.2",
40
- "valibot": "^1.1.0"
37
+ "@piying/view-core": "^1.4.1",
38
+ "static-injector": "^6.1.2"
41
39
  },
42
40
  "sideEffects": false,
43
41
  "peerDependencies": {
44
- "svelte": "^5.0.0"
42
+ "svelte": "^5.0.0",
43
+ "valibot": "^1.1.0"
45
44
  },
46
45
  "module": "index.js",
47
46
  "typings": "index.d.ts",
package/svelte-schema.js CHANGED
@@ -1,24 +1,4 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
1
  import { CoreSchemaHandle } from '@piying/view-core';
17
- var SvelteSchemaHandle = /** @class */ (function (_super) {
18
- __extends(SvelteSchemaHandle, _super);
19
- function SvelteSchemaHandle() {
20
- return _super !== null && _super.apply(this, arguments) || this;
21
- }
22
- return SvelteSchemaHandle;
23
- }(CoreSchemaHandle));
24
- export { SvelteSchemaHandle };
2
+ export class SvelteSchemaHandle extends CoreSchemaHandle {
3
+ contents;
4
+ }
package/token.js CHANGED
@@ -1,2 +1,2 @@
1
- export var InjectorToken = Symbol();
2
- export var PI_VIEW_FIELD_TOKEN = Symbol();
1
+ export const InjectorToken = Symbol();
2
+ export const PI_VIEW_FIELD_TOKEN = Symbol();
@@ -1 +1 @@
1
- export declare function signalToRef<T>(value: () => T | undefined): () => T;
1
+ export declare function signalToState<T>(value: () => T | undefined): () => T | undefined;
@@ -1,20 +1,20 @@
1
- import { effect } from 'static-injector';
1
+ import { effect, Injector } from 'static-injector';
2
2
  import { InjectorToken } from '../token';
3
3
  import { getContext } from 'svelte';
4
- export function signalToRef(value) {
5
- var injector = getContext(InjectorToken);
6
- var dataRef = $state.raw(undefined);
7
- $effect.pre(function () {
4
+ export function signalToState(value) {
5
+ const injector = getContext(InjectorToken);
6
+ let dataRef = $state.raw(undefined);
7
+ $effect.pre(() => {
8
8
  dataRef = value();
9
- var ref = effect(function () {
10
- var currentValue = value();
9
+ const ref = effect(() => {
10
+ const currentValue = value();
11
11
  if (!Object.is(dataRef, currentValue)) {
12
12
  dataRef = currentValue;
13
13
  }
14
14
  }, { injector: injector });
15
- return function () {
15
+ return () => {
16
16
  ref.destroy();
17
17
  };
18
18
  });
19
- return function () { return dataRef; };
19
+ return () => dataRef;
20
20
  }
@@ -1,3 +1,4 @@
1
+ import type { ControlValueAccessor } from '@piying/view-core';
1
2
  export declare function useControlValueAccessor(): {
2
3
  cva: ControlValueAccessor;
3
4
  cvaa: {
@@ -1,19 +1,19 @@
1
1
  export function useControlValueAccessor() {
2
- var value = $state();
3
- var disabled = $state(false);
4
- var onChange;
5
- var touched;
6
- var instance = {
7
- writeValue: function (obj) {
2
+ let value = $state();
3
+ let disabled = $state(false);
4
+ let onChange;
5
+ let touched;
6
+ const instance = {
7
+ writeValue(obj) {
8
8
  value = obj;
9
9
  },
10
- registerOnChange: function (fn) {
10
+ registerOnChange(fn) {
11
11
  onChange = fn;
12
12
  },
13
- registerOnTouched: function (fn) {
13
+ registerOnTouched(fn) {
14
14
  touched = fn;
15
15
  },
16
- setDisabledState: function (value) {
16
+ setDisabledState(value) {
17
17
  disabled = value;
18
18
  }
19
19
  };
@@ -26,11 +26,11 @@ export function useControlValueAccessor() {
26
26
  get disabled() {
27
27
  return disabled;
28
28
  },
29
- valueChange: function (input) {
30
- onChange === null || onChange === void 0 ? void 0 : onChange(input);
29
+ valueChange: (input) => {
30
+ onChange?.(input);
31
31
  value = input;
32
32
  },
33
- touchedChange: function () {
33
+ touchedChange: () => {
34
34
  touched();
35
35
  }
36
36
  }