@alxgrn/telefrag-ui 0.1.2 → 0.1.3

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.
@@ -1,6 +1,6 @@
1
1
  import { jsxs as b, jsx as m } from "react/jsx-runtime";
2
- import { useState as q, useEffect as H } from "react";
3
- import h, { isValidDate as R } from "../date/Date.js";
2
+ import { useState as H, useEffect as R } from "react";
3
+ import h, { isValidDate as T } from "../date/Date.js";
4
4
  import { RadioList as x } from "../radio/RadioList.js";
5
5
  import { Select as y } from "../select/Select.js";
6
6
  import { CheckboxList as F } from "../checkbox/CheckboxList.js";
@@ -17,8 +17,8 @@ import { Image as D } from "../image/Image.js";
17
17
  import E from "../input/Input.js";
18
18
  /* empty css */
19
19
  /* empty css */
20
- import T from "../hidden/Hidden.js";
21
- import B from "../checkbox/Checkbox.js";
20
+ import B from "../hidden/Hidden.js";
21
+ import S from "../checkbox/Checkbox.js";
22
22
  /* empty css */
23
23
  import "react-transition-group";
24
24
  import "react-dom";
@@ -37,60 +37,63 @@ import l from "../../ui/block/Block.js";
37
37
  /* empty css */
38
38
  /* empty css */
39
39
  /* empty css */
40
- import S from "./traverse.js";
41
- const Eo = ({
40
+ import j from "./traverse.js";
41
+ const De = ({
42
42
  info: u,
43
43
  error: d,
44
44
  success: k,
45
45
  submit: p,
46
46
  cancel: f,
47
- submitType: j = "Accent",
48
- cancelType: w = "Error",
49
- wide: A,
47
+ submitType: w = "Accent",
48
+ cancelType: A = "Error",
49
+ wide: L,
50
50
  onSubmit: v,
51
- onCancel: L,
51
+ onCancel: N,
52
52
  children: c
53
53
  }) => {
54
- const [N, i] = q(!1);
55
- return H(() => {
56
- p && (i(!1), S(c, (r) => {
57
- const e = r.props;
54
+ const [q, r] = H(!1);
55
+ return R(() => {
56
+ p && (r(!1), j(c, (t) => {
57
+ const e = t.props;
58
58
  if (e.required)
59
- switch (r.type) {
59
+ switch (t.type) {
60
60
  case I:
61
61
  case E:
62
- e.value.trim() || i(!0);
62
+ e.value.trim() || r(!0);
63
63
  break;
64
- case B:
65
- e.checked || i(!0);
64
+ case S:
65
+ e.checked || r(!0);
66
66
  break;
67
67
  case y:
68
68
  {
69
- const s = e.value;
70
- e.options.findIndex((a) => a.value === s) < 0 && i(!0);
69
+ const a = e.value;
70
+ e.options.findIndex((s) => s.value === a) < 0 && r(!0);
71
71
  }
72
72
  break;
73
73
  case x:
74
74
  {
75
- const s = e.value;
76
- e.options.findIndex((a) => a.value === s) < 0 && i(!0);
75
+ const a = e.value;
76
+ e.options.findIndex((s) => s.value === a) < 0 && r(!0);
77
77
  }
78
78
  break;
79
79
  case g:
80
- e.files.length < 1 && i(!0);
80
+ e.files.length < 1 && r(!0);
81
81
  break;
82
82
  case D:
83
- e.value || i(!0);
83
+ e.value || r(!0);
84
84
  break;
85
85
  case h:
86
- R(e.value.trim()) || i(!0);
86
+ T(e.value.trim()) || r(!0);
87
87
  break;
88
88
  case F:
89
- e.options.findIndex((n) => n.checked === !0) < 0 && i(!0);
89
+ e.options.findIndex((n) => n.checked === !0) < 0 && r(!0);
90
+ break;
91
+ case B:
92
+ `${e.value}`.trim() || r(!0);
90
93
  break;
91
94
  }
92
95
  }));
93
- }, [c, p]), /* @__PURE__ */ b("div", { className: A ? "Form FormWide" : "Form", children: [
96
+ }, [c, p]), /* @__PURE__ */ b("div", { className: L ? "Form FormWide" : "Form", children: [
94
97
  k && /* @__PURE__ */ m(l, { type: "Success", children: k }),
95
98
  d && /* @__PURE__ */ m(l, { type: "Error", children: d }),
96
99
  u && /* @__PURE__ */ m(l, { children: u }),
@@ -99,27 +102,27 @@ const Eo = ({
99
102
  p && /* @__PURE__ */ m(
100
103
  C,
101
104
  {
102
- type: j,
105
+ type: w,
103
106
  label: p,
104
- disabled: N,
107
+ disabled: q,
105
108
  onClick: () => {
106
109
  if (!v) return;
107
- const r = {}, e = (t, o) => {
108
- if (!r[t]) {
109
- r[t] = o;
110
+ const t = {}, e = (i, o) => {
111
+ if (!t[i]) {
112
+ t[i] = o;
110
113
  return;
111
114
  }
112
- r[t] instanceof Array ? r[t].push(o) : r[t] = [r[t], o];
115
+ t[i] instanceof Array ? t[i].push(o) : t[i] = [t[i], o];
113
116
  };
114
- S(c, (t) => {
115
- const o = t.props;
116
- switch (t.type) {
117
+ j(c, (i) => {
118
+ const o = i.props;
119
+ switch (i.type) {
117
120
  case h:
118
121
  case I:
119
122
  case E:
120
123
  e(o.id, o.value.trim());
121
124
  break;
122
- case B:
125
+ case S:
123
126
  e(o.id, o.checked ? o.value : void 0);
124
127
  break;
125
128
  case y:
@@ -132,34 +135,34 @@ const Eo = ({
132
135
  case D:
133
136
  e(o.id, o.value);
134
137
  break;
135
- case T:
138
+ case B:
136
139
  e(o.id, o.value);
137
140
  break;
138
141
  case F:
139
142
  {
140
- const s = [];
141
- o.options.forEach((a) => {
142
- a.checked && s.push(a.value);
143
- }), e(o.id, s);
143
+ const a = [];
144
+ o.options.forEach((s) => {
145
+ s.checked && a.push(s.value);
146
+ }), e(o.id, a);
144
147
  }
145
148
  break;
146
149
  }
147
- }), v(r);
150
+ }), v(t);
148
151
  }
149
152
  }
150
153
  ),
151
154
  f && /* @__PURE__ */ m(
152
155
  C,
153
156
  {
154
- type: w,
157
+ type: A,
155
158
  label: f,
156
- onClick: L
159
+ onClick: N
157
160
  }
158
161
  )
159
162
  ] })
160
163
  ] });
161
164
  };
162
165
  export {
163
- Eo as Form,
164
- Eo as default
166
+ De as Form,
167
+ De as default
165
168
  };
@@ -6,6 +6,7 @@ function i(t) {
6
6
  var o;
7
7
  if (!r.isValidElement(t)) return !1;
8
8
  let e = t.type;
9
+ if (typeof e == "string") return !1;
9
10
  for (; f(e) && (e.$$typeof === Symbol.for("react.memo") || e.$$typeof === Symbol.for("react.forward_ref")); )
10
11
  e = e.type;
11
12
  return typeof e == "function" && !((o = e.prototype) != null && o.isReactComponent);
@@ -2,6 +2,7 @@ import { default as React } from 'react';
2
2
  export interface HiddenProps {
3
3
  id: string;
4
4
  value: string | number;
5
+ required?: boolean;
5
6
  }
6
7
  declare const Hidden: React.FC<HiddenProps>;
7
8
  export default Hidden;
@@ -1,12 +1,13 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- const n = ({ id: t, value: d }) => /* @__PURE__ */ e(
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ const o = ({ id: t, value: d, required: e }) => /* @__PURE__ */ i(
3
3
  "input",
4
4
  {
5
5
  id: t,
6
6
  type: "hidden",
7
- value: d
7
+ value: d,
8
+ required: e
8
9
  }
9
10
  );
10
11
  export {
11
- n as default
12
+ o as default
12
13
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@alxgrn/telefrag-ui",
3
3
  "description": "UI library for The Daily Telefrag project",
4
- "version": "0.1.2",
4
+ "version": "0.1.3",
5
5
  "private": false,
6
6
  "author": "Alexander Fedorov <alex@molner.ru>",
7
7
  "license": "Apache-2.0",