@satoshibits/react-json-schema-builder 1.1.3 → 1.1.5

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.
Files changed (196) hide show
  1. package/dist/index.cjs.js +1 -1
  2. package/dist/index.cjs10.js +1 -1
  3. package/dist/index.cjs10.js.map +1 -1
  4. package/dist/index.cjs11.js +1 -1
  5. package/dist/index.cjs11.js.map +1 -1
  6. package/dist/index.cjs12.js +1 -1
  7. package/dist/index.cjs12.js.map +1 -1
  8. package/dist/index.cjs13.js +1 -1
  9. package/dist/index.cjs13.js.map +1 -1
  10. package/dist/index.cjs14.js +1 -1
  11. package/dist/index.cjs14.js.map +1 -1
  12. package/dist/index.cjs15.js +6 -1
  13. package/dist/index.cjs15.js.map +1 -1
  14. package/dist/index.cjs16.js +1 -1
  15. package/dist/index.cjs16.js.map +1 -1
  16. package/dist/index.cjs17.js +1 -1
  17. package/dist/index.cjs17.js.map +1 -1
  18. package/dist/index.cjs18.js +1 -1
  19. package/dist/index.cjs18.js.map +1 -1
  20. package/dist/index.cjs19.js +1 -1
  21. package/dist/index.cjs19.js.map +1 -1
  22. package/dist/index.cjs2.js +1 -1
  23. package/dist/index.cjs2.js.map +1 -1
  24. package/dist/index.cjs20.js +1 -1
  25. package/dist/index.cjs20.js.map +1 -1
  26. package/dist/index.cjs21.js +1 -1
  27. package/dist/index.cjs21.js.map +1 -1
  28. package/dist/index.cjs22.js +1 -1
  29. package/dist/index.cjs22.js.map +1 -1
  30. package/dist/index.cjs23.js +1 -6
  31. package/dist/index.cjs23.js.map +1 -1
  32. package/dist/index.cjs24.js +1 -6
  33. package/dist/index.cjs24.js.map +1 -1
  34. package/dist/index.cjs25.js +1 -6
  35. package/dist/index.cjs25.js.map +1 -1
  36. package/dist/index.cjs26.js +1 -1
  37. package/dist/index.cjs26.js.map +1 -1
  38. package/dist/index.cjs27.js +1 -1
  39. package/dist/index.cjs27.js.map +1 -1
  40. package/dist/index.cjs28.js +6 -1
  41. package/dist/index.cjs28.js.map +1 -1
  42. package/dist/index.cjs29.js +6 -1
  43. package/dist/index.cjs29.js.map +1 -1
  44. package/dist/index.cjs3.js +1 -1
  45. package/dist/index.cjs3.js.map +1 -1
  46. package/dist/index.cjs30.js +1 -1
  47. package/dist/index.cjs30.js.map +1 -1
  48. package/dist/index.cjs31.js +1 -1
  49. package/dist/index.cjs34.js +1 -1
  50. package/dist/index.cjs36.js +1 -1
  51. package/dist/index.cjs37.js +1 -1
  52. package/dist/index.cjs38.js +1 -1
  53. package/dist/index.cjs39.js +1 -1
  54. package/dist/index.cjs4.js +1 -1
  55. package/dist/index.cjs4.js.map +1 -1
  56. package/dist/index.cjs41.js +1 -1
  57. package/dist/index.cjs42.js +1 -1
  58. package/dist/index.cjs42.js.map +1 -1
  59. package/dist/index.cjs43.js +1 -1
  60. package/dist/index.cjs47.js +1 -1
  61. package/dist/index.cjs5.js +1 -1
  62. package/dist/index.cjs5.js.map +1 -1
  63. package/dist/index.cjs55.js +1 -5
  64. package/dist/index.cjs55.js.map +1 -1
  65. package/dist/index.cjs56.js +1 -1
  66. package/dist/index.cjs56.js.map +1 -1
  67. package/dist/index.cjs57.js +1 -1
  68. package/dist/index.cjs57.js.map +1 -1
  69. package/dist/index.cjs58.js +1 -1
  70. package/dist/index.cjs58.js.map +1 -1
  71. package/dist/index.cjs59.js +1 -1
  72. package/dist/index.cjs59.js.map +1 -1
  73. package/dist/index.cjs6.js +1 -1
  74. package/dist/index.cjs6.js.map +1 -1
  75. package/dist/index.cjs60.js +1 -1
  76. package/dist/index.cjs60.js.map +1 -1
  77. package/dist/index.cjs61.js +1 -1
  78. package/dist/index.cjs61.js.map +1 -1
  79. package/dist/index.cjs62.js +5 -1
  80. package/dist/index.cjs62.js.map +1 -1
  81. package/dist/index.cjs63.js +1 -1
  82. package/dist/index.cjs63.js.map +1 -1
  83. package/dist/index.cjs65.js +1 -1
  84. package/dist/index.cjs67.js +1 -1
  85. package/dist/index.cjs69.js +1 -1
  86. package/dist/index.cjs7.js +1 -1
  87. package/dist/index.cjs7.js.map +1 -1
  88. package/dist/index.cjs71.js +1 -1
  89. package/dist/index.cjs72.js +1 -1
  90. package/dist/index.cjs75.js +1 -1
  91. package/dist/index.cjs78.js +1 -1
  92. package/dist/index.cjs8.js +1 -1
  93. package/dist/index.cjs8.js.map +1 -1
  94. package/dist/index.cjs81.js +1 -1
  95. package/dist/index.cjs9.js +1 -1
  96. package/dist/index.cjs9.js.map +1 -1
  97. package/dist/index.d.mts +5 -4
  98. package/dist/index.d.mts.map +1 -1
  99. package/dist/index.es.js +18 -28
  100. package/dist/index.es10.js +22 -22
  101. package/dist/index.es10.js.map +1 -1
  102. package/dist/index.es11.js +14 -42
  103. package/dist/index.es11.js.map +1 -1
  104. package/dist/index.es12.js +5 -65
  105. package/dist/index.es12.js.map +1 -1
  106. package/dist/index.es13.js +43 -24
  107. package/dist/index.es13.js.map +1 -1
  108. package/dist/index.es14.js +21 -126
  109. package/dist/index.es14.js.map +1 -1
  110. package/dist/index.es15.js +13 -20
  111. package/dist/index.es15.js.map +1 -1
  112. package/dist/index.es16.js +129 -130
  113. package/dist/index.es16.js.map +1 -1
  114. package/dist/index.es17.js +3 -137
  115. package/dist/index.es17.js.map +1 -1
  116. package/dist/index.es18.js +20 -61
  117. package/dist/index.es18.js.map +1 -1
  118. package/dist/index.es19.js +65 -10
  119. package/dist/index.es19.js.map +1 -1
  120. package/dist/index.es2.js +156 -113
  121. package/dist/index.es2.js.map +1 -1
  122. package/dist/index.es20.js +134 -22
  123. package/dist/index.es20.js.map +1 -1
  124. package/dist/index.es21.js +131 -421
  125. package/dist/index.es21.js.map +1 -1
  126. package/dist/index.es22.js +63 -5
  127. package/dist/index.es22.js.map +1 -1
  128. package/dist/index.es23.js +11 -13
  129. package/dist/index.es23.js.map +1 -1
  130. package/dist/index.es24.js +23 -16
  131. package/dist/index.es24.js.map +1 -1
  132. package/dist/index.es25.js +428 -13
  133. package/dist/index.es25.js.map +1 -1
  134. package/dist/index.es26.js +7 -13
  135. package/dist/index.es26.js.map +1 -1
  136. package/dist/index.es27.js +9 -3
  137. package/dist/index.es27.js.map +1 -1
  138. package/dist/index.es28.js +13 -19
  139. package/dist/index.es28.js.map +1 -1
  140. package/dist/index.es29.js +19 -23
  141. package/dist/index.es29.js.map +1 -1
  142. package/dist/index.es3.js +129 -340
  143. package/dist/index.es3.js.map +1 -1
  144. package/dist/index.es30.js +4 -7
  145. package/dist/index.es30.js.map +1 -1
  146. package/dist/index.es31.js +1 -1
  147. package/dist/index.es34.js +1 -1
  148. package/dist/index.es36.js +7 -7
  149. package/dist/index.es37.js +3 -3
  150. package/dist/index.es38.js +3 -3
  151. package/dist/index.es39.js +2 -2
  152. package/dist/index.es4.js +92 -70
  153. package/dist/index.es4.js.map +1 -1
  154. package/dist/index.es41.js +2 -2
  155. package/dist/index.es42.js +4 -4
  156. package/dist/index.es43.js +6 -6
  157. package/dist/index.es47.js +4 -4
  158. package/dist/index.es5.js +225 -79
  159. package/dist/index.es5.js.map +1 -1
  160. package/dist/index.es55.js +30 -252
  161. package/dist/index.es55.js.map +1 -1
  162. package/dist/index.es56.js +26 -21
  163. package/dist/index.es56.js.map +1 -1
  164. package/dist/index.es57.js +6 -32
  165. package/dist/index.es57.js.map +1 -1
  166. package/dist/index.es58.js +62 -23
  167. package/dist/index.es58.js.map +1 -1
  168. package/dist/index.es59.js +29 -6
  169. package/dist/index.es59.js.map +1 -1
  170. package/dist/index.es6.js +117 -57
  171. package/dist/index.es6.js.map +1 -1
  172. package/dist/index.es60.js +4 -64
  173. package/dist/index.es60.js.map +1 -1
  174. package/dist/index.es61.js +24 -29
  175. package/dist/index.es61.js.map +1 -1
  176. package/dist/index.es62.js +254 -5
  177. package/dist/index.es62.js.map +1 -1
  178. package/dist/index.es63.js +21 -24
  179. package/dist/index.es63.js.map +1 -1
  180. package/dist/index.es65.js +2 -2
  181. package/dist/index.es67.js +3 -3
  182. package/dist/index.es69.js +2 -2
  183. package/dist/index.es7.js +345 -48
  184. package/dist/index.es7.js.map +1 -1
  185. package/dist/index.es71.js +4 -4
  186. package/dist/index.es72.js +1 -1
  187. package/dist/index.es75.js +1 -1
  188. package/dist/index.es78.js +1 -1
  189. package/dist/index.es8.js +73 -163
  190. package/dist/index.es8.js.map +1 -1
  191. package/dist/index.es81.js +1 -1
  192. package/dist/index.es9.js +18 -3
  193. package/dist/index.es9.js.map +1 -1
  194. package/dist/packages/builder/add-dialog.d.ts +5 -5
  195. package/dist/packages/builder/context.d.ts.map +1 -1
  196. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.es20.js","sources":["../src/components/depounced-input.tsx"],"sourcesContent":["import { forwardRef, useState, useEffect } from \"react\";\nimport { useDebounce } from \"use-debounce\";\nimport { Input } from \"@/components/ui/input\";\n\nexport const DebouncedInput = forwardRef<\n HTMLInputElement,\n React.ComponentProps<\"input\"> & {\n onDebounce?: (newVal: string) => void;\n delay?: number;\n }\n>(({ onDebounce, type, delay = 200, value, ...props }, ref) => {\n const [inputValue, setInputValue] = useState(value);\n\n const [debouncedValue] = useDebounce(inputValue, delay);\n\n useEffect(() => {\n //prevents the initial value from being sent\n if (typeof debouncedValue === \"string\" && debouncedValue !== value) {\n onDebounce?.(debouncedValue);\n }\n }, [debouncedValue]);\n\n return (\n <Input\n {...props}\n type={type}\n value={inputValue}\n ref={ref}\n onChange={(e) => {\n setInputValue(e.target.value);\n }}\n />\n );\n});\nDebouncedInput.displayName = \"DebouncedInput\";\n"],"names":["DebouncedInput","forwardRef","onDebounce","type","delay","value","props","ref","inputValue","setInputValue","useState","debouncedValue","useDebounce","useEffect","jsx","Input","e"],"mappings":";;;;AAIO,MAAMA,IAAiBC,EAM5B,CAAC,EAAE,YAAAC,GAAY,MAAAC,GAAM,OAAAC,IAAQ,KAAK,OAAAC,GAAO,GAAGC,EAAM,GAAGC,MAAQ;AAC7D,QAAM,CAACC,GAAYC,CAAa,IAAIC,EAASL,CAAK,GAE5C,CAACM,CAAc,IAAIC,EAAYJ,GAAYJ,CAAK;AAEtD,SAAAS,EAAU,MAAM;AAEd,IAAI,OAAOF,KAAmB,YAAYA,MAAmBN,KAC3DH,IAAaS,CAAc;AAAA,EAC7B,GACC,CAACA,CAAc,CAAC,GAGjB,gBAAAG;AAAA,IAACC;AAAA,IAAA;AAAA,MACE,GAAGT;AAAA,MACJ,MAAAH;AAAA,MACA,OAAOK;AAAA,MACP,KAAAD;AAAA,MACA,UAAU,CAACS,MAAM;AACD,QAAAP,EAAAO,EAAE,OAAO,KAAK;AAAA,MAAA;AAAA,IAC9B;AAAA,EACF;AAEJ,CAAC;AACDhB,EAAe,cAAc;"}
1
+ {"version":3,"file":"index.es20.js","sources":["../src/packages/builder/edit-dialog.tsx"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport { Button } from \"@/components/ui/button\";\nimport {\n Dialog,\n DialogContent,\n DialogHeader,\n DialogTitle,\n DialogFooter,\n DialogDescription,\n} from \"@/components/ui/dialog\";\nimport { Label } from \"@/components/ui/label\";\n\nimport type { JSONSchema7 } from \"json-schema\";\nimport { clone } from \"remeda\";\nimport { Constraint, useConstraints } from \"@/packages/constraints/context\";\nimport ConstraintsAdd from \"@/packages/constraints/constraint-add\";\nimport { Separator } from \"@/components/ui/separator\";\nimport { z } from \"zod\";\nimport { AddFormSchema } from \"./add-dialog\";\nimport { useForm } from \"react-hook-form\";\nimport { zodResolver } from \"@hookform/resolvers/zod\";\nimport { OperationError } from \"./shared-types\";\nimport { Form } from \"@/components/ui/form\";\nimport { useSchema } from \"./context\";\n\nexport interface EditPropertyDialogProps {\n property: JSONSchema7;\n propertyKey: string;\n open: boolean;\n onOpenChange: (open: boolean) => void;\n onSubmit: (\n params: Parameters<ReturnType<typeof useSchema>[\"handlePropertyChange\"]>,\n ) => void;\n}\n\nconst EditFormSchema = AddFormSchema.pick({\n constraints: true,\n property: true,\n});\n\n/**\n * Handles editing a constraints and other properties of a JSON schema property\n * that aren't shown in the main UI.\n */\nexport function EditPropertyDialog({\n open,\n onOpenChange,\n onSubmit,\n property: propertyToEdit,\n propertyKey,\n}: EditPropertyDialogProps) {\n const form = useForm<z.infer<typeof EditFormSchema>>({\n resolver: zodResolver(EditFormSchema),\n defaultValues: {\n property: propertyToEdit,\n },\n });\n\n const currentConstraints = form.watch(\"constraints\");\n\n const {\n getConstraintDefinitionsForType,\n getRendererForConstraint,\n validateConstraintValue,\n } = useConstraints();\n\n const handleSubmit = (data: z.infer<typeof EditFormSchema>) => {\n const { constraints } = data;\n const propertyUpdatesOnly: JSONSchema7 = {\n ...constraints?.reduce((acc, constraint) => {\n return {\n ...acc,\n [constraint.name]: constraint.value,\n } satisfies JSONSchema7;\n }, {}),\n };\n onSubmit([propertyKey, propertyUpdatesOnly]);\n form.reset();\n };\n\n const handleConstraintChange = (\n index: number,\n newVal: Constraint[\"value\"],\n ) => {\n const constraintsCopy = clone(currentConstraints);\n\n const constraintToChange = constraintsCopy?.[index];\n\n if (!constraintToChange) {\n form.setError(`constraints.${index}`, {\n message: \"The constraint was not found\",\n type: \"constraint_not_found\",\n });\n return;\n }\n\n const validationResult = validateConstraintValue(\n constraintToChange.name,\n newVal,\n );\n\n if (validationResult.status === \"error\") {\n let message = validationResult.message;\n if (validationResult.code === \"invalid\") {\n message = `${message}: ${validationResult.error?.map((i) => i.message).join(\", \")}`;\n }\n form.setError(`constraints.${index}`, {\n type: validationResult.code,\n message,\n });\n return;\n }\n\n //edit reference\n constraintToChange.value = newVal;\n form.setValue(\"constraints\", constraintsCopy);\n form.clearErrors(`constraints.${index}`);\n };\n\n const handleRemoveConstraint = (constraintName: Constraint[\"name\"]) => {\n if (!currentConstraints) return;\n const copy = clone(currentConstraints);\n const newConstraints = copy.filter((c) => c.name !== constraintName);\n form.setValue(\"constraints\", newConstraints);\n };\n\n const availableDefinitions = useMemo(() => {\n return getConstraintDefinitionsForType(\n typeof propertyToEdit?.type === \"string\" ? propertyToEdit.type : \"\",\n );\n }, [propertyToEdit.type]);\n\n useEffect(() => {\n //get the current constraints from the property based on the available definitions\n const newConstraints: Constraint[] = [];\n for (const constraintDef of availableDefinitions) {\n if (constraintDef.name in propertyToEdit) {\n newConstraints.push({\n name: constraintDef.name,\n value: propertyToEdit[constraintDef.name],\n });\n }\n }\n form.setValue(\"constraints\", newConstraints);\n }, [availableDefinitions]);\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Edit</DialogTitle>\n <DialogDescription>\n Constraints and other properties\n </DialogDescription>\n </DialogHeader>\n <Form {...form}>\n <form\n onSubmit={form.handleSubmit(handleSubmit)}\n className=\"space-y-4\"\n data-testid=\"edit-property-form\"\n >\n {availableDefinitions.length ? (\n <div className=\"space-y-2\">\n <Label>Constraints</Label>\n <ConstraintsAdd\n addedConstraints={currentConstraints ?? []}\n availableDefinitions={availableDefinitions}\n onAdd={(newConstraints) => {\n form.setValue(\"constraints\", newConstraints);\n }}\n />\n <Separator />\n {currentConstraints?.map((constraint, i) => {\n const Renderer = getRendererForConstraint(constraint.name);\n if (!Renderer) return null;\n\n const error = form.formState.errors.constraints?.[i];\n let mappedError: OperationError | undefined;\n\n if (error) {\n mappedError = {\n code: error?.type ?? \"INVALID\",\n message: error.message ?? \"An error occurred\",\n };\n }\n\n return (\n <Renderer\n key={constraint.name}\n constraintName={constraint.name}\n value={constraint.value}\n onConstraintChange={(newVal) => {\n handleConstraintChange(i, newVal);\n }}\n onRemoveConstraint={() => {\n handleRemoveConstraint(constraint.name);\n }}\n error={mappedError}\n />\n );\n })}\n </div>\n ) : null}\n\n <DialogFooter>\n <Button type=\"submit\">Save</Button>\n </DialogFooter>\n </form>\n </Form>\n </DialogContent>\n </Dialog>\n );\n}\n"],"names":["EditFormSchema","AddFormSchema","EditPropertyDialog","open","onOpenChange","onSubmit","propertyToEdit","propertyKey","form","useForm","zodResolver","currentConstraints","getConstraintDefinitionsForType","getRendererForConstraint","validateConstraintValue","useConstraints","handleSubmit","data","constraints","propertyUpdatesOnly","acc","constraint","handleConstraintChange","index","newVal","constraintsCopy","clone","constraintToChange","validationResult","message","i","handleRemoveConstraint","constraintName","newConstraints","c","availableDefinitions","useMemo","useEffect","constraintDef","jsx","Dialog","DialogContent","jsxs","DialogHeader","DialogTitle","DialogDescription","Form","Label","ConstraintsAdd","Separator","Renderer","error","mappedError","DialogFooter","Button"],"mappings":";;;;;;;;;;;;;AAmCA,MAAMA,IAAiBC,EAAc,KAAK;AAAA,EACxC,aAAa;AAAA,EACb,UAAU;AACZ,CAAC;AAMM,SAASC,GAAmB;AAAA,EACjC,MAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAUC;AAAA,EACV,aAAAC;AACF,GAA4B;AAC1B,QAAMC,IAAOC,EAAwC;AAAA,IACnD,UAAUC,EAAYV,CAAc;AAAA,IACpC,eAAe;AAAA,MACb,UAAUM;AAAA,IAAA;AAAA,EACZ,CACD,GAEKK,IAAqBH,EAAK,MAAM,aAAa,GAE7C;AAAA,IACJ,iCAAAI;AAAA,IACA,0BAAAC;AAAA,IACA,yBAAAC;AAAA,MACEC,EAAe,GAEbC,IAAe,CAACC,MAAyC;AACvD,UAAA,EAAE,aAAAC,MAAgBD,GAClBE,IAAmC;AAAA,MACvC,GAAGD,GAAa,OAAO,CAACE,GAAKC,OACpB;AAAA,QACL,GAAGD;AAAA,QACH,CAACC,EAAW,IAAI,GAAGA,EAAW;AAAA,MAChC,IACC,CAAE,CAAA;AAAA,IACP;AACS,IAAAhB,EAAA,CAACE,GAAaY,CAAmB,CAAC,GAC3CX,EAAK,MAAM;AAAA,EACb,GAEMc,IAAyB,CAC7BC,GACAC,MACG;AACG,UAAAC,IAAkBC,EAAMf,CAAkB,GAE1CgB,IAAqBF,IAAkBF,CAAK;AAElD,QAAI,CAACI,GAAoB;AAClB,MAAAnB,EAAA,SAAS,eAAee,CAAK,IAAI;AAAA,QACpC,SAAS;AAAA,QACT,MAAM;AAAA,MAAA,CACP;AACD;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AAAA,kBACA,OAAO+B;AAAA,gBAAA;AAAA,gBATF/B,EAAW;AAAA,cAUlB;AAAA,YAEH,CAAA;AAAA,UAAA,EAAA,CACH,IACE;AAAA,4BAEHgC,GACC,EAAA,UAAA,gBAAAd,EAACe,KAAO,MAAK,UAAS,iBAAI,CAAA,EAC5B,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA,EAEJ,CAAA;AAAA,EAAA,EAAA,CACF,EACF,CAAA;AAEJ;"}
@@ -1,431 +1,141 @@
1
- import { jsx as e, jsxs as i } from "react/jsx-runtime";
2
- import { Button as x } from "./index.es11.js";
3
- import { zodResolver as K } from "./index.es40.js";
4
- import { Dialog as M, DialogContent as _, DialogHeader as B, DialogTitle as H, DialogDescription as J, DialogFooter as G } from "./index.es37.js";
5
- import { Input as O } from "./index.es28.js";
6
- import { Label as Q } from "./index.es15.js";
7
- import { Select as A, SelectTrigger as j, SelectValue as F, SelectContent as N, SelectItem as s } from "./index.es14.js";
8
- import { Switch as U } from "./index.es13.js";
9
- import { DebouncedInput as V } from "./index.es20.js";
10
- import { a as b } from "./index.es10.js";
11
- import W from "./index.es42.js";
12
- import { useConstraints as X } from "./index.es4.js";
13
- import Y from "./index.es38.js";
14
- import { Separator as Z } from "./index.es39.js";
15
- import { z as t } from "zod";
16
- import { useForm as ee } from "react-hook-form";
17
- import { Form as re, FormField as m, FormItem as p, FormLabel as u, FormControl as h, FormMessage as y } from "./index.es41.js";
18
- const g = t.enum([
19
- "string",
20
- "number",
21
- "integer",
22
- "boolean",
23
- "object",
24
- "array",
25
- "null"
26
- ]), ne = t.object({
27
- key: t.string().trim().min(1, { message: "Key must be at least 1 character long" }),
28
- property: t.object({
29
- title: t.string().trim().min(1, { message: "Title must be at least 1 character long" }),
30
- type: g.or(t.array(g)),
31
- description: t.string().optional(),
32
- enum: t.array(
33
- t.string().or(t.number()).or(t.null()).or(t.boolean()).or(t.record(t.string(), t.any()))
34
- ).optional(),
35
- items: t.object({
36
- type: g.or(t.array(g))
37
- }).or(
38
- t.array(
39
- t.object({ type: g.or(t.array(g)) }).or(t.boolean())
40
- )
41
- ).or(t.boolean()).optional()
42
- }),
43
- required: t.boolean().default(!1),
44
- constraints: t.array(
45
- t.custom(() => ({
46
- name: t.string().trim().min(1),
47
- value: t.any()
48
- }))
49
- ).optional()
50
- });
51
- function Ce({
52
- open: T,
53
- onOpenChange: E,
54
- onSubmit: R
1
+ import { jsx as e, jsxs as r } from "react/jsx-runtime";
2
+ import { Root as n, Content as i, Title as s, Description as d, Cancel as c, Action as u, Portal as f, Overlay as m } from "./index.es47.js";
3
+ import { cn as o } from "./index.es12.js";
4
+ import { buttonVariants as l } from "./index.es13.js";
5
+ function N({
6
+ ...t
55
7
  }) {
56
- const n = ee({
57
- resolver: K(ne),
58
- defaultValues: {
59
- key: "",
60
- property: {
61
- title: ""
8
+ return /* @__PURE__ */ e(n, { "data-slot": "alert-dialog", ...t });
9
+ }
10
+ function g({
11
+ ...t
12
+ }) {
13
+ return /* @__PURE__ */ e(f, { "data-slot": "alert-dialog-portal", ...t });
14
+ }
15
+ function p({
16
+ className: t,
17
+ ...a
18
+ }) {
19
+ return /* @__PURE__ */ e(
20
+ m,
21
+ {
22
+ "data-slot": "alert-dialog-overlay",
23
+ className: o(
24
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80",
25
+ t
26
+ ),
27
+ ...a
28
+ }
29
+ );
30
+ }
31
+ function b({
32
+ className: t,
33
+ ...a
34
+ }) {
35
+ return /* @__PURE__ */ r(g, { children: [
36
+ /* @__PURE__ */ e(p, {}),
37
+ /* @__PURE__ */ e(
38
+ i,
39
+ {
40
+ "data-slot": "alert-dialog-content",
41
+ className: o(
42
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
43
+ t
44
+ ),
45
+ ...a
62
46
  }
47
+ )
48
+ ] });
49
+ }
50
+ function y({
51
+ className: t,
52
+ ...a
53
+ }) {
54
+ return /* @__PURE__ */ e(
55
+ "div",
56
+ {
57
+ "data-slot": "alert-dialog-header",
58
+ className: o("flex flex-col gap-2 text-center sm:text-left", t),
59
+ ...a
63
60
  }
64
- }), v = n.watch("constraints"), C = n.watch("property"), I = n.watch("property.enum"), w = n.watch("property.type"), {
65
- getConstraintDefinitionsForType: k,
66
- getRendererForConstraint: P,
67
- validateConstraintValue: q
68
- } = X(), $ = (r) => {
69
- const { key: o, property: a, required: l, constraints: c } = r, d = {
70
- ...a,
71
- ...c?.reduce((f, S) => ({
72
- ...f,
73
- [S.name]: S.value
74
- }), {})
75
- };
76
- R(o, d, l), n.reset();
77
- }, z = (r, o) => {
78
- const a = b(v), l = a?.[r];
79
- if (!l) {
80
- n.setError(`constraints.${r}`, {
81
- message: "The constraint was not found",
82
- type: "constraint_not_found"
83
- });
84
- return;
61
+ );
62
+ }
63
+ function w({
64
+ className: t,
65
+ ...a
66
+ }) {
67
+ return /* @__PURE__ */ e(
68
+ "div",
69
+ {
70
+ "data-slot": "alert-dialog-footer",
71
+ className: o(
72
+ "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
73
+ t
74
+ ),
75
+ ...a
85
76
  }
86
- const c = q(
87
- l.name,
88
- o
89
- );
90
- if (c.status === "error") {
91
- let d = c.message;
92
- c.code === "invalid" && (d = `${d}: ${c.error?.map((f) => f.message).join(", ")}`), n.setError(`constraints.${r}`, {
93
- type: c.code,
94
- message: d
95
- });
96
- return;
77
+ );
78
+ }
79
+ function C({
80
+ className: t,
81
+ ...a
82
+ }) {
83
+ return /* @__PURE__ */ e(
84
+ s,
85
+ {
86
+ "data-slot": "alert-dialog-title",
87
+ className: o("text-lg font-semibold", t),
88
+ ...a
89
+ }
90
+ );
91
+ }
92
+ function z({
93
+ className: t,
94
+ ...a
95
+ }) {
96
+ return /* @__PURE__ */ e(
97
+ d,
98
+ {
99
+ "data-slot": "alert-dialog-description",
100
+ className: o("text-muted-foreground text-sm", t),
101
+ ...a
102
+ }
103
+ );
104
+ }
105
+ function h({
106
+ className: t,
107
+ ...a
108
+ }) {
109
+ return /* @__PURE__ */ e(
110
+ u,
111
+ {
112
+ className: o(l(), t),
113
+ ...a
114
+ }
115
+ );
116
+ }
117
+ function j({
118
+ className: t,
119
+ ...a
120
+ }) {
121
+ return /* @__PURE__ */ e(
122
+ c,
123
+ {
124
+ className: o(l({ variant: "outline" }), t),
125
+ ...a
97
126
  }
98
- l.value = o, n.setValue("constraints", a), n.clearErrors(`constraints.${r}`);
99
- }, L = (r) => {
100
- if (!v) return;
101
- const a = b(v).filter((l) => l.name !== r);
102
- n.setValue("constraints", a);
103
- }, D = k(
104
- typeof C?.type == "string" ? C.type : ""
105
127
  );
106
- return /* @__PURE__ */ e(M, { open: T, onOpenChange: E, children: /* @__PURE__ */ i(_, { "data-testid": "add-property-dialog", children: [
107
- /* @__PURE__ */ i(B, { children: [
108
- /* @__PURE__ */ e(H, { children: "Add" }),
109
- /* @__PURE__ */ e(J, { children: "Required property values and constraints" })
110
- ] }),
111
- /* @__PURE__ */ e(re, { ...n, children: /* @__PURE__ */ i(
112
- "form",
113
- {
114
- onSubmit: (r) => {
115
- r.stopPropagation(), r.preventDefault(), n.handleSubmit($)(r);
116
- },
117
- className: "space-y-4",
118
- "data-testid": "add-property-form",
119
- id: "add-property-form",
120
- children: [
121
- /* @__PURE__ */ e("div", { className: "space-y-2", children: /* @__PURE__ */ e(
122
- m,
123
- {
124
- control: n.control,
125
- name: "key",
126
- render: ({ field: r }) => {
127
- const { onChange: o, ...a } = r;
128
- return /* @__PURE__ */ i(p, { children: [
129
- /* @__PURE__ */ e(u, { children: "Property Key" }),
130
- /* @__PURE__ */ e(h, { children: /* @__PURE__ */ e(
131
- V,
132
- {
133
- ...a,
134
- onDebounce: (l) => o(l)
135
- }
136
- ) }),
137
- /* @__PURE__ */ e(y, {})
138
- ] });
139
- }
140
- }
141
- ) }),
142
- /* @__PURE__ */ e("div", { className: "space-y-2", children: /* @__PURE__ */ e(
143
- m,
144
- {
145
- control: n.control,
146
- name: "property.title",
147
- render: ({ field: r }) => {
148
- const { onChange: o, ...a } = r;
149
- return /* @__PURE__ */ i(p, { children: [
150
- /* @__PURE__ */ e(u, { children: "Property Title" }),
151
- /* @__PURE__ */ e(h, { children: /* @__PURE__ */ e(
152
- V,
153
- {
154
- ...a,
155
- onDebounce: (l) => o(l)
156
- }
157
- ) }),
158
- /* @__PURE__ */ e(y, {})
159
- ] });
160
- }
161
- }
162
- ) }),
163
- /* @__PURE__ */ e("div", { className: "space-y-2", children: /* @__PURE__ */ e(
164
- m,
165
- {
166
- control: n.control,
167
- name: "property.type",
168
- render: ({ field: r }) => /* @__PURE__ */ i(p, { children: [
169
- /* @__PURE__ */ e(u, { children: "Type" }),
170
- /* @__PURE__ */ e(h, { children: /* @__PURE__ */ i(
171
- A,
172
- {
173
- value: Array.isArray(r.value) ? void 0 : r.value,
174
- onValueChange: (o) => {
175
- o === "enum" ? n.setValue("property.enum", []) : n.setValue("property.enum", void 0), r.value === "array" && o !== "array" && (n.clearErrors("property.items"), n.setValue("property.items", void 0)), r.onChange(o);
176
- },
177
- children: [
178
- /* @__PURE__ */ e(
179
- j,
180
- {
181
- className: "w-full",
182
- "aria-label": "Select type",
183
- children: /* @__PURE__ */ e(F, {})
184
- }
185
- ),
186
- /* @__PURE__ */ i(N, { children: [
187
- /* @__PURE__ */ e(
188
- s,
189
- {
190
- value: "string",
191
- children: "string"
192
- }
193
- ),
194
- /* @__PURE__ */ e(
195
- s,
196
- {
197
- value: "number",
198
- children: "number"
199
- }
200
- ),
201
- /* @__PURE__ */ e(
202
- s,
203
- {
204
- value: "integer",
205
- children: "integer"
206
- }
207
- ),
208
- /* @__PURE__ */ e(
209
- s,
210
- {
211
- value: "boolean",
212
- children: "boolean"
213
- }
214
- ),
215
- /* @__PURE__ */ e(
216
- s,
217
- {
218
- value: "object",
219
- children: "object"
220
- }
221
- ),
222
- /* @__PURE__ */ e(
223
- s,
224
- {
225
- value: "array",
226
- children: "array"
227
- }
228
- ),
229
- /* @__PURE__ */ e(
230
- s,
231
- {
232
- value: "null",
233
- children: "null"
234
- }
235
- )
236
- ] })
237
- ]
238
- }
239
- ) }),
240
- /* @__PURE__ */ e(y, {})
241
- ] })
242
- }
243
- ) }),
244
- w === "array" && /* @__PURE__ */ e("div", { className: "space-y-2", children: /* @__PURE__ */ e(
245
- m,
246
- {
247
- control: n.control,
248
- name: "property.items.type",
249
- render: ({ field: r }) => /* @__PURE__ */ i(p, { children: [
250
- /* @__PURE__ */ e(u, { children: "Items of type" }),
251
- /* @__PURE__ */ e(h, { children: /* @__PURE__ */ i(
252
- A,
253
- {
254
- value: Array.isArray(r.value) ? void 0 : r.value,
255
- onValueChange: (o) => {
256
- n.clearErrors("property.items.type"), n.setValue(
257
- "property.items.type",
258
- o
259
- );
260
- },
261
- children: [
262
- /* @__PURE__ */ e(
263
- j,
264
- {
265
- className: "w-full",
266
- "aria-label": "Select items of type",
267
- children: /* @__PURE__ */ e(F, { placeholder: "Select item type" })
268
- }
269
- ),
270
- /* @__PURE__ */ i(N, { children: [
271
- /* @__PURE__ */ e(
272
- s,
273
- {
274
- value: "string",
275
- children: "string"
276
- }
277
- ),
278
- /* @__PURE__ */ e(
279
- s,
280
- {
281
- value: "number",
282
- children: "number"
283
- }
284
- ),
285
- /* @__PURE__ */ e(
286
- s,
287
- {
288
- value: "integer",
289
- children: "integer"
290
- }
291
- ),
292
- /* @__PURE__ */ e(
293
- s,
294
- {
295
- value: "boolean",
296
- children: "boolean"
297
- }
298
- ),
299
- /* @__PURE__ */ e(
300
- s,
301
- {
302
- value: "object",
303
- children: "object"
304
- }
305
- ),
306
- /* @__PURE__ */ e(
307
- s,
308
- {
309
- value: "array",
310
- children: "array"
311
- }
312
- ),
313
- /* @__PURE__ */ e(
314
- s,
315
- {
316
- value: "null",
317
- children: "null"
318
- }
319
- )
320
- ] })
321
- ]
322
- }
323
- ) }),
324
- /* @__PURE__ */ e(y, {})
325
- ] })
326
- }
327
- ) }),
328
- /* @__PURE__ */ e("div", { className: "flex items-center space-x-2", children: /* @__PURE__ */ e(
329
- m,
330
- {
331
- control: n.control,
332
- name: "required",
333
- render: ({ field: r }) => /* @__PURE__ */ i(p, { children: [
334
- /* @__PURE__ */ e(h, { children: /* @__PURE__ */ e(
335
- U,
336
- {
337
- checked: r.value,
338
- onCheckedChange: (o) => r.onChange(o)
339
- }
340
- ) }),
341
- /* @__PURE__ */ e(u, { children: "Required" }),
342
- /* @__PURE__ */ e(y, {})
343
- ] })
344
- }
345
- ) }),
346
- /* @__PURE__ */ e("div", { className: "space-y-2", children: /* @__PURE__ */ e(
347
- m,
348
- {
349
- control: n.control,
350
- name: "property.description",
351
- render: ({ field: r }) => /* @__PURE__ */ i(p, { children: [
352
- /* @__PURE__ */ e(u, { children: "Description" }),
353
- /* @__PURE__ */ e(h, { children: /* @__PURE__ */ e(O, { ...r }) }),
354
- /* @__PURE__ */ e(y, {})
355
- ] })
356
- }
357
- ) }),
358
- I ? /* @__PURE__ */ e(
359
- m,
360
- {
361
- control: n.control,
362
- name: "property.enum",
363
- render: ({ field: r }) => /* @__PURE__ */ i(p, { children: [
364
- /* @__PURE__ */ e(u, { children: "Enum" }),
365
- /* @__PURE__ */ e(h, { children: /* @__PURE__ */ e(
366
- W,
367
- {
368
- values: r.value?.filter((o) => typeof o == "string") ?? [],
369
- onAddValue: (o) => {
370
- const a = [];
371
- r.value && a.push(...r.value), a.push(o), r.onChange(a);
372
- },
373
- onRemoveValue: (o) => {
374
- const a = b(r.value ?? []);
375
- a.splice(o, 1), r.onChange(a);
376
- }
377
- }
378
- ) }),
379
- /* @__PURE__ */ e(y, {})
380
- ] })
381
- }
382
- ) : null,
383
- D.length ? /* @__PURE__ */ i("div", { className: "space-y-2", children: [
384
- /* @__PURE__ */ e(Q, { children: "Constraints" }),
385
- /* @__PURE__ */ e(
386
- Y,
387
- {
388
- addedConstraints: v ?? [],
389
- availableDefinitions: D,
390
- onAdd: (r) => {
391
- n.setValue("constraints", r);
392
- }
393
- }
394
- ),
395
- /* @__PURE__ */ e(Z, {}),
396
- v?.map((r, o) => {
397
- const a = P(r.name);
398
- if (!a) return null;
399
- const l = n.formState.errors.constraints?.[o];
400
- let c;
401
- return l && (c = {
402
- code: l?.type ?? "INVALID",
403
- message: l.message ?? "An error occurred"
404
- }), /* @__PURE__ */ e(
405
- a,
406
- {
407
- constraintName: r.name,
408
- value: r.value,
409
- onConstraintChange: (d) => {
410
- z(o, d);
411
- },
412
- onRemoveConstraint: () => {
413
- L(r.name);
414
- },
415
- error: c
416
- },
417
- r.name
418
- );
419
- })
420
- ] }) : null,
421
- /* @__PURE__ */ e(G, { children: /* @__PURE__ */ e(x, { type: "submit", form: "add-property-form", children: "Add Property" }) })
422
- ]
423
- }
424
- ) })
425
- ] }) });
426
128
  }
427
129
  export {
428
- ne as AddFormSchema,
429
- Ce as AddPropertyDialog
130
+ N as AlertDialog,
131
+ h as AlertDialogAction,
132
+ j as AlertDialogCancel,
133
+ b as AlertDialogContent,
134
+ z as AlertDialogDescription,
135
+ w as AlertDialogFooter,
136
+ y as AlertDialogHeader,
137
+ p as AlertDialogOverlay,
138
+ g as AlertDialogPortal,
139
+ C as AlertDialogTitle
430
140
  };
431
141
  //# sourceMappingURL=index.es21.js.map