@donotdev/crud 0.0.2 → 0.0.4
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/CrudService.d.ts.map +1 -1
- package/dist/CrudService.js +1 -1
- package/dist/CrudStore.d.ts +1 -1
- package/dist/CrudStore.d.ts.map +1 -1
- package/dist/CrudStore.js +1 -1
- package/dist/adapters/FirestoreAdapter.js +1 -1
- package/dist/adapters/FunctionsAdapter.js +1 -1
- package/dist/adapters/index.js +1 -1
- package/dist/components/ControlledFields.d.ts +18 -143
- package/dist/components/ControlledFields.d.ts.map +1 -1
- package/dist/components/ControlledFields.js +1 -1
- package/dist/components/CrudButton.js +1 -1
- package/dist/components/EntityFormRenderer.js +1 -1
- package/dist/components/FormFieldRenderer.d.ts.map +1 -1
- package/dist/components/FormFieldRenderer.js +1 -1
- package/dist/components/FormLayout.js +1 -1
- package/dist/components/form/fields/AddressFieldComponent.d.ts +42 -0
- package/dist/components/form/fields/AddressFieldComponent.d.ts.map +1 -0
- package/dist/components/form/fields/AddressFieldComponent.js +1 -0
- package/dist/components/form/fields/AvatarFieldComponent.js +1 -1
- package/dist/components/form/fields/BadgeFieldComponent.js +1 -1
- package/dist/components/form/fields/ButtonFieldComponent.js +1 -1
- package/dist/components/form/fields/CheckboxFieldComponent.js +1 -1
- package/dist/components/form/fields/DateFieldComponent.js +1 -1
- package/dist/components/form/fields/DropdownComponent.js +1 -1
- package/dist/components/form/fields/FileFieldComponent.js +1 -1
- package/dist/components/form/fields/GeoPointFieldComponent.js +1 -1
- package/dist/components/form/fields/HiddenFieldComponent.js +1 -1
- package/dist/components/form/fields/ImageFieldComponent.js +1 -1
- package/dist/components/form/fields/MapFieldComponent.js +1 -1
- package/dist/components/form/fields/MultiDropdownComponent.js +1 -1
- package/dist/components/form/fields/MultiInputTextFieldComponent.js +1 -1
- package/dist/components/form/fields/NumberFieldComponent.js +1 -1
- package/dist/components/form/fields/PasswordFieldComponent.js +1 -1
- package/dist/components/form/fields/PhoneNumberComponent.js +1 -1
- package/dist/components/form/fields/RadioFieldComponent.js +1 -1
- package/dist/components/form/fields/RangeFieldComponent.js +1 -1
- package/dist/components/form/fields/ReferenceFieldComponent.d.ts +24 -18
- package/dist/components/form/fields/ReferenceFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/ReferenceFieldComponent.js +1 -1
- package/dist/components/form/fields/TextAreaComponent.js +1 -1
- package/dist/components/form/fields/TextFieldComponent.js +1 -1
- package/dist/components/form/fields/TimestampFieldComponent.js +1 -1
- package/dist/components/form/fields/index.d.ts +2 -0
- package/dist/components/form/fields/index.d.ts.map +1 -1
- package/dist/components/form/fields/index.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/useCrud.d.ts +9 -17
- package/dist/useCrud.d.ts.map +1 -1
- package/dist/useCrud.js +1 -1
- package/dist/utils/collections.js +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrudService.d.ts","sourceRoot":"","sources":["../src/CrudService.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,YAAY,EAAE,YAAY,EAAE,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,WAAW,oBAAoB;IACnC,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,GAAG,CAAC,CAAC,EACH,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACrB,GAAG,CAAC,CAAC,EACH,UAAU,EAAE,MAAM,EAClB,EA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CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,EACjD,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,MAAM,IAAI;IA8Bb,qBAAqB,CAAC,CAAC,EACrB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,EAC5C,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,MAAM,IAAI;CAmCd;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,mBAE1B,CAAC"}
|
package/dist/CrudService.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toast as
|
|
1
|
+
import{toast as o}from"@donotdev/components";import{createSingleton as n,handleError as h}from"@donotdev/core";import{FirestoreAdapter as u}from"./adapters/FirestoreAdapter";import{FunctionsAdapter as g}from"./adapters/FunctionsAdapter";class p{adapter=null;backend=null;store=null;setStore(t){this.store=t}async initialize(t){if(!(this.backend===t&&this.adapter)){if(this.backend=t,t==="functions")this.adapter=new g;else if(t==="firestore")this.adapter=new u;else throw new Error(`Unknown backend: ${t}`);this.store&&(this.store.getState().setBackend(t),this.store.getState().setCrudService(this))}}async get(t,s,i){this.adapter||await this.initialize("firestore"),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");const e=await this.adapter.get(t,s,i);return this.store&&e&&this.store.getState().setData(t,s,e),e}catch(e){const r=h(e,{userMessage:`Failed to fetch ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,r),r}finally{this.store&&this.store.getState().setLoading(t,!1)}}async set(t,s,i,e){this.adapter||await this.initialize("firestore"),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");await this.adapter.set(t,s,i,e),this.store&&this.store.getState().setData(t,s,i),o("success",`${t} saved successfully`)}catch(r){const a=h(r,{userMessage:`Failed to save ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,a),a}finally{this.store&&this.store.getState().setLoading(t,!1)}}async update(t,s,i){this.adapter||await this.initialize("firestore"),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));let e=null;this.store&&(e=this.store.getState().getData(t,s)),this.store&&e&&this.store.getState().setData(t,s,{...e,...i});try{if(!this.adapter)throw new Error("Adapter not initialized");await this.adapter.update(t,s,i),o("success",`${t} updated successfully`)}catch(r){this.store&&e&&this.store.getState().setData(t,s,e);const a=h(r,{userMessage:`Failed to update ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,a),a}finally{this.store&&this.store.getState().setLoading(t,!1)}}async delete(t,s){this.adapter||await this.initialize("firestore"),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");await this.adapter.delete(t,s),this.store&&this.store.getState().removeData(t,s),o("success",`${t} deleted successfully`)}catch(i){const e=h(i,{userMessage:`Failed to delete ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,e),e}finally{this.store&&this.store.getState().setLoading(t,!1)}}async add(t,s,i){this.adapter||await this.initialize("firestore"),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");const e=await this.adapter.add(t,s,i);return this.store&&e&&this.store.getState().setData(t,e,{...s,id:e}),o("success",`${t} created successfully`),e}catch(e){const r=h(e,{userMessage:`Failed to create ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,r),r}finally{this.store&&this.store.getState().setLoading(t,!1)}}async query(t,s,i){this.adapter||await this.initialize("firestore"),this.store&&(this.store.getState().setLoading(t,!0),this.store.getState().setError(t,null));try{if(!this.adapter)throw new Error("Adapter not initialized");const e=await this.adapter.query(t,s,i);if(this.store)for(const r of e){const a=r.id;a&&this.store.getState().setData(t,a,r)}return e}catch(e){const r=h(e,{userMessage:`Failed to query ${t}`,showNotification:!0});throw this.store&&this.store.getState().setError(t,r),r}finally{this.store&&this.store.getState().setLoading(t,!1)}}subscribe(t,s,i,e){this.adapter||this.initialize("firestore").catch(()=>{});try{return this.adapter?this.adapter.subscribe(t,s,(r,a)=>{r&&this.store&&this.store.getState().setData(t,s,r),i(r,a)},e):(i(null,new Error("Adapter not initialized")),()=>{})}catch(r){return i(null,h(r)),()=>{}}}subscribeToCollection(t,s,i,e){this.adapter||this.initialize("firestore").catch(()=>{});try{return this.adapter?this.adapter.subscribeToCollection(t,s,(r,a)=>{if(r&&this.store)for(const d of r){const f=d.id;f&&this.store.getState().setData(t,f,d)}i(r,a)},e):(i([],new Error("Adapter not initialized")),()=>{})}catch(r){return i([],h(r)),()=>{}}}}const A=n(()=>new p);export{A as getCrudService};
|
package/dist/CrudStore.d.ts
CHANGED
|
@@ -51,5 +51,5 @@ export interface CrudActions {
|
|
|
51
51
|
* @since 0.0.1
|
|
52
52
|
* @author AMBROISE PARK Consulting
|
|
53
53
|
*/
|
|
54
|
-
export declare const useCrudStore: import("zustand").UseBoundStore<import("zustand").StoreApi<CrudState & CrudActions & import("@donotdev/
|
|
54
|
+
export declare const useCrudStore: import("zustand").UseBoundStore<import("zustand").StoreApi<CrudState & CrudActions & import("@donotdev/core").DoNotDevStore>>;
|
|
55
55
|
//# sourceMappingURL=CrudStore.d.ts.map
|
package/dist/CrudStore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrudStore.d.ts","sourceRoot":"","sources":["../src/CrudStore.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IAExB,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC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EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IAC5C,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,KAAK,GAAG,IAAI,CAAC;IAC/C,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,CAAC;CAC7D;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,+HA2JvB,CAAC"}
|
package/dist/CrudStore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createDoNotDevStore as
|
|
1
|
+
import{createDoNotDevStore as i}from"@donotdev/core";const d={backend:null,crudService:null,collections:{}},u=i({name:"crud-store",createStore:(r,n)=>({...d,setCrudService:o=>{r({crudService:o})},setBackend:o=>{r({backend:o})},setLoading:(o,l)=>{r(e=>{const t=e.collections[o]||{loading:!1,error:null,data:{},lastUpdated:0};return{collections:{...e.collections,[o]:{...t,loading:l}}}})},setError:(o,l)=>{r(e=>{const t=e.collections[o]||{loading:!1,error:null,data:{},lastUpdated:0};return{collections:{...e.collections,[o]:{...t,error:l,loading:!1}}}})},setData:(o,l,e)=>{r(t=>{const c=t.collections[o]||{loading:!1,error:null,data:{},lastUpdated:0};return{collections:{...t.collections,[o]:{...c,data:{...c.data,[l]:e},lastUpdated:Date.now(),error:null}}}})},removeData:(o,l)=>{r(e=>{const t=e.collections[o];if(!t)return e;const{[l]:c,...a}=t.data;return{collections:{...e.collections,[o]:{...t,data:a,lastUpdated:Date.now()}}}})},clearCollection:o=>{r(l=>{const{[o]:e,...t}=l.collections;return{collections:t}})},clearError:o=>{r(l=>{const e=l.collections[o];return e?{collections:{...l.collections,[o]:{...e,error:null}}}:l})},getLoading:o=>n().collections[o]?.loading||!1,getError:o=>n().collections[o]?.error||null,getData:(o,l)=>n().collections[o]?.data[l]||null})});export{u as useCrudStore};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as d from"valibot";import{handleError as F}from"@donotdev/core";import{getFirestore as D,doc as u,getDoc as x,getDocs as q,setDoc as z,updateDoc as E,deleteDoc as v,addDoc as B,collection as C,query as y,where as m,orderBy as g,limit as w,onSnapshot as A}from"@donotdev/firebase";import{transformFirestoreData as h,prepareForFirestore as p}from"@donotdev/firebase";class P{firestore;ensureFirestore(){if(this.firestore)return!0;try{return this.firestore=D(),!0}catch{return!1}}getCollectionRef(o){return!this.ensureFirestore()||!this.firestore?null:C(this.firestore,o)}async get(o,e,r){if(!this.ensureFirestore()||!this.firestore)return null;try{const s=u(this.firestore,o,e),t=await x(s);if(!t.exists())return null;let i=t.data();return i=h(i),{...d.parse(r,i),id:e}}catch{return null}}async set(o,e,r,s){if(!(!this.ensureFirestore()||!this.firestore))try{d.parse(s,r);const t=u(this.firestore,o,e),i=p(r);await z(t,i)}catch(t){throw t}}async update(o,e,r){if(!(!this.ensureFirestore()||!this.firestore))try{const s=u(this.firestore,o,e),t=p(r);await E(s,t)}catch(s){throw s}}async delete(o,e){if(!(!this.ensureFirestore()||!this.firestore))try{const r=u(this.firestore,o,e);await v(r)}catch(r){throw r}}async add(o,e,r){if(!this.ensureFirestore())return"";try{d.parse(r,e);const s=this.getCollectionRef(o);if(!s)return"";const t=p(e);return(await B(s,t)).id}catch(s){throw s}}async query(o,e,r){if(!this.ensureFirestore())return[];const s=this.getCollectionRef(o);if(!s)return[];try{const t=[];if(e.where)for(const n of e.where)t.push(m(n.field,n.operator,n.value));if(e.orderBy)for(const n of e.orderBy)t.push(g(n.field,n.direction||"asc"));e.limit&&t.push(w(e.limit));const i=y(s,...t),c=await q(i),a=[];return c.forEach(n=>{try{let l=n.data();if(!l)return;l=h(l);const f=d.parse(r,l);a.push({...f,id:n.id})}catch(l){F(l,{context:{operation:"FirestoreAdapter.query.parse",docId:n.id,collection:o}})}}),a}catch(t){throw F(t,{context:{operation:"FirestoreAdapter.query",collection:o,options:e}}),t}}subscribe(o,e,r,s){if(!this.ensureFirestore()||!this.firestore)return()=>{};const t=u(this.firestore,o,e);return A(t,i=>{try{if(!i.exists()){r(null);return}let c=i.data();c=h(c);const a=d.parse(s,c);r({...a,id:e})}catch(c){r(null,c)}},i=>{r(null,i)})}subscribeToCollection(o,e,r,s){if(!this.ensureFirestore())return()=>{};const t=this.getCollectionRef(o);if(!t)return()=>{};try{const i=[];if(e.where)for(const a of e.where)i.push(m(a.field,a.operator,a.value));if(e.orderBy)for(const a of e.orderBy)i.push(g(a.field,a.direction||"asc"));e.limit&&i.push(w(e.limit));const c=y(t,...i);return A(c,a=>{try{const n=[];a.forEach(l=>{let f=l.data();f=h(f);const R=d.parse(s,f);n.push({...R,id:l.id})}),r(n)}catch(n){r([],n)}},a=>{r([],a)})}catch(i){return r([],i),()=>{}}}}export{P as FirestoreAdapter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{httpsCallable as
|
|
1
|
+
import{httpsCallable as o}from"firebase/functions";import*as i from"valibot";import{getPlatformEnvVar as c}from"@donotdev/core";import{getFirebaseFunctions as u}from"@donotdev/firebase";class p{functions;region;constructor(){this.region=c("FIREBASE_FUNCTIONS_REGION")||"europe-west1"}async ensureFunctions(){if(this.functions)return!0;try{return this.functions=await u(this.region),!0}catch{return!1}}async get(e,r,n){if(!await this.ensureFunctions())return null;try{const t=`get_${e}`;return(await o(this.functions,t)({id:r})).data}catch(t){throw t}}async set(e,r,n,t){if(await this.ensureFunctions())try{i.parse(t,n);const s=`update_${e}`;await o(this.functions,s)({id:r,payload:n})}catch(s){throw s}}async update(e,r,n){if(await this.ensureFunctions())try{const t=`update_${e}`;await o(this.functions,t)({id:r,payload:n})}catch(t){throw t}}async delete(e,r){if(await this.ensureFunctions())try{const n=`delete_${e}`;await o(this.functions,n)({id:r})}catch(n){throw n}}async add(e,r,n){if(!await this.ensureFunctions())return"";try{i.parse(n,r);const t=`create_${e}`;return(await o(this.functions,t)({payload:r})).data.id}catch(t){throw t}}async query(e,r,n){if(!await this.ensureFunctions())return[];try{const t=`list_${e}`;return(await o(this.functions,t)({filters:r})).data}catch(t){throw t}}subscribe(){throw new Error("Subscriptions are not supported with Functions backend. Use Firestore backend for real-time features.")}subscribeToCollection(){throw new Error("Subscriptions are not supported with Functions backend. Use Firestore backend for real-time features.")}}export{p as FunctionsAdapter};
|
package/dist/adapters/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./FirestoreAdapter";import{FunctionsAdapter as
|
|
1
|
+
export*from"./FirestoreAdapter";import{FunctionsAdapter as e}from"./FunctionsAdapter";export{e as FunctionsAdapter};
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { type Control, type FieldErrors, type FieldValues } from 'react-hook-form';
|
|
2
2
|
import type { FieldConfig, FieldType } from '@donotdev/core';
|
|
3
3
|
import type { ReactElement } from 'react';
|
|
4
|
-
/**
|
|
5
|
-
* Common props for all controlled fields
|
|
6
|
-
*
|
|
7
|
-
* @version 0.0.1
|
|
8
|
-
* @since 0.0.1
|
|
9
|
-
* @author AMBROISE PARK Consulting
|
|
10
|
-
*/
|
|
11
4
|
export interface ControlledFieldProps<T extends FieldValues = any, FT extends FieldType = FieldType> {
|
|
12
5
|
control: Control<T>;
|
|
13
6
|
errors: FieldErrors<T>;
|
|
@@ -17,140 +10,22 @@ export interface ControlledFieldProps<T extends FieldValues = any, FT extends Fi
|
|
|
17
10
|
placeholder?: string;
|
|
18
11
|
[key: string]: any;
|
|
19
12
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export declare const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export declare const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
* @version 0.0.1
|
|
40
|
-
* @since 0.0.1
|
|
41
|
-
* @author AMBROISE PARK Consulting
|
|
42
|
-
*/
|
|
43
|
-
export declare const ControlledDropdownField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "week" | "month" | "file" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
44
|
-
/**
|
|
45
|
-
* Controlled file field component
|
|
46
|
-
*
|
|
47
|
-
* @version 0.0.1
|
|
48
|
-
* @since 0.0.1
|
|
49
|
-
* @author AMBROISE PARK Consulting
|
|
50
|
-
*/
|
|
51
|
-
export declare const ControlledFileField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "week" | "month" | "file" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
52
|
-
/**
|
|
53
|
-
* Controlled geo point field component
|
|
54
|
-
*
|
|
55
|
-
* @version 0.0.1
|
|
56
|
-
* @since 0.0.1
|
|
57
|
-
* @author AMBROISE PARK Consulting
|
|
58
|
-
*/
|
|
59
|
-
export declare const ControlledGeoPointField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "week" | "month" | "file" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
60
|
-
/**
|
|
61
|
-
* Controlled image field component
|
|
62
|
-
*
|
|
63
|
-
* @version 0.0.1
|
|
64
|
-
* @since 0.0.1
|
|
65
|
-
* @author AMBROISE PARK Consulting
|
|
66
|
-
*/
|
|
67
|
-
export declare const ControlledImageField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "week" | "month" | "file" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
68
|
-
/**
|
|
69
|
-
* Controlled map field component
|
|
70
|
-
*
|
|
71
|
-
* @version 0.0.1
|
|
72
|
-
* @since 0.0.1
|
|
73
|
-
* @author AMBROISE PARK Consulting
|
|
74
|
-
*/
|
|
75
|
-
export declare const ControlledMapField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "week" | "month" | "file" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
76
|
-
/**
|
|
77
|
-
* Controlled multi dropdown field component
|
|
78
|
-
*
|
|
79
|
-
* @version 0.0.1
|
|
80
|
-
* @since 0.0.1
|
|
81
|
-
* @author AMBROISE PARK Consulting
|
|
82
|
-
*/
|
|
83
|
-
export declare const ControlledMultiDropdownField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "week" | "month" | "file" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
84
|
-
/**
|
|
85
|
-
* Controlled multi input field component
|
|
86
|
-
*
|
|
87
|
-
* @version 0.0.1
|
|
88
|
-
* @since 0.0.1
|
|
89
|
-
* @author AMBROISE PARK Consulting
|
|
90
|
-
*/
|
|
91
|
-
export declare const ControlledMultiInputField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "week" | "month" | "file" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
92
|
-
/**
|
|
93
|
-
* Controlled number field component
|
|
94
|
-
*
|
|
95
|
-
* @version 0.0.1
|
|
96
|
-
* @since 0.0.1
|
|
97
|
-
* @author AMBROISE PARK Consulting
|
|
98
|
-
*/
|
|
99
|
-
export declare const ControlledNumberField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "week" | "month" | "file" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
100
|
-
/**
|
|
101
|
-
* Controlled phone field component
|
|
102
|
-
*
|
|
103
|
-
* @version 0.0.1
|
|
104
|
-
* @since 0.0.1
|
|
105
|
-
* @author AMBROISE PARK Consulting
|
|
106
|
-
*/
|
|
107
|
-
export declare const ControlledPhoneField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "week" | "month" | "file" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
108
|
-
/**
|
|
109
|
-
* Controlled range field component
|
|
110
|
-
*
|
|
111
|
-
* @version 0.0.1
|
|
112
|
-
* @since 0.0.1
|
|
113
|
-
* @author AMBROISE PARK Consulting
|
|
114
|
-
*/
|
|
115
|
-
export declare const ControlledRangeField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "week" | "month" | "file" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
116
|
-
/**
|
|
117
|
-
* Controlled radio field component
|
|
118
|
-
*
|
|
119
|
-
* @version 0.0.1
|
|
120
|
-
* @since 0.0.1
|
|
121
|
-
* @author AMBROISE PARK Consulting
|
|
122
|
-
*/
|
|
123
|
-
export declare const ControlledRadioField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "week" | "month" | "file" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
124
|
-
/**
|
|
125
|
-
* Controlled reference field component
|
|
126
|
-
*
|
|
127
|
-
* @version 0.0.1
|
|
128
|
-
* @since 0.0.1
|
|
129
|
-
* @author AMBROISE PARK Consulting
|
|
130
|
-
*/
|
|
131
|
-
export declare const ControlledReferenceField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "week" | "month" | "file" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
132
|
-
/**
|
|
133
|
-
* Controlled text field component
|
|
134
|
-
*
|
|
135
|
-
* @version 0.0.1
|
|
136
|
-
* @since 0.0.1
|
|
137
|
-
* @author AMBROISE PARK Consulting
|
|
138
|
-
*/
|
|
139
|
-
export declare const ControlledTextField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "week" | "month" | "file" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
140
|
-
/**
|
|
141
|
-
* Controlled password field component
|
|
142
|
-
*
|
|
143
|
-
* @version 0.0.1
|
|
144
|
-
* @since 0.0.1
|
|
145
|
-
* @author AMBROISE PARK Consulting
|
|
146
|
-
*/
|
|
147
|
-
export declare const ControlledPasswordField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "week" | "month" | "file" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
148
|
-
/**
|
|
149
|
-
* Controlled timestamp field component
|
|
150
|
-
*
|
|
151
|
-
* @version 0.0.1
|
|
152
|
-
* @since 0.0.1
|
|
153
|
-
* @author AMBROISE PARK Consulting
|
|
154
|
-
*/
|
|
155
|
-
export declare const ControlledTimestampField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "week" | "month" | "file" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
13
|
+
export declare const ControlledCheckboxField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
14
|
+
export declare const ControlledDateField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
15
|
+
export declare const ControlledDropdownField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
16
|
+
export declare const ControlledFileField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
17
|
+
export declare const ControlledGeoPointField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
18
|
+
export declare const ControlledImageField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
19
|
+
export declare const ControlledMapField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
20
|
+
export declare const ControlledMultiDropdownField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
21
|
+
export declare const ControlledMultiInputField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
22
|
+
export declare const ControlledNumberField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
23
|
+
export declare const ControlledPhoneField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
24
|
+
export declare const ControlledRangeField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
25
|
+
export declare const ControlledRadioField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
26
|
+
export declare const ControlledReferenceField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
27
|
+
export declare const ControlledTextField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
28
|
+
export declare const ControlledPasswordField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
29
|
+
export declare const ControlledTimestampField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
30
|
+
export declare const ControlledAddressField: (props: ControlledFieldProps<any, "number" | "boolean" | "password" | "reference" | "map" | "color" | "array" | "url" | "email" | "submit" | "file" | "week" | "month" | "address" | "avatar" | "badge" | "checkbox" | "date" | "datetime-local" | "geopoint" | "hidden" | "image" | "multiselect" | "radio" | "range" | "reset" | "select" | "tel" | "text" | "textarea" | "time" | "timestamp">) => ReactElement;
|
|
156
31
|
//# sourceMappingURL=ControlledFields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlledFields.d.ts","sourceRoot":"","sources":["../../src/components/ControlledFields.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ControlledFields.d.ts","sourceRoot":"","sources":["../../src/components/ControlledFields.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,OAAO,EAEZ,KAAK,WAAW,EAChB,KAAK,WAAW,EAGjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA0C7D,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAEzD,MAAM,WAAW,oBAAoB,CACnC,CAAC,SAAS,WAAW,GAAG,GAAG,EAC3B,EAAE,SAAS,SAAS,GAAG,SAAS;IAEhC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACvB,WAAW,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAoLD,eAAO,MAAM,uBAAuB,wYArI/B,YA0IF,CAAC;AAEJ,eAAO,MAAM,mBAAmB,wYA5I3B,YAgJJ,CAAC;AAEF,eAAO,MAAM,uBAAuB,wYAlJ/B,YAsJJ,CAAC;AAEF,eAAO,MAAM,mBAAmB,wYAxJ3B,YA4JJ,CAAC;AAEF,eAAO,MAAM,uBAAuB,wYA9J/B,YAmKF,CAAC;AAEJ,eAAO,MAAM,oBAAoB,wYArK5B,YAyKJ,CAAC;AAEF,eAAO,MAAM,kBAAkB,wYA3K1B,YA+KJ,CAAC;AAEF,eAAO,MAAM,4BAA4B,wYAjLpC,YAsLF,CAAC;AAEJ,eAAO,MAAM,yBAAyB,wYAxLjC,YA6LF,CAAC;AAEJ,eAAO,MAAM,qBAAqB,wYA/L7B,YA2MF,CAAC;AAEJ,eAAO,MAAM,oBAAoB,wYA7M5B,YAiNJ,CAAC;AAEF,eAAO,MAAM,oBAAoB,wYAnN5B,YAuNJ,CAAC;AAEF,eAAO,MAAM,oBAAoB,wYAzN5B,YA6NJ,CAAC;AAEF,eAAO,MAAM,wBAAwB,wYA/NhC,YAoOF,CAAC;AAEJ,eAAO,MAAM,mBAAmB,wYAtO3B,YA0OJ,CAAC;AAEF,eAAO,MAAM,uBAAuB,wYA5O/B,YAiPF,CAAC;AAEJ,eAAO,MAAM,wBAAwB,wYAnPhC,YAwPF,CAAC;AAEJ,eAAO,MAAM,sBAAsB,wYA1P9B,YA+PF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as C}from"react/jsx-runtime";import{useMemo as
|
|
1
|
+
"use client";import{jsx as C}from"react/jsx-runtime";import{useMemo as V}from"react";import{Controller as $}from"react-hook-form";import{handleError as P}from"@donotdev/core";import{CheckboxFieldComponent as j,DateFieldComponent as G,DropdownComponent as O,FileFieldComponent as B,GeoPointFieldComponent as S,ImageFieldComponent as _,MultiDropdownComponent as q,MultiInputTextFieldComponent as z,NumberFieldComponent as H,PhoneNumberComponent as J,PasswordFieldComponent as K,RadioFieldComponent as L,RangeFieldComponent as Q,MapFieldComponent as U,ReferenceFieldComponent as W,TextFieldComponent as X,TimestampFieldComponent as Y,AddressFieldComponent as Z}from"./form/fields";function ee(e){if(e){if(e instanceof RegExp)return e;try{const r=/^\/(.*)\/([gimyus]*)$/.exec(e);if(r){const[,l,a]=r;if(l)return new RegExp(l,a)}return new RegExp(e)}catch{return}}}function oe(e){if(!e)return{};const r={...e};return e.pattern&&typeof e.pattern=="string"&&(r.pattern={value:ee(e.pattern)||/.*/,message:e.messages?.pattern||"Invalid format"}),r}function o(e,r,l){return function(c){const{control:g,errors:x,fieldConfig:u,t:ie,onChange:d,placeholder:R,...v}=c,{name:t,label:p,options:s={},validation:F}=u,w=t,b=F?oe(F):void 0;return C($,{name:w,control:g,rules:b,render:({field:M})=>{const{value:m,onChange:y,...N}=M,D=(()=>{try{return r?r(m):m}catch(n){return P(n,{userMessage:`Error transforming value for field ${p||t}`,context:{fieldName:t,fieldType:u.type},severity:"warning"}),m}})(),E=n=>{try{const f=l?l(n):n;y(f),d&&d(n)}catch(f){P(f,{userMessage:`Error updating field ${p||t}`,context:{fieldName:t,fieldType:u.type},severity:"warning"}),y(n),d&&d(n)}},{prefixIcon:h,suffixIcon:A,fieldSpecific:I,...T}=s||{},k={...N,...v,label:p,value:D,onChange:E,error:!!x[t],helperText:x[t]?.message||void 0,placeholder:R||s.placeholder,clearable:s.clearable,className:s.className,...I||{},...T,...h&&{prefixIcon:h},...A&&{suffixIcon:A}};return C(e,{...k})}})}}function i(e,r){return function(a){const c=V(()=>{try{return r(a)}catch{return a}},[a]);return C(e,{...c})}}const re=i(O,e=>({...e,options:Array.isArray(e.options)?e.options:[]})),te=i(q,e=>({...e,options:Array.isArray(e.options)?e.options:[]})),ne=i(W,e=>e),le=i(L,e=>({...e,options:Array.isArray(e.options)?e.options:[]})),ae=i(J,e=>({...e,phoneNumbers:Array.isArray(e.value)?e.value:[],onPhoneNumberChange:e.onChange})),me=o(j,e=>!!e,e=>e?.target?.checked),fe=o(G,e=>e??null,e=>e?.target?.value),Ce=o(re,e=>e??null,e=>e?.target?.value),ge=o(B,e=>e??null,e=>e?.target?.value),xe=o(S,e=>e||{lat:0,lng:0},e=>e?.target?.value),Fe=o(_,e=>e??null,e=>e?.target?.value),ye=o(U,e=>e||{},e=>e?.target?.value),he=o(te,e=>Array.isArray(e)?e:[],e=>e?.target?.value),Ae=o(z,e=>Array.isArray(e)?e:[],e=>e),Pe=o(H,e=>e??"",e=>{if(e?.target?.value===""||e?.target?.value===null)return null;try{return parseFloat(e?.target?.value)}catch{return 0}}),Re=o(ae,e=>Array.isArray(e)?e:[],e=>e),ve=o(Q,e=>e??null,e=>e),we=o(le,e=>e??null,e=>e),be=o(ne,e=>e??null,e=>e),Me=o(X,e=>e??"",e=>e?.target?.value),Ne=o(K,e=>e??"",e=>e?.target?.value),De=o(Y,e=>e??null,e=>e),Ee=o(Z,e=>e??null,e=>e);export{Ee as ControlledAddressField,me as ControlledCheckboxField,fe as ControlledDateField,Ce as ControlledDropdownField,ge as ControlledFileField,xe as ControlledGeoPointField,Fe as ControlledImageField,ye as ControlledMapField,he as ControlledMultiDropdownField,Ae as ControlledMultiInputField,Pe as ControlledNumberField,Ne as ControlledPasswordField,Re as ControlledPhoneField,we as ControlledRadioField,ve as ControlledRangeField,be as ControlledReferenceField,Me as ControlledTextField,De as ControlledTimestampField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as l}from"react/jsx-runtime";import{ActionButton as a}from"@donotdev/components";import{useCrud as n}from"../useCrud";function u({requiresAuth:i=!0,user:t,disabled:s=!1,children:e,...o}){const r=n("isAvailable");return l(a,{...o,disabled:s||!r||i&&!t,children:e})}var b=u;export{b as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as o,jsxs as g}from"react/jsx-runtime";import{useForm as k}from"react-hook-form";import{Button as d,Stack as v}from"@donotdev/components";import{useTranslation as R}from"@donotdev/core";import{FormFieldRenderer as z}from"./FormFieldRenderer";function A({entity:b,onSubmit:p,t:r,className:h="",submitText:i,isLoading:e=!1,defaultValues:S,submitVariant:l="primary",secondaryButtonText:u,secondaryButtonVariant:y="outline",onSecondarySubmit:c}){const{t:F}=R("dndev"),w=r||F,{control:j,handleSubmit:m,formState:{errors:s,isSubmitting:a},setError:f}=k({defaultValues:S}),x=async t=>{try{await p(t)}catch(n){f("root",{message:n.message||"An error occurred"})}},V=async t=>{if(c)try{await c(t)}catch(n){f("root",{message:n.message||"An error occurred"})}},N=Object.entries(b);return o("form",{onSubmit:m(x),className:h,children:g(v,{gap:"medium",children:[s.root&&o("div",{className:"dndev-surface","data-variant":"destructive",style:{padding:"var(--gap-sm)",fontSize:"var(--font-size-sm)",border:"1px solid var(--destructive)",borderRadius:"var(--radius-lg)",backgroundColor:"var(--muted)",color:"var(--destructive-foreground)"},children:s.root.message}),N.map(([t,n])=>o(z,{name:t,config:n,control:j,errors:s,t:w},t)),u?g(v,{direction:"row",gap:"tight",children:[o(d,{type:"submit",disabled:a||e,variant:l,className:"dndev-w-full",children:a||e?r?r("loading",{defaultValue:"Loading..."}):"Loading...":i||(r?r("submit",{defaultValue:"Submit"}):"Submit")}),o(d,{type:"button",onClick:m(V),disabled:a||e,variant:y,className:"dndev-w-full",children:a||e?r?r("loading",{defaultValue:"Loading..."}):"Loading...":u})]}):o(d,{type:"submit",disabled:a||e,variant:l,className:"dndev-w-full",children:a||e?r?r("loading",{defaultValue:"Loading..."}):"Loading...":i||(r?r("submit",{defaultValue:"Submit"}):"Submit")})]})})}var B=A;export{A as EntityFormRenderer,B as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormFieldRenderer.d.ts","sourceRoot":"","sources":["../../src/components/FormFieldRenderer.tsx"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1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EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAGD,MAAM,MAAM,sBAAsB,CAChC,CAAC,SAAS,SAAS,EACnB,YAAY,SAAS,WAAW,GAAG,WAAW,IAC5C,iBAAiB,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;AAE5D;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,CAAC,SAAS,SAAS,EACnB,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,EACA,IAAI,EACJ,MAAM,EACN,CAAC,EACD,GAAG,KAAK,EACT,EAAE,sBAAsB,CAAC,CAAC,EAAE,YAAY,CAAC,GAAG,YAAY,CA6PxD;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e}from"react/jsx-runtime";import{handleError as m}from"@donotdev/core";import{ControlledCheckboxField as
|
|
1
|
+
"use client";import{jsx as e}from"react/jsx-runtime";import{handleError as m}from"@donotdev/core";import{ControlledCheckboxField as f,ControlledDateField as v,ControlledDropdownField as T,ControlledFileField as w,ControlledGeoPointField as M,ControlledImageField as k,ControlledMapField as P,ControlledMultiDropdownField as R,ControlledMultiInputField as A,ControlledNumberField as D,ControlledPasswordField as E,ControlledPhoneField as H,ControlledRangeField as N,ControlledRadioField as S,ControlledReferenceField as g,ControlledTextField as h,ControlledTimestampField as j,ControlledAddressField as B}from"./ControlledFields";import{AvatarFieldComponent as I,BadgeFieldComponent as $,ButtonFieldComponent as y,HiddenFieldComponent as b,TextAreaComponent as G,TextFieldComponent as U}from"./form/fields";function _({name:n,config:r,t:s,...d}){const c=u=>p=>{try{u(p)}catch(t){m(t,{userMessage:`Error updating field ${r.label||n}`,context:{fieldName:n,fieldType:r.type},severity:"warning"})}};if(r.hidden)return e(b,{name:n,value:"value"in d?d.value:""});if("control"in d&&d.control){const{control:u,errors:p}=d,t={control:u,errors:p,fieldConfig:{...r,label:r.label||n},t:s,onChange:c(F=>{})},l=F=>F;switch(r.type){case"array":return e(A,{...l(t)});case"boolean":case"checkbox":return e(f,{...l(t)});case"date":case"datetime-local":return e(v,{...l(t)});case"file":return e(w,{...l(t)});case"geopoint":return e(M,{...l(t)});case"image":return e(k,{...l(t)});case"map":return e(P,{...l(t)});case"multiselect":return e(R,{...l(t)});case"number":return e(D,{...l(t)});case"radio":return e(S,{...l(t)});case"range":return e(N,{...l(t)});case"reference":return e(g,{...l(t)});case"select":return e(T,{...l(t)});case"tel":return e(H,{...l(t)});case"timestamp":return e(j,{...l(t)});case"password":return e(E,{...l(t)});case"address":return e(B,{...l(t)});case"text":case"email":case"url":case"color":return e(h,{...l(t)});default:return m(new Error(`Unsupported field type: ${r.type}`),{userMessage:s("errors.unsupportedFieldType",{type:r.type}),context:{fieldName:n,fieldType:r.type},severity:"warning"}),e(h,{...l({...t,fieldConfig:{...r,type:"text"}})})}}const{value:i,onChange:x,error:o}=d,a=c(x),C=(()=>{switch(r.type){case"avatar":return e(I,{config:r,value:i,onChange:a,error:!!o,helperText:o||void 0,t:s,...r.options});case"badge":return e($,{config:r,value:i,onChange:a,error:!!o,helperText:o||void 0,t:s,...r.options});case"submit":return e(y,{label:r.label||n,type:"submit",onClick:()=>a(void 0),...r.options});case"reset":return e(y,{label:r.label||n,type:"reset",onClick:()=>a(void 0),...r.options});case"hidden":return e(b,{name:n,value:i});case"textarea":return e(G,{label:r.label||n,value:i,onChange:a,error:o||void 0,helperText:void 0,...r.options});default:return null}})();return C||e(U,{label:r.label||n,value:i,onChange:a,error:o||void 0,helperText:void 0,...r.options})}var Q=_;export{_ as FormFieldRenderer,Q as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as e,jsxs as r,Fragment as N}from"react/jsx-runtime";import{useState as j}from"react";import{FormProvider as w}from"react-hook-form";import{Button as s,BUTTON_VARIANT as C,Spinner as F,cn as _,Stack as i,Grid as I}from"@donotdev/components";import{useTranslation as L}from"@donotdev/core";const k=({title:m,onSubmit:c,children:u,formMethods:f,loading:n=!1,submitText:g,cancelText:v,showCancel:p=!1,onCancel:b,variant:l="default",columns:h=1,description:o})=>{const{t:d}=L("dndev"),[t,a]=j(!1),y=g||d("form.submit","Submit"),S=v||d("form.cancel","Cancel"),x=async T=>{a(!0);try{await c(T)}finally{a(!1)}},z={1:"dndev-grid-cols-1",2:"dndev-grid-cols-1 dndev-md:grid-cols-2",3:"dndev-grid-cols-1 dndev-md:grid-cols-2 dndev-md:grid-cols-3",4:"dndev-grid-cols-1 dndev-md:grid-cols-2 dndev-md:grid-cols-4"};return e(w,{...f,children:e("form",{onSubmit:x,className:_("dndev-mx-auto",{default:"dndev-surface",card:"dndev-surface",minimal:""}[l]),style:l!=="minimal"?{padding:"var(--gap-lg)"}:void 0,role:"form","aria-labelledby":"form-title",noValidate:!0,children:r(i,{gap:"large",children:[r(i,{gap:"tight",children:[e("h2",{id:"form-title",style:{fontSize:"var(--font-size-2xl)",fontWeight:600,color:"var(--foreground)"},children:m}),o&&e("p",{style:{color:"var(--muted-foreground)"},children:o})]}),e(I,{cols:h,gap:"medium",className:"dndev-w-full dndev-min-w-0",children:u}),r(i,{direction:"row",align:"center",justify:"end",gap:"medium",style:{paddingTop:"var(--gap-md)",borderTop:"1px solid var(--border)"},children:[p&&e(s,{type:"button",variant:C.OUTLINE,onClick:b,disabled:n||t,children:S}),e(s,{type:"submit",disabled:n||t,style:{minWidth:"120px"},children:n||t?r(N,{children:[e(F,{className:"me-component-gap"}),t?d("form.submitting","Submitting..."):d("form.loading","Loading...")]}):y})]})]})})})};var E=k;export{E as default};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Address field component props
|
|
3
|
+
*/
|
|
4
|
+
export interface AddressFieldComponentProps {
|
|
5
|
+
/** Field label */
|
|
6
|
+
label: string;
|
|
7
|
+
/** Address value with formatted address and coordinates */
|
|
8
|
+
value?: {
|
|
9
|
+
formatted_address: string;
|
|
10
|
+
latitude?: number;
|
|
11
|
+
longitude?: number;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
/** Change handler */
|
|
15
|
+
onChange: (value: any) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Whether to enable Google Maps autocomplete (default: false)
|
|
18
|
+
* Requires env var: VITE_GOOGLE_MAPS_API_KEY (Vite) or NEXT_PUBLIC_GOOGLE_MAPS_API_KEY (Next.js)
|
|
19
|
+
*/
|
|
20
|
+
enableGoogleMaps?: boolean;
|
|
21
|
+
/** Whether to extract district code for Paris addresses */
|
|
22
|
+
extractDistrictCode?: boolean;
|
|
23
|
+
/** Error state */
|
|
24
|
+
error?: boolean;
|
|
25
|
+
/** Helper text */
|
|
26
|
+
helperText?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Address field component with Google Maps autocomplete
|
|
30
|
+
* Integrates with Google Places API for address selection
|
|
31
|
+
*
|
|
32
|
+
* Environment variables required for Google Maps:
|
|
33
|
+
* - Vite: VITE_GOOGLE_MAPS_API_KEY
|
|
34
|
+
* - Next.js: NEXT_PUBLIC_GOOGLE_MAPS_API_KEY
|
|
35
|
+
*
|
|
36
|
+
* @component
|
|
37
|
+
* @param {AddressFieldComponentProps} props - Component props
|
|
38
|
+
* @returns {JSX.Element} Address input field with autocomplete
|
|
39
|
+
*/
|
|
40
|
+
declare const AddressFieldComponent: ({ label, value, onChange, enableGoogleMaps, extractDistrictCode, error, helperText, }: AddressFieldComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export default AddressFieldComponent;
|
|
42
|
+
//# sourceMappingURL=AddressFieldComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddressFieldComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/AddressFieldComponent.tsx"],"names":[],"mappings":"AAsBA;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,KAAK,CAAC,EAAE;QACN,iBAAiB,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IACF,qBAAqB;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,2DAA2D;IAC3D,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,kBAAkB;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,qBAAqB,GAAI,uFAQ5B,0BAA0B,4CAsQ5B,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as n,jsxs as y}from"react/jsx-runtime";import{useState as v,useEffect as C,useRef as P}from"react";import{Input as M,Popover as x,Command as q,Stack as j}from"@donotdev/components";import{useTranslation as D,getPlatformEnvVar as W}from"@donotdev/core";import{MapPin as Y}from"lucide-react";const $=({label:b,value:l,onChange:E,enableGoogleMaps:A=!1,extractDistrictCode:T,error:p,helperText:m})=>{const{t:r}=D(),[u,a]=v(!1),[c,g]=v(l?.formatted_address||""),[G,h]=v([]),[I,f]=v(!1),_=P(null),w=P(null),i=P(null),S=W("GOOGLE_MAPS_API_KEY")||"",d=A&&!!S,K=e=>{w.current&&(f(!0),w.current.getDetails({placeId:e,fields:["formatted_address","geometry","address_components"]},(t,o)=>{if(f(!1),o===window.google?.maps?.places?.PlacesServiceStatus.OK&&t){const s=t.formatted_address||"",k=t.geometry?.location?.lat(),L=t.geometry?.location?.lng(),O={formatted_address:s,latitude:k,longitude:L};if(T&&t.address_components){const z=t.address_components.find(F=>F.types.includes("postal_code"))?.long_name||"",V=z.startsWith("92")?92:parseInt(z.slice(-2),10)||null;O.district_code=V}g(s),E(O),a(!1)}}))};C(()=>{l?.formatted_address&&g(l.formatted_address)},[l]),C(()=>{if(!d)return;const e=()=>{if(window.google?.maps?.places){t();return}if(document.querySelector("#google-maps-script")){const s=setInterval(()=>{window.google?.maps?.places&&(clearInterval(s),t())},100);return}const o=document.createElement("script");o.id="google-maps-script",o.src=`https://maps.googleapis.com/maps/api/js?key=${S}&libraries=places`,o.async=!0,o.defer=!0,o.onload=()=>t(),document.head.appendChild(o)},t=()=>{window.google?.maps?.places&&(_.current=new window.google.maps.places.AutocompleteService,w.current=new window.google.maps.places.PlacesService(document.createElement("div")))};e()},[d,S]),C(()=>{if(!d||!c||!_.current||!u){h([]);return}return i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{f(!0),_.current.getPlacePredictions({input:c,types:["geocode","establishment"]},(e,t)=>{if(f(!1),t===window.google?.maps?.places?.PlacesServiceStatus.OK&&e){const o=e.map(s=>({label:s.description,value:s.place_id,description:s.structured_formatting?.secondary_text,icon:n(Y,{style:{width:"var(--size-icon-sm)",height:"var(--size-icon-sm)"}}),onSelect:()=>K(s.place_id)}));h(o)}else h([])})},300),()=>{i.current&&clearTimeout(i.current)}},[d,c,u]);const R=e=>{g(e),E({formatted_address:e})};return d?y(j,{gap:"tight",children:[y(x,{open:u,onOpenChange:a,children:[n(x.Trigger,{asChild:!0,children:n(M,{type:"text",label:b,value:c,onChange:e=>{g(e.target.value),u||a(!0)},onFocus:()=>a(!0),placeholder:r("common.address_placeholder"),"data-variant":p?"destructive":void 0,disabled:I})}),n(x.Content,{style:{width:"var(--radix-popover-trigger-width)",padding:0},children:n(q,{placeholder:r("common.search_placeholder"),emptyMessage:r(I?"common.loading":"common.no_results"),items:G,onClose:()=>a(!1)})})]}),m&&n("p",{style:{fontSize:"var(--font-size-xs)",color:p?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:m})]}):y(j,{gap:"tight",children:[n(M,{type:"text",label:b,value:c,onChange:e=>R(e.target.value),placeholder:r("common.address_placeholder"),"data-variant":p?"destructive":void 0}),m&&n("p",{style:{fontSize:"var(--font-size-xs)",color:p?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:m})]})};var X=$;export{X as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Avatar as
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Avatar as u,Input as v,cn as h,Stack as n}from"@donotdev/components";const g=({config:t,value:a,onChange:s,error:f,helperText:l,t:i,className:c,...d})=>{const m=r=>r.split(" ").map(p=>p.charAt(0)).slice(0,2).join("").toUpperCase();return o(n,{gap:"medium",children:[o(n,{direction:"row",align:"center",gap:"medium",children:[e(u,{src:a,alt:t.label||"Avatar",fallback:m(t.label||"AV"),style:{height:"var(--touch-target)",width:"var(--touch-target)"}}),e("div",{className:"dndev-flex-1",children:e(v,{type:"url",className:h("dndev-w-full",c),placeholder:i("common.enterAvatarUrl"),value:a,onChange:r=>s(r.target.value),...d})})]}),l&&e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:l})]})};var j=g;export{g as AvatarFieldComponent,j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Badge as s,Input as g,cn as f,Stack as a}from"@donotdev/components";const p=({config:u,value:r,onChange:d,error:v,helperText:n,t:o,variant:i="default",className:l,...m})=>t(a,{gap:"medium",children:[t(a,{direction:"row",align:"center",gap:"medium",children:[e(s,{variant:i,style:{minWidth:0},children:r||o("common.badgePreview")}),e("div",{className:"dndev-flex-1",children:e(g,{type:"text",className:f("dndev-w-full",l),placeholder:o("common.enterBadgeText"),value:r,onChange:c=>d(c.target.value),...m})})]}),n&&e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:n})]});var j=p;export{p as BadgeFieldComponent,j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as i}from"react/jsx-runtime";import"react";import{Button as m}from"@donotdev/components";const a=({label:t,type:o,onClick:r,variant:e,disabled:n=!1})=>i(m,{type:o,onClick:r,variant:e,disabled:n,children:t});var d=a;export{d as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t,jsxs as r}from"react/jsx-runtime";import{Checkbox as c,Label as h,Stack as s}from"@donotdev/components";const i=({label:n,checked:a=!1,onChange:e})=>r(s,{direction:"row",align:"center",gap:"tight",children:[t(c,{checked:a,onCheckedChange:o=>{e&&e({target:{checked:o}})}}),t(h,{children:n})]});var g=i;export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as n,jsxs as S}from"react/jsx-runtime";import{Input as d,Label as p,Stack as u}from"@donotdev/components";const h=({label:s,value:a,onChange:r,error:o,helperText:l,mode:e="date",...c})=>{const f=t=>{const g=t.target.value?new Date(t.target.value).toISOString():null;r(g)};let i="";if(a){const t=new Date(a);e==="date"?i=t.toISOString().split("T")[0]||"":e==="datetime-local"?i=t.toISOString().slice(0,16)||"":e==="month"?i=t.toISOString().slice(0,7):e==="time"?i=t.toISOString().slice(11,16):e==="week"&&(i=t.toISOString().split("T")[0]||"")}return S(u,{gap:"tight",children:[n(p,{style:{display:"block",fontSize:"var(--font-size-sm)",fontWeight:500},children:s}),n(d,{type:e,value:i,onChange:f,className:"dndev-w-full",...c}),l&&n("p",{style:{fontSize:"var(--font-size-xs)",color:o?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:l})]})};var O=h;export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as n,jsxs as s}from"react/jsx-runtime";import{Select as v,Label as f,Stack as m}from"@donotdev/components";import{useTranslation as h}from"@donotdev/core";const S=({label:l,value:r,options:i,error:c,helperText:a,onChange:o,onBlur:d,required:p})=>{const{t}=h("dndev"),g=r!==void 0?String(r):"",u=e=>{o&&o({target:{value:e}})};return s(m,{gap:"tight",children:[s(f,{style:{display:"block",fontSize:"var(--font-size-sm)",fontWeight:500},children:[t(l),p&&n("span",{style:{color:"var(--destructive-foreground)",marginInlineStart:"var(--gap-sm)"},children:"*"})]}),n(v,{value:g,onValueChange:u,onOpenChange:e=>!e&&d?.(),placeholder:t("actions.select","Select"),options:i.map(e=>({value:String(e.value),label:t(e.label)}))}),a&&n("p",{style:{fontSize:"var(--font-size-xs)",color:c?"var(--destructive-foreground)":"var(--muted-foreground)",marginTop:"var(--gap-sm)"},children:a})]})};var C=S;export{C as default};
|