@piying/view-react 1.0.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/builder.d.ts +4 -0
- package/component/field-template.d.ts +6 -0
- package/component/group.d.ts +5 -0
- package/component/index.d.ts +4 -0
- package/component/view.d.ts +8 -0
- package/component/wrapper.d.ts +6 -0
- package/const.d.ts +10 -0
- package/index.cjs +22 -0
- package/index.d.ts +8 -0
- package/index.js +523 -0
- package/package.json +29 -0
- package/schema-handle.d.ts +7 -0
- package/token.d.ts +4 -0
- package/type/group.d.ts +40 -0
- package/type/index.d.ts +1 -0
- package/use-model/index.d.ts +6 -0
- package/use-model/use-checkbox-model.d.ts +7 -0
- package/use-model/use-number-model.d.ts +7 -0
- package/use-model/use-radio-model.d.ts +8 -0
- package/use-model/use-range-model.d.ts +8 -0
- package/use-model/use-select-model.d.ts +7 -0
- package/use-model/use-text-model.d.ts +13 -0
- package/util/index.d.ts +4 -0
- package/util/init-listen.d.ts +3 -0
- package/util/signal-convert.d.ts +1 -0
- package/util/use-control-value-accessor.d.ts +11 -0
- package/util/use-effect-sync.d.ts +1 -0
package/builder.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PiResolvedViewFieldConfig } from '../type';
|
|
2
|
+
export interface PiyingFieldTemplateProps {
|
|
3
|
+
field: PiResolvedViewFieldConfig;
|
|
4
|
+
}
|
|
5
|
+
export declare const CVA: unique symbol;
|
|
6
|
+
export declare function PiyingFieldTemplate(props: PiyingFieldTemplateProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
export interface PiyingViewProps {
|
|
3
|
+
schema: v.BaseSchema<any, any, any> | v.SchemaWithPipe<any>;
|
|
4
|
+
model?: any;
|
|
5
|
+
modelChange?: (value: any) => void;
|
|
6
|
+
options: any;
|
|
7
|
+
}
|
|
8
|
+
export declare function PiyingView(props: PiyingViewProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CoreResolvedWrapperConfig } from '@piying/view-core';
|
|
2
|
+
export interface PiyingWrapperProps {
|
|
3
|
+
wrappers: CoreResolvedWrapperConfig[];
|
|
4
|
+
children: any;
|
|
5
|
+
}
|
|
6
|
+
export declare function PiyingWrapper(props: PiyingWrapperProps): import("react/jsx-runtime").JSX.Element;
|
package/const.d.ts
ADDED
package/index.cjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react"),C=require("static-injector"),w=require("@piying/view-core");require("valibot");const be=require("fast-equals");var P={exports:{}},k={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Z;function Ee(){if(Z)return k;Z=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(u,o,i){var l=null;if(i!==void 0&&(l=""+i),o.key!==void 0&&(l=""+o.key),"key"in o){i={};for(var g in o)g!=="key"&&(i[g]=o[g])}else i=o;return o=i.ref,{$$typeof:e,type:u,key:l,ref:o!==void 0?o:null,props:i}}return k.Fragment=t,k.jsx=n,k.jsxs=n,k}var y={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var Q;function ge(){return Q||(Q=1,process.env.NODE_ENV!=="production"&&function(){function e(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===de?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case v:return"Fragment";case d:return"Profiler";case M:return"StrictMode";case ae:return"Suspense";case ie:return"SuspenseList";case ce:return"Activity"}if(typeof r=="object")switch(typeof r.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),r.$$typeof){case O:return"Portal";case ue:return(r.displayName||"Context")+".Provider";case N:return(r._context.displayName||"Context")+".Consumer";case se:var s=r.render;return r=r.displayName,r||(r=s.displayName||s.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case le:return s=r.displayName||null,s!==null?s:e(r.type)||"Memo";case q:s=r._payload,r=r._init;try{return e(r(s))}catch{}}return null}function t(r){return""+r}function n(r){try{t(r);var s=!1}catch{s=!0}if(s){s=console;var c=s.error,m=typeof Symbol=="function"&&Symbol.toStringTag&&r[Symbol.toStringTag]||r.constructor.name||"Object";return c.call(s,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",m),t(r)}}function u(r){if(r===v)return"<>";if(typeof r=="object"&&r!==null&&r.$$typeof===q)return"<...>";try{var s=e(r);return s?"<"+s+">":"<...>"}catch{return"<...>"}}function o(){var r=F.A;return r===null?null:r.getOwner()}function i(){return Error("react-stack-top-frame")}function l(r){if(U.call(r,"key")){var s=Object.getOwnPropertyDescriptor(r,"key").get;if(s&&s.isReactWarning)return!1}return r.key!==void 0}function g(r,s){function c(){B||(B=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",s))}c.isReactWarning=!0,Object.defineProperty(r,"key",{get:c,configurable:!0})}function R(){var r=e(this.type);return J[r]||(J[r]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),r=this.props.ref,r!==void 0?r:null}function E(r,s,c,m,T,p,D,V){return c=p.ref,r={$$typeof:A,type:r,key:s,props:p,_owner:T},(c!==void 0?c:null)!==null?Object.defineProperty(r,"ref",{enumerable:!1,get:R}):Object.defineProperty(r,"ref",{enumerable:!1,value:null}),r._store={},Object.defineProperty(r._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(r,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(r,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:D}),Object.defineProperty(r,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:V}),Object.freeze&&(Object.freeze(r.props),Object.freeze(r)),r}function j(r,s,c,m,T,p,D,V){var b=s.children;if(b!==void 0)if(m)if(fe(b)){for(m=0;m<b.length;m++)S(b[m]);Object.freeze&&Object.freeze(b)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else S(b);if(U.call(s,"key")){b=e(r);var x=Object.keys(s).filter(function(me){return me!=="key"});m=0<x.length?"{key: someKey, "+x.join(": ..., ")+": ...}":"{key: someKey}",X[b+m]||(x=0<x.length?"{"+x.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
+
let props = %s;
|
|
19
|
+
<%s {...props} />
|
|
20
|
+
React keys must be passed directly to JSX without using spread:
|
|
21
|
+
let props = %s;
|
|
22
|
+
<%s key={someKey} {...props} />`,m,b,x,b),X[b+m]=!0)}if(b=null,c!==void 0&&(n(c),b=""+c),l(s)&&(n(s.key),b=""+s.key),"key"in s){c={};for(var G in s)G!=="key"&&(c[G]=s[G])}else c=s;return b&&g(c,typeof r=="function"?r.displayName||r.name||"Unknown":r),E(r,b,p,T,o(),c,D,V)}function S(r){typeof r=="object"&&r!==null&&r.$$typeof===A&&r._store&&(r._store.validated=1)}var h=a,A=Symbol.for("react.transitional.element"),O=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),ue=Symbol.for("react.context"),se=Symbol.for("react.forward_ref"),ae=Symbol.for("react.suspense"),ie=Symbol.for("react.suspense_list"),le=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),ce=Symbol.for("react.activity"),de=Symbol.for("react.client.reference"),F=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=Object.prototype.hasOwnProperty,fe=Array.isArray,Y=console.createTask?console.createTask:function(){return null};h={"react-stack-bottom-frame":function(r){return r()}};var B,J={},z=h["react-stack-bottom-frame"].bind(h,i)(),H=Y(u(i)),X={};y.Fragment=v,y.jsx=function(r,s,c,m,T){var p=1e4>F.recentlyCreatedOwnerStacks++;return j(r,s,c,!1,m,T,p?Error("react-stack-top-frame"):z,p?Y(u(r)):H)},y.jsxs=function(r,s,c,m,T){var p=1e4>F.recentlyCreatedOwnerStacks++;return j(r,s,c,!0,m,T,p?Error("react-stack-top-frame"):z,p?Y(u(r)):H)}}()),y}var K;function he(){return K||(K=1,process.env.NODE_ENV==="production"?P.exports=Ee():P.exports=ge()),P.exports}var f=he();const ee=a.createContext(void 0),I=a.createContext(void 0);function _(e,t){const n=a.useContext(I),[u,o]=a.useState(a.useMemo(()=>t(e),[])),i=a.useRef(u);return a.useEffect(()=>{const l=t(e);Object.is(i.current,l)||(o(l),i.current=l);const g=C.effect(()=>{const R=t(e);Object.is(i.current,R)||(o(R),i.current=R)},{injector:n});return()=>{g.destroy()}},[e,a.useMemo(()=>t,[])]),u}function $(e){const t=a.useMemo(()=>e.wrappers.slice(1),[e.wrappers]),n=e.wrappers[0],u=_(n,()=>({...n?.inputs(),...n?.attributes(),...n?.outputs}));return f.jsx(f.Fragment,{children:n?f.jsx(n.type,{...u,children:f.jsx($,{wrappers:t,children:e.children})}):e.children})}const re=Symbol.for("ControlValueAccessor");function W(e){const t=_(e.field,d=>d.inputs()),n=_(e.field,d=>d.outputs()),u=_(e.field,d=>d.renderConfig()),o=_(e.field,d=>d.attributes()),i=a.useMemo(()=>({...t,fields:e.field.fieldGroup?.()}),[t,e.field.fieldGroup]),l=a.useMemo(()=>({...t,fields:e.field.fieldArray?.()}),[t,e.field.fieldArray]),g=_(e.field,d=>d.wrappers()),R=_(e.field,d=>d.fieldGroup?.()),E=_(e.field,d=>d.fieldArray?.()),j=a.useMemo(()=>({...o,...t,...n}),[o,t,n]),S=e.field.form.control,h=e.field.define?.type,A=a.useMemo(()=>!!u.hidden||!h,[u.hidden,h]),O=a.useContext(I),v=a.useRef(void 0),M=a.useMemo(()=>({...j,[re]:v}),[j,v]);return a.useEffect(()=>{let d;return v.current&&(d=w.createViewControlLink(()=>S,v.current,O)),()=>{d?.forEach(N=>N()),d=void 0}},[v.current,S,O]),f.jsx(f.Fragment,{children:f.jsx(ee,{value:e.field,children:A?void 0:f.jsx($,{wrappers:g,children:R?f.jsx(h,{...i}):E?f.jsx(h,{...l}):e.field.form.control?f.jsx(h,{...M}):f.jsx(h,{...j})})})})}function Re(e){return f.jsx(f.Fragment,{children:e.fields.map((t,n)=>f.jsx(W,{field:t},n))})}class te extends w.CoreSchemaHandle{}class ne extends w.FormBuilder{}function oe(e,t,n,u){let o=!0;return C.effect(()=>{const i=t.value$$();o?(be.deepEqual(i,e)||u(i),o=!1):u(i)},{injector:n})}function L(e,t){const n=a.useCallback(e,t),u=a.useRef(void 0);a.useMemo(()=>(u.current=n(),u.current),t),a.useEffect(()=>()=>{u.current?.(),u.current=void 0},[])}function pe(e){const t=a.useMemo(()=>C.createRootInjector({providers:[{provide:C.ChangeDetectionScheduler,useClass:C.ChangeDetectionSchedulerImpl}]}),[]),[n,u]=a.useMemo(()=>{const o=C.createInjector({providers:[],parent:t});return[w.convert(e.schema,{handle:te,builder:ne,injector:o,registerOnDestroy:l=>{o.get(C.DestroyRef).onDestroy(l)},...e.options}),o]},[e.schema,e.options]);return L(()=>{let o;if(n.form.control){const i=e.model;o=oe(typeof i<"u"?i:void 0,n.form.control,u,l=>{C.untracked(()=>{n.form.control?.valueNoError$$()&&e.modelChange?.(l)})})}return()=>{u.destroy(),o?.destroy()}},[n]),L(()=>{n.form.control?.updateValue(e.model)},[n,e.model]),f.jsx(f.Fragment,{children:f.jsx(I,{value:t,children:f.jsx(W,{field:n})})})}const ve=[],_e={directives:"merge",formConfig:"merge",inputs:"merge",outputs:"merge",props:"merge",renderConfig:"merge",wrappers:"replace"};function Te(e,t){const n=a.useRef(!1);return a.useMemo(()=>{const u={value:e.value,disabled:e.disabled,onBlur:e.touchedChange};return t?{...u,onCompositionStart:()=>{n.current=!0},onCompositionEnd:o=>{n.current=!1,e.valueChange(o.target.value)}}:{...u,onInput:o=>e.valueChange(o.target.value)}},[e,t])}function Ce(e){return a.useMemo(()=>({checked:e.value,disabled:e.disabled,onBlur:e.touchedChange,onChange:t=>e.valueChange(t.target.checked)}),[e])}function je(e){return a.useMemo(()=>({value:e.value,disabled:e.disabled,onBlur:e.touchedChange,onInput:t=>{const n=t.target.value;e.valueChange(n==""?void 0:parseFloat(n))}}),[e])}function xe(e,t){return a.useMemo(()=>({value:t,checked:Object.is(e.value,t),disabled:e.disabled,onBlur:e.touchedChange,onChange:()=>e.valueChange(t)}),[e])}function Se(e){return a.useMemo(()=>{const t=n=>{const u=n.target.value;e.valueChange(u==""?void 0:parseFloat(u))};return{value:e.value,disabled:e.disabled,onBlur:e.touchedChange,onInput:t,onChange:t}},[e])}function ke(e,t=!1){return a.useMemo(()=>({value:e.value,disabled:e.disabled,onBlur:e.touchedChange,onChange:n=>{const u=[],o=n.target;if(o.selectedOptions!==void 0)for(let i=0;i<o.selectedOptions.length;i++){const l=o.selectedOptions[i];if(u.push(l.value),!t)break}else for(let i=0;i<o.options.length;i++){const l=o.options[i];if(l.selected&&(u.push(l.value),!t))break}e.valueChange(t?u:u[0])}}),[e])}function ye(e=void 0){const[t,n]=a.useState(e),[u,o]=a.useState(!1),i=a.useRef(void 0),l=a.useRef(void 0),g=a.useMemo(()=>({writeValue(E){n(E)},registerOnChange(E){i.current=E},registerOnTouched(E){l.current=E},setDisabledState(E){o(E)}}),[]),R=a.useMemo(()=>({value:t,disabled:u,valueChange:E=>{i.current?.(E),n(E)},touchedChange:()=>{l.current?.()}}),[t,u]);return a.useMemo(()=>({cva:g,cvaa:R}),[R])}exports.CVA=re;exports.EMPTY_ARRAY=ve;exports.InjectorToken=I;exports.NG_CONFIG_DEFAULT_MERGE_STRAGEGY=_e;exports.PI_VIEW_FIELD_TOKEN=ee;exports.PiyingFieldTemplate=W;exports.PiyingGroup=Re;exports.PiyingView=pe;exports.PiyingWrapper=$;exports.ReactFormBuilder=ne;exports.ReactSchemaHandle=te;exports.initListen=oe;exports.useControlValueAccessor=ye;exports.useEffectSync=L;exports.useInputCheckboxModel=Ce;exports.useInputNumberModel=je;exports.useInputRadioModel=xe;exports.useInputRangeModel=Se;exports.useInputTextModel=Te;exports.useSelectModel=ke;exports.useSignalToRef=_;
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
import me, { createContext as K, useContext as ee, useState as V, useMemo as c, useRef as x, useEffect as $, useCallback as be } from "react";
|
|
2
|
+
import { effect as re, createRootInjector as he, ChangeDetectionSchedulerImpl as ge, ChangeDetectionScheduler as Ee, createInjector as pe, DestroyRef as Re, untracked as ve } from "static-injector";
|
|
3
|
+
import { createViewControlLink as _e, CoreSchemaHandle as Te, FormBuilder as Ce, convert as je } from "@piying/view-core";
|
|
4
|
+
import "valibot";
|
|
5
|
+
import { deepEqual as xe } from "fast-equals";
|
|
6
|
+
var w = { exports: {} }, O = {};
|
|
7
|
+
/**
|
|
8
|
+
* @license React
|
|
9
|
+
* react-jsx-runtime.production.js
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the MIT license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
var H;
|
|
17
|
+
function ke() {
|
|
18
|
+
if (H) return O;
|
|
19
|
+
H = 1;
|
|
20
|
+
var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
|
|
21
|
+
function n(u, o, a) {
|
|
22
|
+
var l = null;
|
|
23
|
+
if (a !== void 0 && (l = "" + a), o.key !== void 0 && (l = "" + o.key), "key" in o) {
|
|
24
|
+
a = {};
|
|
25
|
+
for (var g in o)
|
|
26
|
+
g !== "key" && (a[g] = o[g]);
|
|
27
|
+
} else a = o;
|
|
28
|
+
return o = a.ref, {
|
|
29
|
+
$$typeof: e,
|
|
30
|
+
type: u,
|
|
31
|
+
key: l,
|
|
32
|
+
ref: o !== void 0 ? o : null,
|
|
33
|
+
props: a
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return O.Fragment = t, O.jsx = n, O.jsxs = n, O;
|
|
37
|
+
}
|
|
38
|
+
var y = {};
|
|
39
|
+
/**
|
|
40
|
+
* @license React
|
|
41
|
+
* react-jsx-runtime.development.js
|
|
42
|
+
*
|
|
43
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
44
|
+
*
|
|
45
|
+
* This source code is licensed under the MIT license found in the
|
|
46
|
+
* LICENSE file in the root directory of this source tree.
|
|
47
|
+
*/
|
|
48
|
+
var X;
|
|
49
|
+
function Oe() {
|
|
50
|
+
return X || (X = 1, process.env.NODE_ENV !== "production" && function() {
|
|
51
|
+
function e(r) {
|
|
52
|
+
if (r == null) return null;
|
|
53
|
+
if (typeof r == "function")
|
|
54
|
+
return r.$$typeof === ce ? null : r.displayName || r.name || null;
|
|
55
|
+
if (typeof r == "string") return r;
|
|
56
|
+
switch (r) {
|
|
57
|
+
case v:
|
|
58
|
+
return "Fragment";
|
|
59
|
+
case d:
|
|
60
|
+
return "Profiler";
|
|
61
|
+
case P:
|
|
62
|
+
return "StrictMode";
|
|
63
|
+
case se:
|
|
64
|
+
return "Suspense";
|
|
65
|
+
case ae:
|
|
66
|
+
return "SuspenseList";
|
|
67
|
+
case ie:
|
|
68
|
+
return "Activity";
|
|
69
|
+
}
|
|
70
|
+
if (typeof r == "object")
|
|
71
|
+
switch (typeof r.tag == "number" && console.error(
|
|
72
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
73
|
+
), r.$$typeof) {
|
|
74
|
+
case S:
|
|
75
|
+
return "Portal";
|
|
76
|
+
case oe:
|
|
77
|
+
return (r.displayName || "Context") + ".Provider";
|
|
78
|
+
case I:
|
|
79
|
+
return (r._context.displayName || "Context") + ".Consumer";
|
|
80
|
+
case ue:
|
|
81
|
+
var s = r.render;
|
|
82
|
+
return r = r.displayName, r || (r = s.displayName || s.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
|
|
83
|
+
case le:
|
|
84
|
+
return s = r.displayName || null, s !== null ? s : e(r.type) || "Memo";
|
|
85
|
+
case L:
|
|
86
|
+
s = r._payload, r = r._init;
|
|
87
|
+
try {
|
|
88
|
+
return e(r(s));
|
|
89
|
+
} catch {
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
function t(r) {
|
|
95
|
+
return "" + r;
|
|
96
|
+
}
|
|
97
|
+
function n(r) {
|
|
98
|
+
try {
|
|
99
|
+
t(r);
|
|
100
|
+
var s = !1;
|
|
101
|
+
} catch {
|
|
102
|
+
s = !0;
|
|
103
|
+
}
|
|
104
|
+
if (s) {
|
|
105
|
+
s = console;
|
|
106
|
+
var i = s.error, m = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
|
|
107
|
+
return i.call(
|
|
108
|
+
s,
|
|
109
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
110
|
+
m
|
|
111
|
+
), t(r);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function u(r) {
|
|
115
|
+
if (r === v) return "<>";
|
|
116
|
+
if (typeof r == "object" && r !== null && r.$$typeof === L)
|
|
117
|
+
return "<...>";
|
|
118
|
+
try {
|
|
119
|
+
var s = e(r);
|
|
120
|
+
return s ? "<" + s + ">" : "<...>";
|
|
121
|
+
} catch {
|
|
122
|
+
return "<...>";
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function o() {
|
|
126
|
+
var r = N.A;
|
|
127
|
+
return r === null ? null : r.getOwner();
|
|
128
|
+
}
|
|
129
|
+
function a() {
|
|
130
|
+
return Error("react-stack-top-frame");
|
|
131
|
+
}
|
|
132
|
+
function l(r) {
|
|
133
|
+
if (W.call(r, "key")) {
|
|
134
|
+
var s = Object.getOwnPropertyDescriptor(r, "key").get;
|
|
135
|
+
if (s && s.isReactWarning) return !1;
|
|
136
|
+
}
|
|
137
|
+
return r.key !== void 0;
|
|
138
|
+
}
|
|
139
|
+
function g(r, s) {
|
|
140
|
+
function i() {
|
|
141
|
+
U || (U = !0, console.error(
|
|
142
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
143
|
+
s
|
|
144
|
+
));
|
|
145
|
+
}
|
|
146
|
+
i.isReactWarning = !0, Object.defineProperty(r, "key", {
|
|
147
|
+
get: i,
|
|
148
|
+
configurable: !0
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function p() {
|
|
152
|
+
var r = e(this.type);
|
|
153
|
+
return B[r] || (B[r] = !0, console.error(
|
|
154
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
155
|
+
)), r = this.props.ref, r !== void 0 ? r : null;
|
|
156
|
+
}
|
|
157
|
+
function h(r, s, i, m, _, R, Y, D) {
|
|
158
|
+
return i = R.ref, r = {
|
|
159
|
+
$$typeof: A,
|
|
160
|
+
type: r,
|
|
161
|
+
key: s,
|
|
162
|
+
props: R,
|
|
163
|
+
_owner: _
|
|
164
|
+
}, (i !== void 0 ? i : null) !== null ? Object.defineProperty(r, "ref", {
|
|
165
|
+
enumerable: !1,
|
|
166
|
+
get: p
|
|
167
|
+
}) : Object.defineProperty(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._store, "validated", {
|
|
168
|
+
configurable: !1,
|
|
169
|
+
enumerable: !1,
|
|
170
|
+
writable: !0,
|
|
171
|
+
value: 0
|
|
172
|
+
}), Object.defineProperty(r, "_debugInfo", {
|
|
173
|
+
configurable: !1,
|
|
174
|
+
enumerable: !1,
|
|
175
|
+
writable: !0,
|
|
176
|
+
value: null
|
|
177
|
+
}), Object.defineProperty(r, "_debugStack", {
|
|
178
|
+
configurable: !1,
|
|
179
|
+
enumerable: !1,
|
|
180
|
+
writable: !0,
|
|
181
|
+
value: Y
|
|
182
|
+
}), Object.defineProperty(r, "_debugTask", {
|
|
183
|
+
configurable: !1,
|
|
184
|
+
enumerable: !1,
|
|
185
|
+
writable: !0,
|
|
186
|
+
value: D
|
|
187
|
+
}), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
|
|
188
|
+
}
|
|
189
|
+
function C(r, s, i, m, _, R, Y, D) {
|
|
190
|
+
var b = s.children;
|
|
191
|
+
if (b !== void 0)
|
|
192
|
+
if (m)
|
|
193
|
+
if (de(b)) {
|
|
194
|
+
for (m = 0; m < b.length; m++)
|
|
195
|
+
k(b[m]);
|
|
196
|
+
Object.freeze && Object.freeze(b);
|
|
197
|
+
} else
|
|
198
|
+
console.error(
|
|
199
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
200
|
+
);
|
|
201
|
+
else k(b);
|
|
202
|
+
if (W.call(s, "key")) {
|
|
203
|
+
b = e(r);
|
|
204
|
+
var j = Object.keys(s).filter(function(fe) {
|
|
205
|
+
return fe !== "key";
|
|
206
|
+
});
|
|
207
|
+
m = 0 < j.length ? "{key: someKey, " + j.join(": ..., ") + ": ...}" : "{key: someKey}", z[b + m] || (j = 0 < j.length ? "{" + j.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
208
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
209
|
+
let props = %s;
|
|
210
|
+
<%s {...props} />
|
|
211
|
+
React keys must be passed directly to JSX without using spread:
|
|
212
|
+
let props = %s;
|
|
213
|
+
<%s key={someKey} {...props} />`,
|
|
214
|
+
m,
|
|
215
|
+
b,
|
|
216
|
+
j,
|
|
217
|
+
b
|
|
218
|
+
), z[b + m] = !0);
|
|
219
|
+
}
|
|
220
|
+
if (b = null, i !== void 0 && (n(i), b = "" + i), l(s) && (n(s.key), b = "" + s.key), "key" in s) {
|
|
221
|
+
i = {};
|
|
222
|
+
for (var M in s)
|
|
223
|
+
M !== "key" && (i[M] = s[M]);
|
|
224
|
+
} else i = s;
|
|
225
|
+
return b && g(
|
|
226
|
+
i,
|
|
227
|
+
typeof r == "function" ? r.displayName || r.name || "Unknown" : r
|
|
228
|
+
), h(
|
|
229
|
+
r,
|
|
230
|
+
b,
|
|
231
|
+
R,
|
|
232
|
+
_,
|
|
233
|
+
o(),
|
|
234
|
+
i,
|
|
235
|
+
Y,
|
|
236
|
+
D
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
function k(r) {
|
|
240
|
+
typeof r == "object" && r !== null && r.$$typeof === A && r._store && (r._store.validated = 1);
|
|
241
|
+
}
|
|
242
|
+
var E = me, A = Symbol.for("react.transitional.element"), S = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), P = Symbol.for("react.strict_mode"), d = Symbol.for("react.profiler"), I = Symbol.for("react.consumer"), oe = Symbol.for("react.context"), ue = Symbol.for("react.forward_ref"), se = Symbol.for("react.suspense"), ae = Symbol.for("react.suspense_list"), le = Symbol.for("react.memo"), L = Symbol.for("react.lazy"), ie = Symbol.for("react.activity"), ce = Symbol.for("react.client.reference"), N = E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, W = Object.prototype.hasOwnProperty, de = Array.isArray, F = console.createTask ? console.createTask : function() {
|
|
243
|
+
return null;
|
|
244
|
+
};
|
|
245
|
+
E = {
|
|
246
|
+
"react-stack-bottom-frame": function(r) {
|
|
247
|
+
return r();
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
var U, B = {}, q = E["react-stack-bottom-frame"].bind(
|
|
251
|
+
E,
|
|
252
|
+
a
|
|
253
|
+
)(), J = F(u(a)), z = {};
|
|
254
|
+
y.Fragment = v, y.jsx = function(r, s, i, m, _) {
|
|
255
|
+
var R = 1e4 > N.recentlyCreatedOwnerStacks++;
|
|
256
|
+
return C(
|
|
257
|
+
r,
|
|
258
|
+
s,
|
|
259
|
+
i,
|
|
260
|
+
!1,
|
|
261
|
+
m,
|
|
262
|
+
_,
|
|
263
|
+
R ? Error("react-stack-top-frame") : q,
|
|
264
|
+
R ? F(u(r)) : J
|
|
265
|
+
);
|
|
266
|
+
}, y.jsxs = function(r, s, i, m, _) {
|
|
267
|
+
var R = 1e4 > N.recentlyCreatedOwnerStacks++;
|
|
268
|
+
return C(
|
|
269
|
+
r,
|
|
270
|
+
s,
|
|
271
|
+
i,
|
|
272
|
+
!0,
|
|
273
|
+
m,
|
|
274
|
+
_,
|
|
275
|
+
R ? Error("react-stack-top-frame") : q,
|
|
276
|
+
R ? F(u(r)) : J
|
|
277
|
+
);
|
|
278
|
+
};
|
|
279
|
+
}()), y;
|
|
280
|
+
}
|
|
281
|
+
var Z;
|
|
282
|
+
function ye() {
|
|
283
|
+
return Z || (Z = 1, process.env.NODE_ENV === "production" ? w.exports = ke() : w.exports = Oe()), w.exports;
|
|
284
|
+
}
|
|
285
|
+
var f = ye();
|
|
286
|
+
const Ae = K(void 0), G = K(void 0);
|
|
287
|
+
function T(e, t) {
|
|
288
|
+
const n = ee(G), [u, o] = V(c(() => t(e), [])), a = x(u);
|
|
289
|
+
return $(() => {
|
|
290
|
+
const l = t(e);
|
|
291
|
+
Object.is(a.current, l) || (o(l), a.current = l);
|
|
292
|
+
const g = re(
|
|
293
|
+
() => {
|
|
294
|
+
const p = t(e);
|
|
295
|
+
Object.is(a.current, p) || (o(p), a.current = p);
|
|
296
|
+
},
|
|
297
|
+
{ injector: n }
|
|
298
|
+
);
|
|
299
|
+
return () => {
|
|
300
|
+
g.destroy();
|
|
301
|
+
};
|
|
302
|
+
}, [e, c(() => t, [])]), u;
|
|
303
|
+
}
|
|
304
|
+
function te(e) {
|
|
305
|
+
const t = c(() => e.wrappers.slice(1), [e.wrappers]), n = e.wrappers[0], u = T(n, () => ({ ...n?.inputs(), ...n?.attributes(), ...n?.outputs }));
|
|
306
|
+
return /* @__PURE__ */ f.jsx(f.Fragment, { children: n ? /* @__PURE__ */ f.jsx(n.type, { ...u, children: /* @__PURE__ */ f.jsx(te, { wrappers: t, children: e.children }) }) : e.children });
|
|
307
|
+
}
|
|
308
|
+
const Se = Symbol.for("ControlValueAccessor");
|
|
309
|
+
function ne(e) {
|
|
310
|
+
const t = T(e.field, (d) => d.inputs()), n = T(e.field, (d) => d.outputs()), u = T(e.field, (d) => d.renderConfig()), o = T(e.field, (d) => d.attributes()), a = c(() => ({ ...t, fields: e.field.fieldGroup?.() }), [t, e.field.fieldGroup]), l = c(() => ({ ...t, fields: e.field.fieldArray?.() }), [t, e.field.fieldArray]), g = T(e.field, (d) => d.wrappers()), p = T(e.field, (d) => d.fieldGroup?.()), h = T(e.field, (d) => d.fieldArray?.()), C = c(() => ({ ...o, ...t, ...n }), [o, t, n]), k = e.field.form.control, E = e.field.define?.type, A = c(() => !!u.hidden || !E, [u.hidden, E]), S = ee(G), v = x(void 0), P = c(() => ({ ...C, [Se]: v }), [C, v]);
|
|
311
|
+
return $(() => {
|
|
312
|
+
let d;
|
|
313
|
+
return v.current && (d = _e(() => k, v.current, S)), () => {
|
|
314
|
+
d?.forEach((I) => I()), d = void 0;
|
|
315
|
+
};
|
|
316
|
+
}, [v.current, k, S]), /* @__PURE__ */ f.jsx(f.Fragment, { children: /* @__PURE__ */ f.jsx(Ae, { value: e.field, children: A ? void 0 : /* @__PURE__ */ f.jsx(te, { wrappers: g, children: p ? /* @__PURE__ */ f.jsx(E, { ...a }) : h ? /* @__PURE__ */ f.jsx(E, { ...l }) : e.field.form.control ? /* @__PURE__ */ f.jsx(E, { ...P }) : /* @__PURE__ */ f.jsx(E, { ...C }) }) }) });
|
|
317
|
+
}
|
|
318
|
+
function Ve(e) {
|
|
319
|
+
return /* @__PURE__ */ f.jsx(f.Fragment, { children: e.fields.map((t, n) => /* @__PURE__ */ f.jsx(ne, { field: t }, n)) });
|
|
320
|
+
}
|
|
321
|
+
class we extends Te {
|
|
322
|
+
// contents?: any[];
|
|
323
|
+
}
|
|
324
|
+
class Pe extends Ce {
|
|
325
|
+
}
|
|
326
|
+
function Ie(e, t, n, u) {
|
|
327
|
+
let o = !0;
|
|
328
|
+
return re(
|
|
329
|
+
() => {
|
|
330
|
+
const a = t.value$$();
|
|
331
|
+
o ? (xe(a, e) || u(a), o = !1) : u(a);
|
|
332
|
+
},
|
|
333
|
+
{ injector: n }
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
function Q(e, t) {
|
|
337
|
+
const n = be(e, t), u = x(void 0);
|
|
338
|
+
c(() => (u.current = n(), u.current), t), $(() => () => {
|
|
339
|
+
u.current?.(), u.current = void 0;
|
|
340
|
+
}, []);
|
|
341
|
+
}
|
|
342
|
+
function $e(e) {
|
|
343
|
+
const t = c(() => he({
|
|
344
|
+
providers: [
|
|
345
|
+
{
|
|
346
|
+
provide: Ee,
|
|
347
|
+
useClass: ge
|
|
348
|
+
}
|
|
349
|
+
]
|
|
350
|
+
}), []), [n, u] = c(() => {
|
|
351
|
+
const o = pe({ providers: [], parent: t });
|
|
352
|
+
return [je(e.schema, {
|
|
353
|
+
handle: we,
|
|
354
|
+
builder: Pe,
|
|
355
|
+
injector: o,
|
|
356
|
+
registerOnDestroy: (l) => {
|
|
357
|
+
o.get(Re).onDestroy(l);
|
|
358
|
+
},
|
|
359
|
+
...e.options
|
|
360
|
+
}), o];
|
|
361
|
+
}, [e.schema, e.options]);
|
|
362
|
+
return Q(() => {
|
|
363
|
+
let o;
|
|
364
|
+
if (n.form.control) {
|
|
365
|
+
const a = e.model;
|
|
366
|
+
o = Ie(typeof a < "u" ? a : void 0, n.form.control, u, (l) => {
|
|
367
|
+
ve(() => {
|
|
368
|
+
n.form.control?.valueNoError$$() && e.modelChange?.(l);
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
return () => {
|
|
373
|
+
u.destroy(), o?.destroy();
|
|
374
|
+
};
|
|
375
|
+
}, [n]), Q(() => {
|
|
376
|
+
n.form.control?.updateValue(e.model);
|
|
377
|
+
}, [n, e.model]), /* @__PURE__ */ f.jsx(f.Fragment, { children: /* @__PURE__ */ f.jsx(G, { value: t, children: /* @__PURE__ */ f.jsx(ne, { field: n }) }) });
|
|
378
|
+
}
|
|
379
|
+
const Ge = [], Le = {
|
|
380
|
+
directives: "merge",
|
|
381
|
+
formConfig: "merge",
|
|
382
|
+
inputs: "merge",
|
|
383
|
+
outputs: "merge",
|
|
384
|
+
props: "merge",
|
|
385
|
+
renderConfig: "merge",
|
|
386
|
+
wrappers: "replace"
|
|
387
|
+
};
|
|
388
|
+
function We(e, t) {
|
|
389
|
+
const n = x(!1);
|
|
390
|
+
return c(() => {
|
|
391
|
+
const u = { value: e.value, disabled: e.disabled, onBlur: e.touchedChange };
|
|
392
|
+
return t ? {
|
|
393
|
+
...u,
|
|
394
|
+
onCompositionStart: () => {
|
|
395
|
+
n.current = !0;
|
|
396
|
+
},
|
|
397
|
+
onCompositionEnd: (o) => {
|
|
398
|
+
n.current = !1, e.valueChange(o.target.value);
|
|
399
|
+
}
|
|
400
|
+
} : {
|
|
401
|
+
...u,
|
|
402
|
+
onInput: (o) => e.valueChange(o.target.value)
|
|
403
|
+
};
|
|
404
|
+
}, [e, t]);
|
|
405
|
+
}
|
|
406
|
+
function Ue(e) {
|
|
407
|
+
return c(() => ({
|
|
408
|
+
checked: e.value,
|
|
409
|
+
disabled: e.disabled,
|
|
410
|
+
onBlur: e.touchedChange,
|
|
411
|
+
onChange: (t) => e.valueChange(t.target.checked)
|
|
412
|
+
}), [e]);
|
|
413
|
+
}
|
|
414
|
+
function Be(e) {
|
|
415
|
+
return c(() => ({
|
|
416
|
+
value: e.value,
|
|
417
|
+
disabled: e.disabled,
|
|
418
|
+
onBlur: e.touchedChange,
|
|
419
|
+
onInput: (t) => {
|
|
420
|
+
const n = t.target.value;
|
|
421
|
+
e.valueChange(n == "" ? void 0 : parseFloat(n));
|
|
422
|
+
}
|
|
423
|
+
}), [e]);
|
|
424
|
+
}
|
|
425
|
+
function qe(e, t) {
|
|
426
|
+
return c(() => ({
|
|
427
|
+
value: t,
|
|
428
|
+
checked: Object.is(e.value, t),
|
|
429
|
+
disabled: e.disabled,
|
|
430
|
+
onBlur: e.touchedChange,
|
|
431
|
+
onChange: () => e.valueChange(t)
|
|
432
|
+
}), [e]);
|
|
433
|
+
}
|
|
434
|
+
function Je(e) {
|
|
435
|
+
return c(() => {
|
|
436
|
+
const t = (n) => {
|
|
437
|
+
const u = n.target.value;
|
|
438
|
+
e.valueChange(u == "" ? void 0 : parseFloat(u));
|
|
439
|
+
};
|
|
440
|
+
return {
|
|
441
|
+
value: e.value,
|
|
442
|
+
disabled: e.disabled,
|
|
443
|
+
onBlur: e.touchedChange,
|
|
444
|
+
onInput: t,
|
|
445
|
+
onChange: t
|
|
446
|
+
};
|
|
447
|
+
}, [e]);
|
|
448
|
+
}
|
|
449
|
+
function ze(e, t = !1) {
|
|
450
|
+
return c(() => ({
|
|
451
|
+
value: e.value,
|
|
452
|
+
disabled: e.disabled,
|
|
453
|
+
onBlur: e.touchedChange,
|
|
454
|
+
onChange: (n) => {
|
|
455
|
+
const u = [], o = n.target;
|
|
456
|
+
if (o.selectedOptions !== void 0)
|
|
457
|
+
for (let a = 0; a < o.selectedOptions.length; a++) {
|
|
458
|
+
const l = o.selectedOptions[a];
|
|
459
|
+
if (u.push(l.value), !t)
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
else
|
|
463
|
+
for (let a = 0; a < o.options.length; a++) {
|
|
464
|
+
const l = o.options[a];
|
|
465
|
+
if (l.selected && (u.push(l.value), !t))
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
e.valueChange(t ? u : u[0]);
|
|
469
|
+
}
|
|
470
|
+
}), [e]);
|
|
471
|
+
}
|
|
472
|
+
function He(e = void 0) {
|
|
473
|
+
const [t, n] = V(e), [u, o] = V(!1), a = x(void 0), l = x(void 0), g = c(() => ({
|
|
474
|
+
writeValue(h) {
|
|
475
|
+
n(h);
|
|
476
|
+
},
|
|
477
|
+
registerOnChange(h) {
|
|
478
|
+
a.current = h;
|
|
479
|
+
},
|
|
480
|
+
registerOnTouched(h) {
|
|
481
|
+
l.current = h;
|
|
482
|
+
},
|
|
483
|
+
setDisabledState(h) {
|
|
484
|
+
o(h);
|
|
485
|
+
}
|
|
486
|
+
}), []), p = c(() => ({
|
|
487
|
+
value: t,
|
|
488
|
+
disabled: u,
|
|
489
|
+
valueChange: (h) => {
|
|
490
|
+
a.current?.(h), n(h);
|
|
491
|
+
},
|
|
492
|
+
touchedChange: () => {
|
|
493
|
+
l.current?.();
|
|
494
|
+
}
|
|
495
|
+
}), [t, u]);
|
|
496
|
+
return c(() => ({
|
|
497
|
+
cva: g,
|
|
498
|
+
cvaa: p
|
|
499
|
+
}), [p]);
|
|
500
|
+
}
|
|
501
|
+
export {
|
|
502
|
+
Se as CVA,
|
|
503
|
+
Ge as EMPTY_ARRAY,
|
|
504
|
+
G as InjectorToken,
|
|
505
|
+
Le as NG_CONFIG_DEFAULT_MERGE_STRAGEGY,
|
|
506
|
+
Ae as PI_VIEW_FIELD_TOKEN,
|
|
507
|
+
ne as PiyingFieldTemplate,
|
|
508
|
+
Ve as PiyingGroup,
|
|
509
|
+
$e as PiyingView,
|
|
510
|
+
te as PiyingWrapper,
|
|
511
|
+
Pe as ReactFormBuilder,
|
|
512
|
+
we as ReactSchemaHandle,
|
|
513
|
+
Ie as initListen,
|
|
514
|
+
He as useControlValueAccessor,
|
|
515
|
+
Q as useEffectSync,
|
|
516
|
+
Ue as useInputCheckboxModel,
|
|
517
|
+
Be as useInputNumberModel,
|
|
518
|
+
qe as useInputRadioModel,
|
|
519
|
+
Je as useInputRangeModel,
|
|
520
|
+
We as useInputTextModel,
|
|
521
|
+
ze as useSelectModel,
|
|
522
|
+
T as useSignalToRef
|
|
523
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@piying/view-react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@piying/view-core": "^0.6.24",
|
|
7
|
+
"fast-equals": "^5.2.2",
|
|
8
|
+
"static-injector": "^6.1.2",
|
|
9
|
+
"valibot": "^1.1.0"
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"react": "^19.1.0",
|
|
14
|
+
"react-dom": "^19.1.0"
|
|
15
|
+
},
|
|
16
|
+
"module": "index.js",
|
|
17
|
+
"typings": "index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
"./package.json": {
|
|
20
|
+
"default": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./index.d.ts",
|
|
24
|
+
"default": "./index.js",
|
|
25
|
+
"import": "./index.js",
|
|
26
|
+
"require": "./index.cjs"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CoreSchemaHandle, type ConfigMergeStrategy } from '@piying/view-core';
|
|
2
|
+
import type { PiResolvedViewFieldConfig } from './type/group';
|
|
3
|
+
export declare class ReactSchemaHandle extends CoreSchemaHandle<ReactSchemaHandle, () => PiResolvedViewFieldConfig> {
|
|
4
|
+
type?: any;
|
|
5
|
+
}
|
|
6
|
+
export type PiDefaultRawFormlyFieldConfig = Pick<ReactSchemaHandle, 'inputs' | 'outputs' | 'wrappers' | 'formConfig' | 'renderConfig' | 'props'>;
|
|
7
|
+
export type ConfigMergeStrategyObject = Record<keyof PiDefaultRawFormlyFieldConfig, ConfigMergeStrategy>;
|
package/token.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Injector } from 'static-injector';
|
|
2
|
+
import type { PiResolvedViewFieldConfig } from './type/group';
|
|
3
|
+
export declare const PI_VIEW_FIELD_TOKEN: import("react").Context<PiResolvedViewFieldConfig | undefined>;
|
|
4
|
+
export declare const InjectorToken: import("react").Context<Injector | undefined>;
|
package/type/group.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ConfigMergeStrategyObject, ReactSchemaHandle } from '../schema-handle';
|
|
2
|
+
import type { ConfigMergeStrategy, CoreResolvedComponentDefine, PiResolvedCommonViewFieldConfig } from '@piying/view-core';
|
|
3
|
+
import type { SetOptional } from '@piying/view-core';
|
|
4
|
+
export interface RawDirectiveOutputs {
|
|
5
|
+
[name: string]: (event: any, field: PiResolvedViewFieldConfig) => void;
|
|
6
|
+
}
|
|
7
|
+
export type RawWrapperDefine = {
|
|
8
|
+
inputs?: Record<string, any>;
|
|
9
|
+
type: string;
|
|
10
|
+
};
|
|
11
|
+
export type ResolvedrapperDefine = {
|
|
12
|
+
inputs?: Record<string, any>;
|
|
13
|
+
type: any;
|
|
14
|
+
};
|
|
15
|
+
export interface RawComponentDefine {
|
|
16
|
+
type: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ComponentFieldConfig {
|
|
19
|
+
type?: string;
|
|
20
|
+
contents?: any[];
|
|
21
|
+
}
|
|
22
|
+
export type ResolvedComponentFieldConfig = Omit<ComponentFieldConfig, 'inputs' | 'outputs' | 'directives' | 'wrappers'>;
|
|
23
|
+
export type PiDefaultRawViewFieldConfig = Pick<ReactSchemaHandle, 'inputs' | 'outputs' | 'wrappers' | 'formConfig' | 'renderConfig' | 'props'>;
|
|
24
|
+
export type PiResolvedViewFieldConfig = PiResolvedCommonViewFieldConfig<() => PiResolvedViewFieldConfig, CoreResolvedComponentDefine> & ResolvedComponentFieldConfig & {
|
|
25
|
+
/** 除了无component的控件,其他情况下都应该有define,group/array会赋值默认 */
|
|
26
|
+
define?: RawComponentDefine;
|
|
27
|
+
};
|
|
28
|
+
export type PiComponentDefaultConfig = {
|
|
29
|
+
type: any | (() => Promise<any>);
|
|
30
|
+
} & Omit<SetOptional<PiDefaultRawViewFieldConfig, 'formConfig'>, 'type'>;
|
|
31
|
+
export interface PiViewConfig {
|
|
32
|
+
types?: Record<string, PiComponentDefaultConfig>;
|
|
33
|
+
wrappers?: Record<string, {
|
|
34
|
+
type: any | (() => Promise<any>);
|
|
35
|
+
inputs?: Record<string, any>;
|
|
36
|
+
}>;
|
|
37
|
+
defaultConfig?: PiDefaultRawViewFieldConfig;
|
|
38
|
+
/** merge 数组/对象会合并 replace 优先自身/组件/全局 */
|
|
39
|
+
defaultConfigMergeStrategy?: ConfigMergeStrategy | ConfigMergeStrategyObject;
|
|
40
|
+
}
|
package/type/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './group';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ControlValueAccessorAdapter } from '../util/use-control-value-accessor';
|
|
2
|
+
export declare function useInputCheckboxModel(cvaa: ControlValueAccessorAdapter): {
|
|
3
|
+
checked: any;
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
onBlur: () => void;
|
|
6
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
7
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ControlValueAccessorAdapter } from '../util/use-control-value-accessor';
|
|
2
|
+
export declare function useInputRadioModel(cvaa: ControlValueAccessorAdapter, value: any): {
|
|
3
|
+
value: any;
|
|
4
|
+
checked: boolean;
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
onBlur: () => void;
|
|
7
|
+
onChange: () => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ControlValueAccessorAdapter } from '../util/use-control-value-accessor';
|
|
2
|
+
export declare function useInputRangeModel(cvaa: ControlValueAccessorAdapter): {
|
|
3
|
+
value: any;
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
onBlur: () => void;
|
|
6
|
+
onInput: (event: any) => void;
|
|
7
|
+
onChange: (event: any) => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ControlValueAccessorAdapter } from '../util/use-control-value-accessor';
|
|
2
|
+
export declare function useSelectModel(cvaa: ControlValueAccessorAdapter, multiple?: boolean): {
|
|
3
|
+
value: any;
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
onBlur: () => void;
|
|
6
|
+
onChange: (event: React.ChangeEvent<HTMLSelectElement>) => void;
|
|
7
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ControlValueAccessorAdapter } from '../util/use-control-value-accessor';
|
|
2
|
+
export declare function useInputTextModel(cvaa: ControlValueAccessorAdapter, compositionMode: boolean): {
|
|
3
|
+
onCompositionStart: () => void;
|
|
4
|
+
onCompositionEnd: (event: any) => void;
|
|
5
|
+
value: any;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
onBlur: () => void;
|
|
8
|
+
} | {
|
|
9
|
+
onInput: (event: any) => void;
|
|
10
|
+
value: any;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
onBlur: () => void;
|
|
13
|
+
};
|
package/util/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useSignalToRef<I, R>(listen: I, value: (fn: I) => R): R;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ControlValueAccessor } from '@piying/view-core';
|
|
2
|
+
export declare function useControlValueAccessor(initValue?: any): {
|
|
3
|
+
cva: ControlValueAccessor;
|
|
4
|
+
cvaa: ControlValueAccessorAdapter;
|
|
5
|
+
};
|
|
6
|
+
export type ControlValueAccessorAdapter = {
|
|
7
|
+
value: any;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
touchedChange: () => void;
|
|
10
|
+
valueChange: (value: any) => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useEffectSync(fn: () => (() => void) | void, deps: any[]): void;
|