@insticc/genericform 2.0.0 → 2.0.2
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/build/Demo.js +95 -83
- package/build/Demo2.js +230 -192
- package/build/FormFields/CustomAccordion.js +44 -35
- package/build/FormFields/CustomCheckbox.js +14 -12
- package/build/FormFields/CustomCheckboxGroup.js +25 -21
- package/build/FormFields/CustomComponent.js +11 -9
- package/build/FormFields/CustomDatePicker.js +35 -29
- package/build/FormFields/CustomDropdown.js +23 -19
- package/build/FormFields/CustomInput.js +16 -14
- package/build/FormFields/CustomJson.js +42 -38
- package/build/FormFields/CustomLabel.js +8 -7
- package/build/FormFields/CustomMultiDropdown.js +23 -22
- package/build/FormFields/CustomNumberInput.js +19 -17
- package/build/FormFields/CustomRadioGroup.js +28 -24
- package/build/FormFields/CustomSearch.js +22 -21
- package/build/FormFields/CustomSeparator.js +5 -5
- package/build/FormFields/CustomTextArea.js +18 -16
- package/build/FormFields/CustomToggle.js +16 -13
- package/build/FormFields/defaults.js +21 -15
- package/build/index.js +123 -128
- package/package.json +1 -1
package/build/Demo.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _index = _interopRequireDefault(require("./index"));
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
11
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
11
12
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -17,8 +18,7 @@ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } /**
|
|
|
17
18
|
* Full GenericForm demo — every field type + every key scenario.
|
|
18
19
|
*
|
|
19
20
|
* Mount anywhere: <Demo />
|
|
20
|
-
*/
|
|
21
|
-
// ── Shared option sets ────────────────────────────────────────────────────────
|
|
21
|
+
*/ // ── Shared option sets ────────────────────────────────────────────────────────
|
|
22
22
|
var COUNTRIES = [{
|
|
23
23
|
value: "PT",
|
|
24
24
|
text: "Portugal"
|
|
@@ -368,40 +368,44 @@ var Demo = function Demo() {
|
|
|
368
368
|
sections: [{
|
|
369
369
|
title: "Advanced settings",
|
|
370
370
|
icon: "⚙️",
|
|
371
|
-
content: /*#__PURE__*/
|
|
371
|
+
content: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
372
372
|
style: {
|
|
373
373
|
display: "flex",
|
|
374
374
|
flexDirection: "column",
|
|
375
375
|
gap: 8
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
376
|
+
},
|
|
377
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
|
|
378
|
+
style: {
|
|
379
|
+
fontSize: "0.9rem"
|
|
380
|
+
},
|
|
381
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
382
|
+
type: "checkbox",
|
|
383
|
+
style: {
|
|
384
|
+
marginRight: 6
|
|
385
|
+
}
|
|
386
|
+
}), "Enable experimental features"]
|
|
387
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
|
|
388
|
+
style: {
|
|
389
|
+
fontSize: "0.9rem"
|
|
390
|
+
},
|
|
391
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
392
|
+
type: "checkbox",
|
|
393
|
+
style: {
|
|
394
|
+
marginRight: 6
|
|
395
|
+
}
|
|
396
|
+
}), "Verbose logging"]
|
|
397
|
+
})]
|
|
398
|
+
})
|
|
396
399
|
}, {
|
|
397
400
|
title: "Danger zone",
|
|
398
401
|
icon: "⚠️",
|
|
399
|
-
content: /*#__PURE__*/
|
|
402
|
+
content: /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
400
403
|
style: {
|
|
401
404
|
color: "#db2828",
|
|
402
405
|
fontSize: "0.9rem"
|
|
403
|
-
}
|
|
404
|
-
|
|
406
|
+
},
|
|
407
|
+
children: "Destructive actions go here."
|
|
408
|
+
})
|
|
405
409
|
}]
|
|
406
410
|
},
|
|
407
411
|
// ── Custom component ──────────────────────────────────────────────────
|
|
@@ -416,7 +420,7 @@ var Demo = function Demo() {
|
|
|
416
420
|
name: "avatar",
|
|
417
421
|
type: "component",
|
|
418
422
|
displayName: "Avatar preview",
|
|
419
|
-
component: /*#__PURE__*/
|
|
423
|
+
component: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
420
424
|
style: {
|
|
421
425
|
width: 64,
|
|
422
426
|
height: 64,
|
|
@@ -428,8 +432,9 @@ var Demo = function Demo() {
|
|
|
428
432
|
color: "#fff",
|
|
429
433
|
fontSize: 24,
|
|
430
434
|
fontWeight: 600
|
|
431
|
-
}
|
|
432
|
-
|
|
435
|
+
},
|
|
436
|
+
children: "A"
|
|
437
|
+
})
|
|
433
438
|
},
|
|
434
439
|
// ── Conditional (hide as function) ────────────────────────────────────
|
|
435
440
|
{
|
|
@@ -496,64 +501,71 @@ var Demo = function Demo() {
|
|
|
496
501
|
return alert("Reset clicked");
|
|
497
502
|
}
|
|
498
503
|
}];
|
|
499
|
-
return /*#__PURE__*/
|
|
504
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
500
505
|
style: {
|
|
501
506
|
maxWidth: 800,
|
|
502
507
|
margin: "2rem auto",
|
|
503
508
|
fontFamily: "sans-serif"
|
|
504
|
-
}
|
|
505
|
-
}, /*#__PURE__*/React.createElement("h1", {
|
|
506
|
-
style: {
|
|
507
|
-
fontSize: "1.4rem",
|
|
508
|
-
marginBottom: "0.5rem"
|
|
509
|
-
}
|
|
510
|
-
}, "GenericForm \u2014 full demo"), /*#__PURE__*/React.createElement("p", {
|
|
511
|
-
style: {
|
|
512
|
-
color: "#666",
|
|
513
|
-
marginBottom: "1.5rem",
|
|
514
|
-
fontSize: "0.9rem"
|
|
515
|
-
}
|
|
516
|
-
}, "Every field type, conditional visibility, validation, custom actions, and onSubmit."), /*#__PURE__*/React.createElement(_index["default"], {
|
|
517
|
-
title: "Demo form",
|
|
518
|
-
fields: fields,
|
|
519
|
-
submitText: "Submit demo",
|
|
520
|
-
cancelText: "Clear",
|
|
521
|
-
customActions: customActions,
|
|
522
|
-
validateOnChange: true,
|
|
523
|
-
validateOnSubmit: true,
|
|
524
|
-
onSubmit: function onSubmit(data) {
|
|
525
|
-
console.log("Submitted:", data);
|
|
526
|
-
setLastSubmit(data);
|
|
527
509
|
},
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
510
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h1", {
|
|
511
|
+
style: {
|
|
512
|
+
fontSize: "1.4rem",
|
|
513
|
+
marginBottom: "0.5rem"
|
|
514
|
+
},
|
|
515
|
+
children: "GenericForm \u2014 full demo"
|
|
516
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
517
|
+
style: {
|
|
518
|
+
color: "#666",
|
|
519
|
+
marginBottom: "1.5rem",
|
|
520
|
+
fontSize: "0.9rem"
|
|
521
|
+
},
|
|
522
|
+
children: "Every field type, conditional visibility, validation, custom actions, and onSubmit."
|
|
523
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_index["default"], {
|
|
524
|
+
title: "Demo form",
|
|
525
|
+
fields: fields,
|
|
526
|
+
submitText: "Submit demo",
|
|
527
|
+
cancelText: "Clear",
|
|
528
|
+
customActions: customActions,
|
|
529
|
+
validateOnChange: true,
|
|
530
|
+
validateOnSubmit: true,
|
|
531
|
+
onSubmit: function onSubmit(data) {
|
|
532
|
+
console.log("Submitted:", data);
|
|
533
|
+
setLastSubmit(data);
|
|
534
|
+
},
|
|
535
|
+
onCancel: function onCancel() {
|
|
536
|
+
return setLastSubmit(null);
|
|
537
|
+
}
|
|
538
|
+
// Date handlers
|
|
539
|
+
,
|
|
540
|
+
onChangeTime: function onChangeTime(date, name) {
|
|
541
|
+
return console.log("date:", name, date);
|
|
542
|
+
},
|
|
543
|
+
onChangeYear: function onChangeYear(date, name) {
|
|
544
|
+
return console.log("year:", name, date);
|
|
545
|
+
}
|
|
546
|
+
// Search
|
|
547
|
+
,
|
|
548
|
+
handleSearchChange: function handleSearchChange() {},
|
|
549
|
+
handleResultSelect: function handleResultSelect() {}
|
|
550
|
+
}), lastSubmit && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
551
|
+
style: {
|
|
552
|
+
marginTop: "2rem",
|
|
553
|
+
padding: "1rem",
|
|
554
|
+
background: "#f0f8f0",
|
|
555
|
+
borderRadius: 8,
|
|
556
|
+
border: "1px solid #b2dfb2"
|
|
557
|
+
},
|
|
558
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
|
|
559
|
+
children: "Last submitted data:"
|
|
560
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("pre", {
|
|
561
|
+
style: {
|
|
562
|
+
marginTop: 8,
|
|
563
|
+
fontSize: "0.8rem",
|
|
564
|
+
overflow: "auto"
|
|
565
|
+
},
|
|
566
|
+
children: JSON.stringify(lastSubmit, null, 2)
|
|
567
|
+
})]
|
|
568
|
+
})]
|
|
569
|
+
});
|
|
558
570
|
};
|
|
559
571
|
var _default = exports["default"] = Demo;
|