@algolia/satellite 2.3.0-rc.5 → 2.3.0-rc.6
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/dist/cjs/Fields/Checkbox/Checkbox.d.ts +2 -2
- package/dist/cjs/Fields/Checkbox/Checkbox.js +2 -2
- package/dist/cjs/Fields/Dropzone/Dropzone.js +1 -1
- package/dist/cjs/Fields/Form/stories/Complex.js +123 -50
- package/dist/cjs/Fields/RadioGroup/RadioButton.js +9 -2
- package/dist/cjs/Fields/RadioGroup/RadioButton.tailwind.js +1 -1
- package/dist/cjs/Fields/RadioGroup/RadioGroupItem.js +1 -1
- package/dist/cjs/Fields/SelectableCard/SelectableCard.d.ts +35 -0
- package/dist/cjs/Fields/SelectableCard/SelectableCard.js +105 -0
- package/dist/cjs/Fields/SelectableCard/SelectableCardContext.d.ts +13 -0
- package/dist/cjs/Fields/SelectableCard/SelectableCardContext.js +15 -0
- package/dist/cjs/Fields/SelectableCard/SelectableCardGroup.d.ts +13 -0
- package/dist/cjs/Fields/SelectableCard/SelectableCardGroup.js +55 -0
- package/dist/cjs/Fields/SelectableCard/index.d.ts +2 -0
- package/dist/cjs/Fields/SelectableCard/index.js +27 -0
- package/dist/cjs/Fields/Switch/Switch.js +1 -1
- package/dist/cjs/Fields/index.d.ts +1 -0
- package/dist/cjs/Fields/index.js +11 -0
- package/dist/cjs/Helpers/utilities/focusable.tailwind.js +1 -1
- package/dist/esm/Fields/Checkbox/Checkbox.d.ts +2 -2
- package/dist/esm/Fields/Checkbox/Checkbox.js +2 -2
- package/dist/esm/Fields/Dropzone/Dropzone.js +1 -1
- package/dist/esm/Fields/Form/stories/Complex.js +123 -50
- package/dist/esm/Fields/RadioGroup/RadioButton.js +10 -3
- package/dist/esm/Fields/RadioGroup/RadioButton.tailwind.js +1 -1
- package/dist/esm/Fields/RadioGroup/RadioGroupItem.js +1 -1
- package/dist/esm/Fields/SelectableCard/SelectableCard.d.ts +35 -0
- package/dist/esm/Fields/SelectableCard/SelectableCard.js +100 -0
- package/dist/esm/Fields/SelectableCard/SelectableCardContext.d.ts +13 -0
- package/dist/esm/Fields/SelectableCard/SelectableCardContext.js +9 -0
- package/dist/esm/Fields/SelectableCard/SelectableCardGroup.d.ts +13 -0
- package/dist/esm/Fields/SelectableCard/SelectableCardGroup.js +48 -0
- package/dist/esm/Fields/SelectableCard/index.d.ts +2 -0
- package/dist/esm/Fields/SelectableCard/index.js +2 -0
- package/dist/esm/Fields/Switch/Switch.js +1 -1
- package/dist/esm/Fields/index.d.ts +1 -0
- package/dist/esm/Fields/index.js +1 -0
- package/dist/esm/Helpers/utilities/focusable.tailwind.js +1 -1
- package/dist/satellite.min.css +1 -1
- package/package.json +2 -2
@@ -1,7 +1,7 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
2
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
4
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30, _templateObject31, _templateObject32, _templateObject33, _templateObject34, _templateObject35, _templateObject36, _templateObject37, _templateObject38, _templateObject39, _templateObject40, _templateObject41, _templateObject42, _templateObject43, _templateObject44, _templateObject45, _templateObject46, _templateObject47, _templateObject48, _templateObject49, _templateObject50;
|
4
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30, _templateObject31, _templateObject32, _templateObject33, _templateObject34, _templateObject35, _templateObject36, _templateObject37, _templateObject38, _templateObject39, _templateObject40, _templateObject41, _templateObject42, _templateObject43, _templateObject44, _templateObject45, _templateObject46, _templateObject47, _templateObject48, _templateObject49, _templateObject50, _templateObject51, _templateObject52, _templateObject53, _templateObject54, _templateObject55, _templateObject56, _templateObject57, _templateObject58;
|
5
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
7
7
|
import { zodResolver } from "@hookform/resolvers/zod";
|
@@ -19,6 +19,8 @@ import { Input } from "./../../Input";
|
|
19
19
|
import { RadioButton, RadioGroup } from "./../../RadioGroup";
|
20
20
|
import { RangeSlider } from "./../../RangeSlider";
|
21
21
|
import { Select } from "./../../Select";
|
22
|
+
import { SelectableCard } from "./../../SelectableCard/SelectableCard";
|
23
|
+
import { SelectableCardGroup } from "./../../SelectableCard/SelectableCardGroup";
|
22
24
|
import { Switch } from "./../../Switch";
|
23
25
|
import { TextArea } from "./../../TextArea";
|
24
26
|
import stl from "./../../../styles/helpers/satellitePrefixer";
|
@@ -33,6 +35,7 @@ var initialFormData = {
|
|
33
35
|
employmentStatus: "",
|
34
36
|
birthday: null,
|
35
37
|
age: "",
|
38
|
+
hobbies: [],
|
36
39
|
interest: 0,
|
37
40
|
idealLocation: [0, 50],
|
38
41
|
profilePicture: null,
|
@@ -50,6 +53,7 @@ var jobPositions = ["Frontend Developer", "Backend Developer", "Fullstack Develo
|
|
50
53
|
var now = new Date();
|
51
54
|
var genders = ["please select", "woman", "man", "transgender man", "transgender woman", "non-binary", "agender", "prefer not to state"];
|
52
55
|
var employmentStatuses = ["employed", "unemployed", "student"];
|
56
|
+
var hobbies = ["reading", "writing", "coding"];
|
53
57
|
var zodSchema = z.object({
|
54
58
|
firstName: z.string().min(1, {
|
55
59
|
message: "You must specify a first name"
|
@@ -110,6 +114,15 @@ var zodSchema = z.object({
|
|
110
114
|
}).lte(100, {
|
111
115
|
message: "You must be at most 100 years old"
|
112
116
|
}),
|
117
|
+
hobbies: z.array(z["enum"](hobbies, {
|
118
|
+
errorMap: function errorMap() {
|
119
|
+
return {
|
120
|
+
message: "You must specify at least one hobby"
|
121
|
+
};
|
122
|
+
}
|
123
|
+
})).min(1, {
|
124
|
+
message: "You must specify at least one hobby"
|
125
|
+
}),
|
113
126
|
interest: z.number().min(5, {
|
114
127
|
message: "Your level of interest must be at least 5"
|
115
128
|
}),
|
@@ -405,18 +418,50 @@ export var RHFComplexComponent = function RHFComplexComponent() {
|
|
405
418
|
});
|
406
419
|
}
|
407
420
|
}), /*#__PURE__*/_jsx(Controller, {
|
408
|
-
name: "
|
421
|
+
name: "hobbies",
|
409
422
|
control: control,
|
410
423
|
render: function render(_ref10) {
|
411
424
|
var field = _ref10.field;
|
425
|
+
return /*#__PURE__*/_jsx(Field, {
|
426
|
+
label: "Hobbies",
|
427
|
+
labelFor: hobbies[0],
|
428
|
+
description: "Please specify your hobbies",
|
429
|
+
state: getFieldState("hobbies"),
|
430
|
+
className: stl(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["w-full"]))),
|
431
|
+
children: /*#__PURE__*/_jsx(SelectableCardGroup, {
|
432
|
+
type: "multiple",
|
433
|
+
className: stl(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["flex gap-2"]))),
|
434
|
+
value: field.value,
|
435
|
+
onValueChange: field.onChange,
|
436
|
+
required: true,
|
437
|
+
children: hobbies.map(function (hobby) {
|
438
|
+
return /*#__PURE__*/_jsx("label", {
|
439
|
+
htmlFor: hobby,
|
440
|
+
className: stl(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["flex-1 cursor-pointer"]))),
|
441
|
+
children: /*#__PURE__*/_jsx(SelectableCard, {
|
442
|
+
id: hobby,
|
443
|
+
value: hobby,
|
444
|
+
className: stl(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["p-4"]))),
|
445
|
+
children: capitalize(hobby)
|
446
|
+
})
|
447
|
+
}, hobby);
|
448
|
+
})
|
449
|
+
})
|
450
|
+
});
|
451
|
+
}
|
452
|
+
}), /*#__PURE__*/_jsx(Controller, {
|
453
|
+
name: "interest",
|
454
|
+
control: control,
|
455
|
+
render: function render(_ref11) {
|
456
|
+
var field = _ref11.field;
|
412
457
|
return /*#__PURE__*/_jsxs(Field, {
|
413
458
|
label: "Interest",
|
414
459
|
labelFor: "interest",
|
415
460
|
description: "Please specify your interest",
|
416
461
|
state: getFieldState("interest"),
|
417
|
-
className: stl(
|
462
|
+
className: stl(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["w-full"]))),
|
418
463
|
children: [/*#__PURE__*/_jsxs("p", {
|
419
|
-
className: stl(
|
464
|
+
className: stl(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["display-caption flex justify-between mb-2"]))),
|
420
465
|
children: [/*#__PURE__*/_jsx("span", {
|
421
466
|
children: "0"
|
422
467
|
}), /*#__PURE__*/_jsx("span", {
|
@@ -435,16 +480,16 @@ export var RHFComplexComponent = function RHFComplexComponent() {
|
|
435
480
|
}), /*#__PURE__*/_jsx(Controller, {
|
436
481
|
name: "idealLocation",
|
437
482
|
control: control,
|
438
|
-
render: function render(
|
439
|
-
var field =
|
483
|
+
render: function render(_ref12) {
|
484
|
+
var field = _ref12.field;
|
440
485
|
return /*#__PURE__*/_jsxs(Field, {
|
441
486
|
label: "Ideal Location",
|
442
487
|
labelFor: "idealLocation",
|
443
488
|
description: "Please specify your ideal location",
|
444
489
|
state: getFieldState("idealLocation"),
|
445
|
-
className: stl(
|
490
|
+
className: stl(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["w-full"]))),
|
446
491
|
children: [/*#__PURE__*/_jsxs("p", {
|
447
|
-
className: stl(
|
492
|
+
className: stl(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["display-caption flex justify-between mb-2"]))),
|
448
493
|
children: [/*#__PURE__*/_jsx("span", {
|
449
494
|
children: "0 km"
|
450
495
|
}), /*#__PURE__*/_jsx("span", {
|
@@ -470,14 +515,14 @@ export var RHFComplexComponent = function RHFComplexComponent() {
|
|
470
515
|
}), /*#__PURE__*/_jsx(Controller, {
|
471
516
|
name: "profilePicture",
|
472
517
|
control: control,
|
473
|
-
render: function render(
|
474
|
-
var field =
|
518
|
+
render: function render(_ref13) {
|
519
|
+
var field = _ref13.field;
|
475
520
|
return /*#__PURE__*/_jsx(Field, {
|
476
521
|
label: "Profile Picture",
|
477
522
|
labelFor: "profilePicture",
|
478
523
|
description: "Please upload your profile picture, 1 MB minimum",
|
479
524
|
state: getFieldState("profilePicture"),
|
480
|
-
className: stl(
|
525
|
+
className: stl(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["w-full"]))),
|
481
526
|
children: /*#__PURE__*/_jsx(Dropzone, _objectSpread(_objectSpread({
|
482
527
|
id: "profilePicture",
|
483
528
|
minSize: 1024 * 1024 * 1,
|
@@ -493,14 +538,14 @@ export var RHFComplexComponent = function RHFComplexComponent() {
|
|
493
538
|
}), /*#__PURE__*/_jsx(Controller, {
|
494
539
|
name: "bio",
|
495
540
|
control: control,
|
496
|
-
render: function render(
|
497
|
-
var field =
|
541
|
+
render: function render(_ref14) {
|
542
|
+
var field = _ref14.field;
|
498
543
|
return /*#__PURE__*/_jsx(Field, {
|
499
544
|
label: "Bio",
|
500
545
|
labelFor: "bio",
|
501
546
|
description: "Please write a short bio",
|
502
547
|
state: getFieldState("bio"),
|
503
|
-
className: stl(
|
548
|
+
className: stl(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["w-full"]))),
|
504
549
|
children: /*#__PURE__*/_jsx(TextArea, _objectSpread({
|
505
550
|
id: "bio",
|
506
551
|
required: true
|
@@ -510,14 +555,14 @@ export var RHFComplexComponent = function RHFComplexComponent() {
|
|
510
555
|
}), /*#__PURE__*/_jsx(Controller, {
|
511
556
|
name: "acceptTerms",
|
512
557
|
control: control,
|
513
|
-
render: function render(
|
514
|
-
var field =
|
558
|
+
render: function render(_ref15) {
|
559
|
+
var field = _ref15.field;
|
515
560
|
return /*#__PURE__*/_jsx(Field, {
|
516
561
|
label: "Accept Terms",
|
517
562
|
labelFor: "acceptTerms",
|
518
563
|
description: "Please accept the terms",
|
519
564
|
state: getFieldState("acceptTerms"),
|
520
|
-
className: stl(
|
565
|
+
className: stl(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["w-full"]))),
|
521
566
|
inline: true,
|
522
567
|
children: /*#__PURE__*/_jsx(Checkbox, _objectSpread({
|
523
568
|
id: "acceptTerms",
|
@@ -529,14 +574,14 @@ export var RHFComplexComponent = function RHFComplexComponent() {
|
|
529
574
|
}), /*#__PURE__*/_jsx(Controller, {
|
530
575
|
name: "newsletter",
|
531
576
|
control: control,
|
532
|
-
render: function render(
|
533
|
-
var field =
|
577
|
+
render: function render(_ref16) {
|
578
|
+
var field = _ref16.field;
|
534
579
|
return /*#__PURE__*/_jsx(Field, {
|
535
580
|
label: "Receive Newsletter",
|
536
581
|
labelFor: "newsletter",
|
537
582
|
description: "Do you want to receive our newsletter?",
|
538
583
|
state: getFieldState("newsletter"),
|
539
|
-
className: stl(
|
584
|
+
className: stl(_templateObject26 || (_templateObject26 = _taggedTemplateLiteral(["w-full"]))),
|
540
585
|
inline: true,
|
541
586
|
children: /*#__PURE__*/_jsx(Switch, _objectSpread({
|
542
587
|
id: "newsletter",
|
@@ -546,7 +591,7 @@ export var RHFComplexComponent = function RHFComplexComponent() {
|
|
546
591
|
});
|
547
592
|
}
|
548
593
|
}), /*#__PURE__*/_jsxs("div", {
|
549
|
-
className: stl(
|
594
|
+
className: stl(_templateObject27 || (_templateObject27 = _taggedTemplateLiteral(["flex gap-2"]))),
|
550
595
|
children: [/*#__PURE__*/_jsx(FormSubmit, {
|
551
596
|
variant: "primary",
|
552
597
|
"aria-label": "Save the form",
|
@@ -560,9 +605,9 @@ export var RHFComplexComponent = function RHFComplexComponent() {
|
|
560
605
|
})]
|
561
606
|
})]
|
562
607
|
}), /*#__PURE__*/_jsx("hr", {
|
563
|
-
className: stl(
|
608
|
+
className: stl(_templateObject28 || (_templateObject28 = _taggedTemplateLiteral(["text-grey-500"])))
|
564
609
|
}), /*#__PURE__*/_jsx("code", {
|
565
|
-
className: stl(
|
610
|
+
className: stl(_templateObject29 || (_templateObject29 = _taggedTemplateLiteral(["whitespace-pre display-code"]))),
|
566
611
|
children: JSON.stringify(formData, null, 2)
|
567
612
|
})]
|
568
613
|
})
|
@@ -583,10 +628,11 @@ var yupSchema = yup.object({
|
|
583
628
|
return value < now;
|
584
629
|
}),
|
585
630
|
age: yup.number().min(18, "You must be at least 18 years old").max(100, "You must be at most 100 years old").required("You must specify an age"),
|
631
|
+
hobbies: yup.array(yup.string().oneOf(hobbies)).min(1, "You must specify at least one hobby"),
|
586
632
|
interest: yup.number().min(5, "Your level of interest must be at least 5").required(),
|
587
633
|
idealLocation: yup.array(yup.number().min(10, "Your minimum ideal location must be 10 km").max(40, "Your maximum ideal location must be 40 km").required()).required(),
|
588
|
-
profilePicture: yup.mixed().nullable().test("profilePicture", function (
|
589
|
-
var value =
|
634
|
+
profilePicture: yup.mixed().nullable().test("profilePicture", function (_ref17) {
|
635
|
+
var value = _ref17.value;
|
590
636
|
return value.errors.map(function (error) {
|
591
637
|
return error.message;
|
592
638
|
}).join(", ");
|
@@ -638,9 +684,9 @@ export var FormikComplexComponent = function FormikComplexComponent() {
|
|
638
684
|
};
|
639
685
|
useFormikAutoFocusOnError(formik);
|
640
686
|
return /*#__PURE__*/_jsx("div", {
|
641
|
-
className: stl(
|
687
|
+
className: stl(_templateObject30 || (_templateObject30 = _taggedTemplateLiteral(["@container w-full flex justify-center"]))),
|
642
688
|
children: /*#__PURE__*/_jsxs("div", {
|
643
|
-
className: stl(
|
689
|
+
className: stl(_templateObject31 || (_templateObject31 = _taggedTemplateLiteral(["flex flex-col gap-8 w-full @lg:w-1/2"]))),
|
644
690
|
children: [/*#__PURE__*/_jsxs(Form, {
|
645
691
|
onSubmit: function onSubmit(e) {
|
646
692
|
setRevalidationEnabled(true);
|
@@ -650,13 +696,13 @@ export var FormikComplexComponent = function FormikComplexComponent() {
|
|
650
696
|
setRevalidationEnabled(false);
|
651
697
|
formik.handleReset(e);
|
652
698
|
},
|
653
|
-
className: stl(
|
699
|
+
className: stl(_templateObject32 || (_templateObject32 = _taggedTemplateLiteral(["flex flex-col items-start gap-6 min-w-72"]))),
|
654
700
|
children: [/*#__PURE__*/_jsx(FormErrorMessage, {}), /*#__PURE__*/_jsx(Field, {
|
655
701
|
label: "First Name",
|
656
702
|
labelFor: "firstName",
|
657
703
|
description: "Please enter your first name",
|
658
704
|
state: getFieldState("firstName"),
|
659
|
-
className: stl(
|
705
|
+
className: stl(_templateObject33 || (_templateObject33 = _taggedTemplateLiteral(["w-full"]))),
|
660
706
|
children: /*#__PURE__*/_jsx(Input, _objectSpread({
|
661
707
|
id: "firstName",
|
662
708
|
placeholder: "John",
|
@@ -667,7 +713,7 @@ export var FormikComplexComponent = function FormikComplexComponent() {
|
|
667
713
|
labelFor: "lastName",
|
668
714
|
description: "Please enter your last name",
|
669
715
|
state: getFieldState("lastName"),
|
670
|
-
className: stl(
|
716
|
+
className: stl(_templateObject34 || (_templateObject34 = _taggedTemplateLiteral(["w-full"]))),
|
671
717
|
children: /*#__PURE__*/_jsx(Input, _objectSpread({
|
672
718
|
id: "lastName",
|
673
719
|
placeholder: "Doe",
|
@@ -678,7 +724,7 @@ export var FormikComplexComponent = function FormikComplexComponent() {
|
|
678
724
|
labelFor: "password",
|
679
725
|
description: "Please enter your password",
|
680
726
|
state: getFieldState("password"),
|
681
|
-
className: stl(
|
727
|
+
className: stl(_templateObject35 || (_templateObject35 = _taggedTemplateLiteral(["w-full"]))),
|
682
728
|
children: /*#__PURE__*/_jsx(Input, _objectSpread({
|
683
729
|
id: "password",
|
684
730
|
placeholder: "Password",
|
@@ -690,14 +736,14 @@ export var FormikComplexComponent = function FormikComplexComponent() {
|
|
690
736
|
labelFor: civilities[0],
|
691
737
|
description: "Please enter your civility",
|
692
738
|
state: getFieldState("civility"),
|
693
|
-
className: stl(
|
739
|
+
className: stl(_templateObject36 || (_templateObject36 = _taggedTemplateLiteral(["w-full"]))),
|
694
740
|
children: /*#__PURE__*/_jsx("div", {
|
695
|
-
className: stl(
|
741
|
+
className: stl(_templateObject37 || (_templateObject37 = _taggedTemplateLiteral(["flex gap-4 display-body"]))),
|
696
742
|
children: civilities.map(function (civility, index) {
|
697
743
|
return /*#__PURE__*/_jsxs("label", {
|
698
744
|
id: index === 0 ? "civility" : undefined,
|
699
745
|
htmlFor: civility,
|
700
|
-
className: stl(
|
746
|
+
className: stl(_templateObject38 || (_templateObject38 = _taggedTemplateLiteral(["flex items-center gap-1"]))),
|
701
747
|
children: [/*#__PURE__*/_jsx(RadioButton, _objectSpread({
|
702
748
|
id: civility,
|
703
749
|
"aria-labelledby": civility,
|
@@ -715,7 +761,7 @@ export var FormikComplexComponent = function FormikComplexComponent() {
|
|
715
761
|
labelFor: "gender",
|
716
762
|
description: "Please specify your gender",
|
717
763
|
state: getFieldState("gender"),
|
718
|
-
className: stl(
|
764
|
+
className: stl(_templateObject39 || (_templateObject39 = _taggedTemplateLiteral(["w-full"]))),
|
719
765
|
children: /*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({
|
720
766
|
id: "gender",
|
721
767
|
required: true
|
@@ -732,7 +778,7 @@ export var FormikComplexComponent = function FormikComplexComponent() {
|
|
732
778
|
labelFor: "jobPositions",
|
733
779
|
description: "Please specify the job positions you are interested in",
|
734
780
|
state: getFieldState("jobPositions"),
|
735
|
-
className: stl(
|
781
|
+
className: stl(_templateObject40 || (_templateObject40 = _taggedTemplateLiteral(["w-full"]))),
|
736
782
|
children: /*#__PURE__*/_jsx(AutoComplete, {
|
737
783
|
id: "jobPositions",
|
738
784
|
options: jobPositions,
|
@@ -751,7 +797,7 @@ export var FormikComplexComponent = function FormikComplexComponent() {
|
|
751
797
|
labelFor: "employmentStatus",
|
752
798
|
description: "Please specify your employment status",
|
753
799
|
state: getFieldState("employmentStatus"),
|
754
|
-
className: stl(
|
800
|
+
className: stl(_templateObject41 || (_templateObject41 = _taggedTemplateLiteral(["w-full"]))),
|
755
801
|
children: /*#__PURE__*/_jsx(RadioGroup, {
|
756
802
|
id: "employmentStatus",
|
757
803
|
required: true,
|
@@ -771,7 +817,7 @@ export var FormikComplexComponent = function FormikComplexComponent() {
|
|
771
817
|
labelFor: "birthday",
|
772
818
|
description: "Please specify your birthday",
|
773
819
|
state: getFieldState("birthday"),
|
774
|
-
className: stl(
|
820
|
+
className: stl(_templateObject42 || (_templateObject42 = _taggedTemplateLiteral(["w-full"]))),
|
775
821
|
children: /*#__PURE__*/_jsx(DateInput, {
|
776
822
|
id: "birthday",
|
777
823
|
required: true,
|
@@ -792,7 +838,7 @@ export var FormikComplexComponent = function FormikComplexComponent() {
|
|
792
838
|
labelFor: "age",
|
793
839
|
description: "Please specify your age",
|
794
840
|
state: getFieldState("age"),
|
795
|
-
className: stl(
|
841
|
+
className: stl(_templateObject43 || (_templateObject43 = _taggedTemplateLiteral(["w-full"]))),
|
796
842
|
children: /*#__PURE__*/_jsx(Input, _objectSpread({
|
797
843
|
id: "age",
|
798
844
|
type: "number",
|
@@ -800,14 +846,41 @@ export var FormikComplexComponent = function FormikComplexComponent() {
|
|
800
846
|
step: 1,
|
801
847
|
required: true
|
802
848
|
}, formik.getFieldProps("age")))
|
849
|
+
}), /*#__PURE__*/_jsx(Field, {
|
850
|
+
label: "Hobbies",
|
851
|
+
labelFor: hobbies[0],
|
852
|
+
description: "Please specify your hobbies",
|
853
|
+
state: getFieldState("hobbies"),
|
854
|
+
className: stl(_templateObject44 || (_templateObject44 = _taggedTemplateLiteral(["w-full"]))),
|
855
|
+
children: /*#__PURE__*/_jsx(SelectableCardGroup, {
|
856
|
+
type: "multiple",
|
857
|
+
className: stl(_templateObject45 || (_templateObject45 = _taggedTemplateLiteral(["flex gap-2"]))),
|
858
|
+
value: formik.values.hobbies,
|
859
|
+
onValueChange: function onValueChange(value) {
|
860
|
+
return formik.setFieldValue("hobbies", value);
|
861
|
+
},
|
862
|
+
required: true,
|
863
|
+
children: hobbies.map(function (hobby) {
|
864
|
+
return /*#__PURE__*/_jsx("label", {
|
865
|
+
htmlFor: hobby,
|
866
|
+
className: stl(_templateObject46 || (_templateObject46 = _taggedTemplateLiteral(["flex-1 cursor-pointer"]))),
|
867
|
+
children: /*#__PURE__*/_jsx(SelectableCard, {
|
868
|
+
id: hobby,
|
869
|
+
value: hobby,
|
870
|
+
className: stl(_templateObject47 || (_templateObject47 = _taggedTemplateLiteral(["p-4"]))),
|
871
|
+
children: capitalize(hobby)
|
872
|
+
})
|
873
|
+
}, hobby);
|
874
|
+
})
|
875
|
+
})
|
803
876
|
}), /*#__PURE__*/_jsxs(Field, {
|
804
877
|
label: "Interest",
|
805
878
|
labelFor: "interest",
|
806
879
|
description: "Please specify your interest",
|
807
880
|
state: getFieldState("interest"),
|
808
|
-
className: stl(
|
881
|
+
className: stl(_templateObject48 || (_templateObject48 = _taggedTemplateLiteral(["w-full"]))),
|
809
882
|
children: [/*#__PURE__*/_jsxs("p", {
|
810
|
-
className: stl(
|
883
|
+
className: stl(_templateObject49 || (_templateObject49 = _taggedTemplateLiteral(["display-caption flex justify-between mb-2"]))),
|
811
884
|
children: [/*#__PURE__*/_jsx("span", {
|
812
885
|
children: "0"
|
813
886
|
}), /*#__PURE__*/_jsx("span", {
|
@@ -830,9 +903,9 @@ export var FormikComplexComponent = function FormikComplexComponent() {
|
|
830
903
|
labelFor: "idealLocation",
|
831
904
|
description: "Please specify your ideal location",
|
832
905
|
state: getFieldState("idealLocation"),
|
833
|
-
className: stl(
|
906
|
+
className: stl(_templateObject50 || (_templateObject50 = _taggedTemplateLiteral(["w-full"]))),
|
834
907
|
children: [/*#__PURE__*/_jsxs("p", {
|
835
|
-
className: stl(
|
908
|
+
className: stl(_templateObject51 || (_templateObject51 = _taggedTemplateLiteral(["display-caption flex justify-between mb-2"]))),
|
836
909
|
children: [/*#__PURE__*/_jsx("span", {
|
837
910
|
children: "0 km"
|
838
911
|
}), /*#__PURE__*/_jsx("span", {
|
@@ -862,7 +935,7 @@ export var FormikComplexComponent = function FormikComplexComponent() {
|
|
862
935
|
labelFor: "profilePicture",
|
863
936
|
description: "Please upload your profile picture, 1 MB minimum",
|
864
937
|
state: getFieldState("profilePicture"),
|
865
|
-
className: stl(
|
938
|
+
className: stl(_templateObject52 || (_templateObject52 = _taggedTemplateLiteral(["w-full"]))),
|
866
939
|
children: /*#__PURE__*/_jsx(Dropzone, {
|
867
940
|
id: "profilePicture",
|
868
941
|
minSize: 1024 * 1024 * 1,
|
@@ -877,7 +950,7 @@ export var FormikComplexComponent = function FormikComplexComponent() {
|
|
877
950
|
labelFor: "bio",
|
878
951
|
description: "Please write a short bio",
|
879
952
|
state: getFieldState("bio"),
|
880
|
-
className: stl(
|
953
|
+
className: stl(_templateObject53 || (_templateObject53 = _taggedTemplateLiteral(["w-full"]))),
|
881
954
|
children: /*#__PURE__*/_jsx(TextArea, _objectSpread({
|
882
955
|
id: "bio",
|
883
956
|
required: true
|
@@ -887,7 +960,7 @@ export var FormikComplexComponent = function FormikComplexComponent() {
|
|
887
960
|
labelFor: "acceptTerms",
|
888
961
|
description: "Please accept the terms",
|
889
962
|
state: getFieldState("acceptTerms"),
|
890
|
-
className: stl(
|
963
|
+
className: stl(_templateObject54 || (_templateObject54 = _taggedTemplateLiteral(["w-full"]))),
|
891
964
|
inline: true,
|
892
965
|
children: /*#__PURE__*/_jsx(Checkbox, _objectSpread({
|
893
966
|
id: "acceptTerms",
|
@@ -899,7 +972,7 @@ export var FormikComplexComponent = function FormikComplexComponent() {
|
|
899
972
|
labelFor: "newsletter",
|
900
973
|
description: "Do you want to receive our newsletter?",
|
901
974
|
state: getFieldState("newsletter"),
|
902
|
-
className: stl(
|
975
|
+
className: stl(_templateObject55 || (_templateObject55 = _taggedTemplateLiteral(["w-full"]))),
|
903
976
|
inline: true,
|
904
977
|
children: /*#__PURE__*/_jsx(Switch, _objectSpread({
|
905
978
|
id: "newsletter",
|
@@ -907,7 +980,7 @@ export var FormikComplexComponent = function FormikComplexComponent() {
|
|
907
980
|
checked: formik.values.newsletter
|
908
981
|
}, formik.getFieldProps("newsletter")))
|
909
982
|
}), /*#__PURE__*/_jsxs("div", {
|
910
|
-
className: stl(
|
983
|
+
className: stl(_templateObject56 || (_templateObject56 = _taggedTemplateLiteral(["flex gap-2"]))),
|
911
984
|
children: [/*#__PURE__*/_jsx(FormSubmit, {
|
912
985
|
variant: "primary",
|
913
986
|
"aria-label": "Save the form",
|
@@ -921,9 +994,9 @@ export var FormikComplexComponent = function FormikComplexComponent() {
|
|
921
994
|
})]
|
922
995
|
})]
|
923
996
|
}), /*#__PURE__*/_jsx("hr", {
|
924
|
-
className: stl(
|
997
|
+
className: stl(_templateObject57 || (_templateObject57 = _taggedTemplateLiteral(["text-grey-500"])))
|
925
998
|
}), /*#__PURE__*/_jsx("code", {
|
926
|
-
className: stl(
|
999
|
+
className: stl(_templateObject58 || (_templateObject58 = _taggedTemplateLiteral(["whitespace-pre display-code"]))),
|
927
1000
|
children: JSON.stringify(formData, null, 2)
|
928
1001
|
})]
|
929
1002
|
})
|
@@ -6,9 +6,10 @@ var _excluded = ["className", "required"];
|
|
6
6
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
7
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
8
8
|
import cx from "clsx";
|
9
|
-
import { forwardRef } from "react";
|
9
|
+
import { forwardRef, useMemo } from "react";
|
10
10
|
import { useField } from "./../Field";
|
11
11
|
import stl from "./../../styles/helpers/satellitePrefixer";
|
12
|
+
import { uniqueId } from "./../../utils";
|
12
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
13
14
|
/**
|
14
15
|
* The `RadioButton` component is a control that allows single selection from a set of options.
|
@@ -24,14 +25,20 @@ export var RadioButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
24
25
|
required: required
|
25
26
|
}),
|
26
27
|
state = _useField.state,
|
27
|
-
descriptionId = _useField.descriptionId
|
28
|
+
descriptionId = _useField.descriptionId,
|
29
|
+
inputId = _useField.inputId;
|
30
|
+
var id = useMemo(function () {
|
31
|
+
var _ref2, _props$id;
|
32
|
+
return (_ref2 = (_props$id = props.id) !== null && _props$id !== void 0 ? _props$id : inputId) !== null && _ref2 !== void 0 ? _ref2 : uniqueId("radio-button");
|
33
|
+
}, [props.id, inputId]);
|
28
34
|
var isInvalid = state.status === "invalid";
|
29
35
|
return /*#__PURE__*/_jsx("input", _objectSpread(_objectSpread({
|
30
36
|
"aria-describedby": descriptionId
|
31
37
|
}, props), {}, {
|
32
38
|
required: required,
|
39
|
+
id: id,
|
33
40
|
"aria-invalid": isInvalid,
|
34
|
-
className: cx(stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["radio-button focusable ", ""])), isInvalid && "radio-button-invalid"), className),
|
41
|
+
className: cx(stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["radio-button focusable-visible ", ""])), isInvalid && "radio-button-invalid"), className),
|
35
42
|
type: "radio",
|
36
43
|
ref: ref
|
37
44
|
}));
|
@@ -43,7 +43,7 @@ export var RadioGroupItem = function RadioGroupItem(_ref) {
|
|
43
43
|
className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["flex-1 truncate ", ""])), textPosition === "right" ? "ml-2" : "mr-2"),
|
44
44
|
children: children
|
45
45
|
}), /*#__PURE__*/_jsx(RadioButton, {
|
46
|
-
id: checked || isFirstChild && !contextValue ? id :
|
46
|
+
id: checked || isFirstChild && !contextValue ? id : uniqueId("radio-group-item"),
|
47
47
|
className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["shrink-0 self-start mt-1"]))),
|
48
48
|
value: value,
|
49
49
|
checked: checked,
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import type { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react";
|
2
|
+
import type { CardProps } from "../../Layout";
|
3
|
+
import { Card } from "../../Layout";
|
4
|
+
declare type SelectableCardBaseProps = Omit<CardProps, "elevation"> & {
|
5
|
+
/**
|
6
|
+
* The color of the selected card.
|
7
|
+
*/
|
8
|
+
selectedColor?: keyof typeof SELECTED_COLOR_CLASSNAMES;
|
9
|
+
};
|
10
|
+
export declare type SelectableCardProps = SelectableCardBaseProps & {
|
11
|
+
/**
|
12
|
+
* Whether the `SelectableCard` is disabled.
|
13
|
+
*/
|
14
|
+
disabled?: boolean;
|
15
|
+
/**
|
16
|
+
* The value of the `SelectableCard`.
|
17
|
+
*/
|
18
|
+
value: string;
|
19
|
+
};
|
20
|
+
interface SelectableCardType extends ForwardRefExoticComponent<PropsWithoutRef<SelectableCardProps> & RefAttributes<HTMLElement>> {
|
21
|
+
Header: typeof Card.Header;
|
22
|
+
Title: typeof Card.Title;
|
23
|
+
}
|
24
|
+
declare const SELECTED_COLOR_CLASSNAMES: {
|
25
|
+
readonly grey: string;
|
26
|
+
readonly pink: string;
|
27
|
+
readonly accent: string;
|
28
|
+
readonly blue: string;
|
29
|
+
readonly green: string;
|
30
|
+
readonly orange: string;
|
31
|
+
readonly red: string;
|
32
|
+
readonly xenon: string;
|
33
|
+
};
|
34
|
+
export declare const SelectableCard: SelectableCardType;
|
35
|
+
export {};
|
@@ -0,0 +1,100 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
5
|
+
var _excluded = ["value", "selectedColor", "children", "id", "className"];
|
6
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18;
|
7
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
8
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
9
|
+
import cx from "clsx";
|
10
|
+
import { forwardRef } from "react";
|
11
|
+
import { Checkbox, RadioButton, useField } from "..";
|
12
|
+
import { Card } from "../../Layout";
|
13
|
+
import stl from "../../styles/helpers/satellitePrefixer";
|
14
|
+
import { useSelectableCardContext } from "./SelectableCardContext";
|
15
|
+
|
16
|
+
// We need to omit the `elevation` prop because we handle it ourselves.
|
17
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
18
|
+
var SELECTED_COLOR_CLASSNAMES = {
|
19
|
+
grey: stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["border-grey-600"]))),
|
20
|
+
pink: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["border-pink-600"]))),
|
21
|
+
accent: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["border-accent-600"]))),
|
22
|
+
blue: stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["border-blue-600"]))),
|
23
|
+
green: stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["border-green-600"]))),
|
24
|
+
orange: stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["border-orange-600"]))),
|
25
|
+
red: stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["border-red-600"]))),
|
26
|
+
xenon: stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["border-xenon-600"])))
|
27
|
+
};
|
28
|
+
export var SelectableCard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
29
|
+
var value = _ref.value,
|
30
|
+
_ref$selectedColor = _ref.selectedColor,
|
31
|
+
selectedColor = _ref$selectedColor === void 0 ? "xenon" : _ref$selectedColor,
|
32
|
+
children = _ref.children,
|
33
|
+
id = _ref.id,
|
34
|
+
className = _ref.className,
|
35
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
36
|
+
var _useSelectableCardCon = useSelectableCardContext(),
|
37
|
+
name = _useSelectableCardCon.name,
|
38
|
+
isControlled = _useSelectableCardCon.isControlled,
|
39
|
+
setValue = _useSelectableCardCon.setValue,
|
40
|
+
onValueChange = _useSelectableCardCon.onValueChange,
|
41
|
+
type = _useSelectableCardCon.type,
|
42
|
+
valueContext = _useSelectableCardCon.value,
|
43
|
+
disabledContext = _useSelectableCardCon.disabled;
|
44
|
+
var disabled = props.disabled || disabledContext;
|
45
|
+
var selected = valueContext === null || valueContext === void 0 ? void 0 : valueContext.includes(value);
|
46
|
+
var _useField = useField(),
|
47
|
+
status = _useField.state.status;
|
48
|
+
var isInvalid = status === "invalid";
|
49
|
+
var handleCheckboxChange = function handleCheckboxChange(evt) {
|
50
|
+
var _valueContext$filter;
|
51
|
+
var newValue = selected ? (_valueContext$filter = valueContext === null || valueContext === void 0 ? void 0 : valueContext.filter(function (v) {
|
52
|
+
return v !== value;
|
53
|
+
})) !== null && _valueContext$filter !== void 0 ? _valueContext$filter : [] : [].concat(_toConsumableArray(valueContext !== null && valueContext !== void 0 ? valueContext : []), [value]);
|
54
|
+
if (!isControlled && !evt.isDefaultPrevented()) {
|
55
|
+
setValue(newValue);
|
56
|
+
}
|
57
|
+
onValueChange === null || onValueChange === void 0 || onValueChange(newValue);
|
58
|
+
};
|
59
|
+
var handleRadioButtonChange = function handleRadioButtonChange(evt) {
|
60
|
+
var newValue = [evt.target.value];
|
61
|
+
if (!isControlled && !evt.isDefaultPrevented()) {
|
62
|
+
setValue(newValue);
|
63
|
+
}
|
64
|
+
onValueChange === null || onValueChange === void 0 || onValueChange(newValue);
|
65
|
+
};
|
66
|
+
return /*#__PURE__*/_jsxs(Card, _objectSpread(_objectSpread({
|
67
|
+
ref: ref,
|
68
|
+
fullBleed: true,
|
69
|
+
className: cx(stl(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["relative border transition-[shadow,border]"]))), !disabled && !selected && !isInvalid && stl(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["border-transparent"]))),
|
70
|
+
// Disabled
|
71
|
+
disabled && stl(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["bg-grey-100 border-grey-200 text-grey-300 shadow-none cursor-not-allowed [&>*]:text-grey-300"]))),
|
72
|
+
// Selected
|
73
|
+
selected && stl(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["card-z200"]))), !disabled && selected && !isInvalid && SELECTED_COLOR_CLASSNAMES[selectedColor],
|
74
|
+
// Hovered
|
75
|
+
!disabled && !selected && !isInvalid && stl(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["hover:border-grey-200"]))), // Focused
|
76
|
+
stl(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["focusable-visible-within"]))), !selected && stl(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["focus-within:border-grey-200"]))),
|
77
|
+
// Invalid
|
78
|
+
isInvalid && stl(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["border-red-700 shadow-none"]))),
|
79
|
+
// Custom
|
80
|
+
className)
|
81
|
+
}, props), {}, {
|
82
|
+
children: [type === "multiple" ? /*#__PURE__*/_jsx(Checkbox, {
|
83
|
+
id: id,
|
84
|
+
disabled: disabled,
|
85
|
+
checked: selected,
|
86
|
+
className: cx(stl(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["absolute right-4 top-4 z-10"])))),
|
87
|
+
onChange: handleCheckboxChange,
|
88
|
+
name: name
|
89
|
+
}) : /*#__PURE__*/_jsx(RadioButton, {
|
90
|
+
id: id,
|
91
|
+
disabled: disabled,
|
92
|
+
checked: selected,
|
93
|
+
className: cx(stl(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["absolute right-4 top-4 z-10"])))),
|
94
|
+
onChange: handleRadioButtonChange,
|
95
|
+
value: value,
|
96
|
+
name: name
|
97
|
+
}), children]
|
98
|
+
}));
|
99
|
+
});
|
100
|
+
SelectableCard.displayName = "SelectableCard";
|