xote 4.4.3 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,18 +9,10 @@ function jsx(component, props) {
9
9
  return component(props);
10
10
  }
11
11
 
12
- function jsxs(component, props) {
13
- return component(props);
14
- }
15
-
16
12
  function jsxKeyed(component, props, key, param) {
17
13
  return component(props);
18
14
  }
19
15
 
20
- function jsxsKeyed(component, props, key, param) {
21
- return component(props);
22
- }
23
-
24
16
  function jsxFragment(props) {
25
17
  let child = props.children;
26
18
  if (child !== undefined) {
@@ -77,148 +69,57 @@ function convertBoolAttrValue(key, value) {
77
69
  return Xote__Component.signalAttr(key, strSignal);
78
70
  }
79
71
 
80
- function propsToAttrs(props) {
81
- let attrs = [];
82
- let v = props.id;
83
- if (v !== undefined) {
84
- attrs.push(convertAttrValue("id", Primitive_option.valFromOption(v)));
85
- }
86
- let v$1 = props.class;
87
- if (v$1 !== undefined) {
88
- attrs.push(convertAttrValue("class", Primitive_option.valFromOption(v$1)));
89
- }
90
- let v$2 = props.style;
91
- if (v$2 !== undefined) {
92
- attrs.push(convertAttrValue("style", Primitive_option.valFromOption(v$2)));
93
- }
94
- let v$3 = props.type;
95
- if (v$3 !== undefined) {
96
- attrs.push(convertAttrValue("type", Primitive_option.valFromOption(v$3)));
97
- }
98
- let v$4 = props.name;
99
- if (v$4 !== undefined) {
100
- attrs.push(convertAttrValue("name", Primitive_option.valFromOption(v$4)));
101
- }
102
- let v$5 = props.value;
103
- if (v$5 !== undefined) {
104
- attrs.push(convertAttrValue("value", Primitive_option.valFromOption(v$5)));
105
- }
106
- let v$6 = props.placeholder;
107
- if (v$6 !== undefined) {
108
- attrs.push(convertAttrValue("placeholder", Primitive_option.valFromOption(v$6)));
109
- }
110
- let v$7 = props.disabled;
111
- if (v$7 !== undefined) {
112
- attrs.push(convertBoolAttrValue("disabled", Primitive_option.valFromOption(v$7)));
113
- }
114
- let v$8 = props.checked;
115
- if (v$8 !== undefined) {
116
- attrs.push(convertBoolAttrValue("checked", Primitive_option.valFromOption(v$8)));
117
- }
118
- let v$9 = props.required;
119
- if (v$9 !== undefined) {
120
- attrs.push(convertBoolAttrValue("required", Primitive_option.valFromOption(v$9)));
121
- }
122
- let v$10 = props.readOnly;
123
- if (v$10 !== undefined) {
124
- attrs.push(convertBoolAttrValue("readonly", Primitive_option.valFromOption(v$10)));
125
- }
126
- let v$11 = props.maxLength;
127
- if (v$11 !== undefined) {
128
- attrs.push(Xote__Component.attr("maxlength", v$11.toString()));
129
- }
130
- let v$12 = props.minLength;
131
- if (v$12 !== undefined) {
132
- attrs.push(Xote__Component.attr("minlength", v$12.toString()));
133
- }
134
- let v$13 = props.min;
135
- if (v$13 !== undefined) {
136
- attrs.push(convertAttrValue("min", Primitive_option.valFromOption(v$13)));
137
- }
138
- let v$14 = props.max;
139
- if (v$14 !== undefined) {
140
- attrs.push(convertAttrValue("max", Primitive_option.valFromOption(v$14)));
72
+ function addAttr(attrs, opt, key, converter) {
73
+ if (opt !== undefined) {
74
+ attrs.push(converter(key, Primitive_option.valFromOption(opt)));
75
+ return;
141
76
  }
142
- let v$15 = props.step;
143
- if (v$15 !== undefined) {
144
- attrs.push(convertAttrValue("step", Primitive_option.valFromOption(v$15)));
145
- }
146
- let v$16 = props.pattern;
147
- if (v$16 !== undefined) {
148
- attrs.push(convertAttrValue("pattern", Primitive_option.valFromOption(v$16)));
149
- }
150
- let v$17 = props.autoComplete;
151
- if (v$17 !== undefined) {
152
- attrs.push(convertAttrValue("autocomplete", Primitive_option.valFromOption(v$17)));
153
- }
154
- let v$18 = props.multiple;
155
- if (v$18 !== undefined) {
156
- attrs.push(convertBoolAttrValue("multiple", Primitive_option.valFromOption(v$18)));
157
- }
158
- let v$19 = props.accept;
159
- if (v$19 !== undefined) {
160
- attrs.push(convertAttrValue("accept", Primitive_option.valFromOption(v$19)));
161
- }
162
- let v$20 = props.rows;
163
- if (v$20 !== undefined) {
164
- attrs.push(Xote__Component.attr("rows", v$20.toString()));
165
- }
166
- let v$21 = props.cols;
167
- if (v$21 !== undefined) {
168
- attrs.push(Xote__Component.attr("cols", v$21.toString()));
169
- }
170
- let v$22 = props.for;
171
- if (v$22 !== undefined) {
172
- attrs.push(convertAttrValue("for", Primitive_option.valFromOption(v$22)));
173
- }
174
- let v$23 = props.href;
175
- if (v$23 !== undefined) {
176
- attrs.push(convertAttrValue("href", Primitive_option.valFromOption(v$23)));
177
- }
178
- let v$24 = props.target;
179
- if (v$24 !== undefined) {
180
- attrs.push(convertAttrValue("target", Primitive_option.valFromOption(v$24)));
181
- }
182
- let v$25 = props.src;
183
- if (v$25 !== undefined) {
184
- attrs.push(convertAttrValue("src", Primitive_option.valFromOption(v$25)));
185
- }
186
- let v$26 = props.alt;
187
- if (v$26 !== undefined) {
188
- attrs.push(convertAttrValue("alt", Primitive_option.valFromOption(v$26)));
189
- }
190
- let v$27 = props.width;
191
- if (v$27 !== undefined) {
192
- attrs.push(convertAttrValue("width", Primitive_option.valFromOption(v$27)));
193
- }
194
- let v$28 = props.height;
195
- if (v$28 !== undefined) {
196
- attrs.push(convertAttrValue("height", Primitive_option.valFromOption(v$28)));
197
- }
198
- let v$29 = props.role;
199
- if (v$29 !== undefined) {
200
- attrs.push(convertAttrValue("role", Primitive_option.valFromOption(v$29)));
201
- }
202
- let v$30 = props.tabIndex;
203
- if (v$30 !== undefined) {
204
- attrs.push(Xote__Component.attr("tabindex", v$30.toString()));
205
- }
206
- let v$31 = props["aria-label"];
207
- if (v$31 !== undefined) {
208
- attrs.push(convertAttrValue("aria-label", Primitive_option.valFromOption(v$31)));
209
- }
210
- let v$32 = props["aria-hidden"];
211
- if (v$32 !== undefined) {
212
- attrs.push(convertBoolAttrValue("aria-hidden", Primitive_option.valFromOption(v$32)));
213
- }
214
- let v$33 = props["aria-expanded"];
215
- if (v$33 !== undefined) {
216
- attrs.push(convertBoolAttrValue("aria-expanded", Primitive_option.valFromOption(v$33)));
217
- }
218
- let v$34 = props["aria-selected"];
219
- if (v$34 !== undefined) {
220
- attrs.push(convertBoolAttrValue("aria-selected", Primitive_option.valFromOption(v$34)));
77
+ }
78
+
79
+ function addIntAttr(attrs, opt, key) {
80
+ if (opt !== undefined) {
81
+ attrs.push(Xote__Component.attr(key, opt.toString()));
82
+ return;
221
83
  }
84
+ }
85
+
86
+ function propsToAttrs(props) {
87
+ let attrs = [];
88
+ addAttr(attrs, props.id, "id", convertAttrValue);
89
+ addAttr(attrs, props.class, "class", convertAttrValue);
90
+ addAttr(attrs, props.style, "style", convertAttrValue);
91
+ addAttr(attrs, props.type, "type", convertAttrValue);
92
+ addAttr(attrs, props.name, "name", convertAttrValue);
93
+ addAttr(attrs, props.value, "value", convertAttrValue);
94
+ addAttr(attrs, props.placeholder, "placeholder", convertAttrValue);
95
+ addAttr(attrs, props.disabled, "disabled", convertBoolAttrValue);
96
+ addAttr(attrs, props.checked, "checked", convertBoolAttrValue);
97
+ addAttr(attrs, props.required, "required", convertBoolAttrValue);
98
+ addAttr(attrs, props.readOnly, "readonly", convertBoolAttrValue);
99
+ addIntAttr(attrs, props.maxLength, "maxlength");
100
+ addIntAttr(attrs, props.minLength, "minlength");
101
+ addAttr(attrs, props.min, "min", convertAttrValue);
102
+ addAttr(attrs, props.max, "max", convertAttrValue);
103
+ addAttr(attrs, props.step, "step", convertAttrValue);
104
+ addAttr(attrs, props.pattern, "pattern", convertAttrValue);
105
+ addAttr(attrs, props.autoComplete, "autocomplete", convertAttrValue);
106
+ addAttr(attrs, props.multiple, "multiple", convertBoolAttrValue);
107
+ addAttr(attrs, props.accept, "accept", convertAttrValue);
108
+ addIntAttr(attrs, props.rows, "rows");
109
+ addIntAttr(attrs, props.cols, "cols");
110
+ addAttr(attrs, props.for, "for", convertAttrValue);
111
+ addAttr(attrs, props.href, "href", convertAttrValue);
112
+ addAttr(attrs, props.target, "target", convertAttrValue);
113
+ addAttr(attrs, props.src, "src", convertAttrValue);
114
+ addAttr(attrs, props.alt, "alt", convertAttrValue);
115
+ addAttr(attrs, props.width, "width", convertAttrValue);
116
+ addAttr(attrs, props.height, "height", convertAttrValue);
117
+ addAttr(attrs, props.role, "role", convertAttrValue);
118
+ addIntAttr(attrs, props.tabIndex, "tabindex");
119
+ addAttr(attrs, props["aria-label"], "aria-label", convertAttrValue);
120
+ addAttr(attrs, props["aria-hidden"], "aria-hidden", convertBoolAttrValue);
121
+ addAttr(attrs, props["aria-expanded"], "aria-expanded", convertBoolAttrValue);
122
+ addAttr(attrs, props["aria-selected"], "aria-selected", convertBoolAttrValue);
222
123
  let _dataObj = props.data;
223
124
  if (_dataObj !== undefined) {
224
125
  ((Object.entries(_dataObj).forEach(([key, value]) => {
@@ -228,78 +129,28 @@ function propsToAttrs(props) {
228
129
  return attrs;
229
130
  }
230
131
 
231
- function propsToEvents(props) {
232
- let events = [];
233
- let handler = props.onClick;
234
- if (handler !== undefined) {
235
- events.push([
236
- "click",
237
- handler
238
- ]);
239
- }
240
- let handler$1 = props.onInput;
241
- if (handler$1 !== undefined) {
242
- events.push([
243
- "input",
244
- handler$1
245
- ]);
246
- }
247
- let handler$2 = props.onChange;
248
- if (handler$2 !== undefined) {
249
- events.push([
250
- "change",
251
- handler$2
252
- ]);
253
- }
254
- let handler$3 = props.onSubmit;
255
- if (handler$3 !== undefined) {
132
+ function addEvent(events, opt, eventName) {
133
+ if (opt !== undefined) {
256
134
  events.push([
257
- "submit",
258
- handler$3
259
- ]);
260
- }
261
- let handler$4 = props.onFocus;
262
- if (handler$4 !== undefined) {
263
- events.push([
264
- "focus",
265
- handler$4
266
- ]);
267
- }
268
- let handler$5 = props.onBlur;
269
- if (handler$5 !== undefined) {
270
- events.push([
271
- "blur",
272
- handler$5
273
- ]);
274
- }
275
- let handler$6 = props.onKeyDown;
276
- if (handler$6 !== undefined) {
277
- events.push([
278
- "keydown",
279
- handler$6
280
- ]);
281
- }
282
- let handler$7 = props.onKeyUp;
283
- if (handler$7 !== undefined) {
284
- events.push([
285
- "keyup",
286
- handler$7
287
- ]);
288
- }
289
- let handler$8 = props.onMouseEnter;
290
- if (handler$8 !== undefined) {
291
- events.push([
292
- "mouseenter",
293
- handler$8
294
- ]);
295
- }
296
- let handler$9 = props.onMouseLeave;
297
- if (handler$9 !== undefined) {
298
- events.push([
299
- "mouseleave",
300
- handler$9
135
+ eventName,
136
+ Primitive_option.valFromOption(opt)
301
137
  ]);
138
+ return;
302
139
  }
140
+ }
141
+
142
+ function propsToEvents(props) {
143
+ let events = [];
144
+ addEvent(events, props.onClick, "click");
145
+ addEvent(events, props.onInput, "input");
146
+ addEvent(events, props.onChange, "change");
147
+ addEvent(events, props.onSubmit, "submit");
148
+ addEvent(events, props.onFocus, "focus");
149
+ addEvent(events, props.onBlur, "blur");
150
+ addEvent(events, props.onKeyDown, "keydown");
151
+ addEvent(events, props.onKeyUp, "keyup");
152
+ addEvent(events, props.onMouseEnter, "mouseenter");
153
+ addEvent(events, props.onMouseLeave, "mouseleave");
303
154
  return events;
304
155
  }
305
156
 
@@ -328,33 +179,34 @@ function createElement(tag, props) {
328
179
 
329
180
  let jsx$1 = createElement;
330
181
 
331
- let jsxs$1 = createElement;
332
-
333
182
  function jsxKeyed$1(tag, props, key, param) {
334
183
  return createElement(tag, props);
335
184
  }
336
185
 
337
- function jsxsKeyed$1(tag, props, key, param) {
338
- return createElement(tag, props);
339
- }
340
-
341
186
  let Elements = {
342
187
  signal: signal,
343
188
  computed: computed,
344
189
  convertAttrValue: convertAttrValue,
345
190
  convertBoolAttrValue: convertBoolAttrValue,
191
+ addAttr: addAttr,
192
+ addIntAttr: addIntAttr,
346
193
  propsToAttrs: propsToAttrs,
194
+ addEvent: addEvent,
347
195
  propsToEvents: propsToEvents,
348
196
  getChildren: getChildren,
349
197
  createElement: createElement,
350
198
  jsx: jsx$1,
351
- jsxs: jsxs$1,
199
+ jsxs: jsx$1,
352
200
  jsxKeyed: jsxKeyed$1,
353
- jsxsKeyed: jsxsKeyed$1
201
+ jsxsKeyed: jsxKeyed$1
354
202
  };
355
203
 
356
204
  let Component;
357
205
 
206
+ let jsxs = jsx;
207
+
208
+ let jsxsKeyed = jsxKeyed;
209
+
358
210
  export {
359
211
  Component,
360
212
  jsx,
@@ -0,0 +1,11 @@
1
+ open Signals
2
+
3
+ /* Defines a property that can either be a signal (Reactive) or a static value
4
+ (Static) */
5
+ type t<'a> = Reactive(Signal.t<'a>) | Static('a)
6
+
7
+ let get = value =>
8
+ switch value {
9
+ | Reactive(signal) => Signal.get(signal)
10
+ | Static(value) => value
11
+ }
@@ -0,0 +1,16 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Signals from "rescript-signals/src/Signals.res.mjs";
4
+
5
+ function get(value) {
6
+ if (value.TAG === "Reactive") {
7
+ return Signals.Signal.get(value._0);
8
+ } else {
9
+ return value._0;
10
+ }
11
+ }
12
+
13
+ export {
14
+ get,
15
+ }
16
+ /* Signals Not a pure module */