zudoku 0.1.1-dev.51 → 0.1.1-dev.53

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudoku",
3
- "version": "0.1.1-dev.51",
3
+ "version": "0.1.1-dev.53",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -29,10 +29,15 @@ export const MakeRequest = ({
29
29
  }));
30
30
  const queryParams = operation.parameters
31
31
  ?.filter((p) => p.in === "query")
32
- .map((p) => ({
33
- name: p.name,
34
- value: "",
35
- }));
32
+ .sort((a, b) => (a.required && !b.required ? -1 : 1))
33
+ .map((p) => {
34
+ return {
35
+ name: p.name,
36
+ value: "",
37
+ active: p.required ?? false,
38
+ isRequired: p.required ?? false,
39
+ };
40
+ });
36
41
  const pathParams = operation.parameters
37
42
  ?.filter((p) => p.in === "path")
38
43
  .map((p) => ({
@@ -65,7 +65,8 @@ export type Header = {
65
65
  export type QueryParam = {
66
66
  name: string;
67
67
  value: string;
68
- active?: boolean;
68
+ active: boolean;
69
+ isRequired: boolean;
69
70
  };
70
71
  export type PathParam = {
71
72
  name: string;
@@ -200,9 +201,7 @@ const Playground = ({
200
201
  </VisuallyHidden>
201
202
  <FormProvider {...{ register, control, handleSubmit, watch, ...form }}>
202
203
  <form
203
- onSubmit={handleSubmit((data) => {
204
- queryMutation.mutateAsync(data);
205
- })}
204
+ onSubmit={handleSubmit((data) => queryMutation.mutateAsync(data))}
206
205
  >
207
206
  <div className="grid grid-cols-2 text-sm h-full">
208
207
  <div className="flex flex-col gap-4 p-8 bg-muted/50 after:bg-muted-foreground/20 relative after:absolute after:w-px after:inset-0 after:left-auto">
@@ -1,51 +1,13 @@
1
- import logger from "loglevel";
2
1
  import { XIcon } from "lucide-react";
3
- import { useEffect } from "react";
4
2
  import {
5
3
  Control,
6
4
  Controller,
7
5
  useFieldArray,
8
6
  useFormContext,
9
- useWatch,
10
7
  } from "react-hook-form";
11
8
  import { InlineInput } from "./InlineInput.js";
12
9
  import { PlaygroundForm } from "./Playground.js";
13
10
 
14
- const QueryParamActive = ({
15
- i,
16
- control,
17
- }: {
18
- i: number;
19
- control: Control<PlaygroundForm>;
20
- }) => {
21
- const value = useWatch({ control, name: `queryParams.${i}.value` });
22
- const active = useWatch({ control, name: `queryParams.${i}.active` });
23
- const form = useFormContext<PlaygroundForm>();
24
-
25
- useEffect(() => {
26
- if (value) {
27
- logger.log(`queryParams.${i}.active`, active);
28
- form.setValue(`queryParams.${i}.active`, true);
29
- }
30
- }, [value]);
31
-
32
- return (
33
- <Controller
34
- name={`queryParams.${i}.active`}
35
- render={({ field }) => {
36
- return (
37
- <input
38
- type="checkbox"
39
- id={`queryParams.${i}.active`}
40
- {...field}
41
- checked={field.value}
42
- />
43
- );
44
- }}
45
- />
46
- );
47
- };
48
-
49
11
  export const QueryParams = ({
50
12
  control,
51
13
  }: {
@@ -55,13 +17,29 @@ export const QueryParams = ({
55
17
  control,
56
18
  name: "queryParams",
57
19
  });
20
+ const form = useFormContext<PlaygroundForm>();
21
+
22
+ const requiredFields = form
23
+ .getValues(`queryParams`)
24
+ .map((param) => param.isRequired);
58
25
 
59
26
  return fields.map((field, i) => (
60
27
  <div
61
28
  key={field.id}
62
29
  className="px-2 grid-cols-subgrid col-span-full grid items-center gap-x-2 has-[:focus]:bg-muted hover:bg-accent rounded overflow-hidden group"
63
30
  >
64
- <QueryParamActive i={i} control={control} />
31
+ <Controller
32
+ control={control}
33
+ name={`queryParams.${i}.active`}
34
+ render={({ field }) => (
35
+ <input
36
+ type="checkbox"
37
+ id={`queryParams.${i}.active`}
38
+ checked={field.value}
39
+ onChange={field.onChange}
40
+ />
41
+ )}
42
+ />
65
43
 
66
44
  <Controller
67
45
  control={control}
@@ -71,8 +49,10 @@ export const QueryParams = ({
71
49
  <label
72
50
  className="flex items-center"
73
51
  htmlFor={`queryParams.${i}.active`}
52
+ title={requiredFields[i] ? "Required field" : undefined}
74
53
  >
75
54
  {field.value}
55
+ {requiredFields[i] && <sup className="text-destructive">*</sup>}
76
56
  </label>
77
57
  </InlineInput>
78
58
  );
@@ -1,152 +0,0 @@
1
- import { F as N, j as _ } from "./DevPortalProvider-yBHPOS9_.js";
2
- var I = { exports: {} };
3
- (function(w) {
4
- (function(g, i) {
5
- w.exports ? w.exports = i() : g.log = i();
6
- })(N, function() {
7
- var g = function() {
8
- }, i = "undefined", C = typeof window !== i && typeof window.navigator !== i && /Trident\/|MSIE /.test(window.navigator.userAgent), p = [
9
- "trace",
10
- "debug",
11
- "info",
12
- "warn",
13
- "error"
14
- ], a = {}, l = null;
15
- function h(o, t) {
16
- var e = o[t];
17
- if (typeof e.bind == "function")
18
- return e.bind(o);
19
- try {
20
- return Function.prototype.bind.call(e, o);
21
- } catch {
22
- return function() {
23
- return Function.prototype.apply.apply(e, [o, arguments]);
24
- };
25
- }
26
- }
27
- function T() {
28
- console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
29
- }
30
- function F(o) {
31
- return o === "debug" && (o = "log"), typeof console === i ? !1 : o === "trace" && C ? T : console[o] !== void 0 ? h(console, o) : console.log !== void 0 ? h(console, "log") : g;
32
- }
33
- function u() {
34
- for (var o = this.getLevel(), t = 0; t < p.length; t++) {
35
- var e = p[t];
36
- this[e] = t < o ? g : this.methodFactory(e, o, this.name);
37
- }
38
- if (this.log = this.debug, typeof console === i && o < this.levels.SILENT)
39
- return "No console available for logging";
40
- }
41
- function x(o) {
42
- return function() {
43
- typeof console !== i && (u.call(this), this[o].apply(this, arguments));
44
- };
45
- }
46
- function R(o, t, e) {
47
- return F(o) || x.apply(this, arguments);
48
- }
49
- function L(o, t) {
50
- var e = this, v, y, f, s = "loglevel";
51
- typeof o == "string" ? s += ":" + o : typeof o == "symbol" && (s = void 0);
52
- function S(n) {
53
- var r = (p[n] || "silent").toUpperCase();
54
- if (!(typeof window === i || !s)) {
55
- try {
56
- window.localStorage[s] = r;
57
- return;
58
- } catch {
59
- }
60
- try {
61
- window.document.cookie = encodeURIComponent(s) + "=" + r + ";";
62
- } catch {
63
- }
64
- }
65
- }
66
- function b() {
67
- var n;
68
- if (!(typeof window === i || !s)) {
69
- try {
70
- n = window.localStorage[s];
71
- } catch {
72
- }
73
- if (typeof n === i)
74
- try {
75
- var r = window.document.cookie, d = encodeURIComponent(s), m = r.indexOf(d + "=");
76
- m !== -1 && (n = /^([^;]+)/.exec(
77
- r.slice(m + d.length + 1)
78
- )[1]);
79
- } catch {
80
- }
81
- return e.levels[n] === void 0 && (n = void 0), n;
82
- }
83
- }
84
- function U() {
85
- if (!(typeof window === i || !s)) {
86
- try {
87
- window.localStorage.removeItem(s);
88
- } catch {
89
- }
90
- try {
91
- window.document.cookie = encodeURIComponent(s) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
92
- } catch {
93
- }
94
- }
95
- }
96
- function c(n) {
97
- var r = n;
98
- if (typeof r == "string" && e.levels[r.toUpperCase()] !== void 0 && (r = e.levels[r.toUpperCase()]), typeof r == "number" && r >= 0 && r <= e.levels.SILENT)
99
- return r;
100
- throw new TypeError("log.setLevel() called with invalid level: " + n);
101
- }
102
- e.name = o, e.levels = {
103
- TRACE: 0,
104
- DEBUG: 1,
105
- INFO: 2,
106
- WARN: 3,
107
- ERROR: 4,
108
- SILENT: 5
109
- }, e.methodFactory = t || R, e.getLevel = function() {
110
- return f ?? y ?? v;
111
- }, e.setLevel = function(n, r) {
112
- return f = c(n), r !== !1 && S(f), u.call(e);
113
- }, e.setDefaultLevel = function(n) {
114
- y = c(n), b() || e.setLevel(n, !1);
115
- }, e.resetLevel = function() {
116
- f = null, U(), u.call(e);
117
- }, e.enableAll = function(n) {
118
- e.setLevel(e.levels.TRACE, n);
119
- }, e.disableAll = function(n) {
120
- e.setLevel(e.levels.SILENT, n);
121
- }, e.rebuild = function() {
122
- if (l !== e && (v = c(l.getLevel())), u.call(e), l === e)
123
- for (var n in a)
124
- a[n].rebuild();
125
- }, v = c(
126
- l ? l.getLevel() : "WARN"
127
- );
128
- var E = b();
129
- E != null && (f = c(E)), u.call(e);
130
- }
131
- l = new L(), l.getLogger = function(t) {
132
- if (typeof t != "symbol" && typeof t != "string" || t === "")
133
- throw new TypeError("You must supply a name when creating a logger.");
134
- var e = a[t];
135
- return e || (e = a[t] = new L(
136
- t,
137
- l.methodFactory
138
- )), e;
139
- };
140
- var A = typeof window !== i ? window.log : void 0;
141
- return l.noConflict = function() {
142
- return typeof window !== i && window.log === l && (window.log = A), l;
143
- }, l.getLoggers = function() {
144
- return a;
145
- }, l.default = l, l;
146
- });
147
- })(I);
148
- var D = I.exports;
149
- const P = /* @__PURE__ */ _(D);
150
- export {
151
- P as l
152
- };