@planetaexo/design-system 0.4.21 → 0.5.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.
package/dist/index.cjs CHANGED
@@ -16,6 +16,7 @@ var checkbox = require('@base-ui/react/checkbox');
16
16
  var accordion = require('@base-ui/react/accordion');
17
17
  var mergeProps = require('@base-ui/react/merge-props');
18
18
  var useRender = require('@base-ui/react/use-render');
19
+ var reactDom = require('react-dom');
19
20
  var input = require('@base-ui/react/input');
20
21
 
21
22
  function _interopNamespace(e) {
@@ -628,7 +629,8 @@ var PHONE_COUNTRIES = [...PHONE_PRIORITY, ...PHONE_REST];
628
629
  function PhoneCountrySelect({
629
630
  value,
630
631
  onChange,
631
- className
632
+ className,
633
+ disabled
632
634
  }) {
633
635
  var _a;
634
636
  const [open, setOpen] = React22__namespace.useState(false);
@@ -652,6 +654,7 @@ function PhoneCountrySelect({
652
654
  activeEl == null ? void 0 : activeEl.scrollIntoView({ block: "nearest" });
653
655
  }, [open]);
654
656
  const handleSelect = (code) => {
657
+ if (disabled) return;
655
658
  onChange(code);
656
659
  setOpen(false);
657
660
  };
@@ -660,14 +663,19 @@ function PhoneCountrySelect({
660
663
  "button",
661
664
  {
662
665
  type: "button",
663
- onClick: () => setOpen((v) => !v),
666
+ onClick: () => {
667
+ if (disabled) return;
668
+ setOpen((v) => !v);
669
+ },
664
670
  "aria-haspopup": "listbox",
665
671
  "aria-expanded": open,
672
+ disabled,
666
673
  className: cn(
667
674
  "flex h-14 items-center gap-1.5 rounded-l-lg border border-r-0 border-border bg-muted",
668
675
  "px-3 font-ui text-sm text-foreground transition-colors",
669
676
  "focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",
670
- open && "border-primary ring-1 ring-primary"
677
+ open && "border-primary ring-1 ring-primary",
678
+ disabled && "opacity-50 cursor-not-allowed pointer-events-none"
671
679
  ),
672
680
  children: [
673
681
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-base leading-none", children: selected.flag }),
@@ -939,7 +947,8 @@ function BirthDateField({
939
947
  value,
940
948
  onChange,
941
949
  error,
942
- className
950
+ className,
951
+ disabled
943
952
  }) {
944
953
  const [open, setOpen] = React22__namespace.useState(false);
945
954
  const [text, setText] = React22__namespace.useState(
@@ -1004,8 +1013,9 @@ function BirthDateField({
1004
1013
  inputMode: "numeric",
1005
1014
  value: text,
1006
1015
  onChange: handleTextChange,
1016
+ disabled,
1007
1017
  placeholder: "dd/mm/yyyy",
1008
- className: "block h-full w-full bg-transparent px-3 pt-5 pb-2 text-base text-foreground font-ui focus:outline-none placeholder:text-muted-foreground/50"
1018
+ className: "block h-full w-full bg-transparent px-3 pt-5 pb-2 text-base text-foreground font-ui focus:outline-none placeholder:text-muted-foreground/50 disabled:opacity-50 disabled:cursor-not-allowed"
1009
1019
  }
1010
1020
  )
1011
1021
  ] }),
@@ -1013,10 +1023,14 @@ function BirthDateField({
1013
1023
  "button",
1014
1024
  {
1015
1025
  type: "button",
1016
- onClick: () => setOpen((v) => !v),
1026
+ onClick: () => {
1027
+ if (disabled) return;
1028
+ setOpen((v) => !v);
1029
+ },
1017
1030
  tabIndex: -1,
1031
+ disabled,
1018
1032
  "aria-label": "Open calendar",
1019
- className: "px-3 h-full flex items-center text-muted-foreground hover:text-primary transition-colors focus:outline-none",
1033
+ className: "px-3 h-full flex items-center text-muted-foreground hover:text-primary transition-colors focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",
1020
1034
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarIcon, { className: "h-4 w-4" })
1021
1035
  }
1022
1036
  )
@@ -1149,7 +1163,8 @@ function CountrySearchField({
1149
1163
  label = "Country",
1150
1164
  countries,
1151
1165
  placeholder = "Search country\u2026",
1152
- className
1166
+ className,
1167
+ disabled
1153
1168
  }) {
1154
1169
  var _a;
1155
1170
  const list = countries != null ? countries : COUNTRIES;
@@ -1173,6 +1188,7 @@ function CountrySearchField({
1173
1188
  return () => document.removeEventListener("mousedown", handler);
1174
1189
  }, [open]);
1175
1190
  const handleOpen = () => {
1191
+ if (disabled) return;
1176
1192
  setOpen(true);
1177
1193
  setQuery("");
1178
1194
  setTimeout(() => {
@@ -1191,9 +1207,11 @@ function CountrySearchField({
1191
1207
  {
1192
1208
  type: "button",
1193
1209
  onClick: handleOpen,
1210
+ disabled,
1194
1211
  className: cn(
1195
1212
  "relative flex w-full items-center rounded-lg border border-border bg-background h-14 px-3 text-left transition-colors",
1196
- open && "border-primary ring-1 ring-primary"
1213
+ open && "border-primary ring-1 ring-primary",
1214
+ disabled && "opacity-50 cursor-not-allowed pointer-events-none"
1197
1215
  ),
1198
1216
  children: [
1199
1217
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -4203,14 +4221,15 @@ function isFieldEmpty(field, value) {
4203
4221
  return typeof value === "string" ? !value.trim() : false;
4204
4222
  }
4205
4223
  }
4206
- function PhoneInput({ id, label, required, value, onChange, error }) {
4224
+ function PhoneInput({ id, label, required, value, onChange, error, disabled }) {
4207
4225
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full min-w-0", children: [
4208
4226
  /* @__PURE__ */ jsxRuntime.jsx(
4209
4227
  PhoneCountrySelect,
4210
4228
  {
4211
4229
  value: value.country,
4212
4230
  onChange: (country) => onChange(__spreadProps(__spreadValues({}, value), { country })),
4213
- className: "shrink-0"
4231
+ className: "shrink-0",
4232
+ disabled
4214
4233
  }
4215
4234
  ),
4216
4235
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative min-w-0 flex-1", children: [
@@ -4222,6 +4241,7 @@ function PhoneInput({ id, label, required, value, onChange, error }) {
4222
4241
  placeholder: " ",
4223
4242
  value: value.nationalNumber,
4224
4243
  required,
4244
+ disabled,
4225
4245
  onChange: (e) => onChange(__spreadProps(__spreadValues({}, value), { nationalNumber: e.target.value })),
4226
4246
  className: cn(
4227
4247
  "peer block h-14 w-full rounded-r-lg border border-border bg-background",
@@ -4258,7 +4278,8 @@ function FloatingTextarea({
4258
4278
  optionalHint,
4259
4279
  value,
4260
4280
  onChange,
4261
- error
4281
+ error,
4282
+ disabled
4262
4283
  }) {
4263
4284
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
4264
4285
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -4269,6 +4290,7 @@ function FloatingTextarea({
4269
4290
  rows: 5,
4270
4291
  value,
4271
4292
  required,
4293
+ disabled,
4272
4294
  onChange: (e) => onChange(e.target.value),
4273
4295
  className: cn(
4274
4296
  "peer block w-full resize-none rounded-lg border border-border bg-background",
@@ -4297,7 +4319,7 @@ function FloatingTextarea({
4297
4319
  )
4298
4320
  ] });
4299
4321
  }
4300
- function SelectField({ field, value, onChange, error }) {
4322
+ function SelectField({ field, value, onChange, error, disabled }) {
4301
4323
  var _a, _b, _c;
4302
4324
  const [open, setOpen] = React22__namespace.useState(false);
4303
4325
  const containerRef = React22__namespace.useRef(null);
@@ -4318,11 +4340,16 @@ function SelectField({ field, value, onChange, error }) {
4318
4340
  "button",
4319
4341
  {
4320
4342
  type: "button",
4321
- onClick: () => setOpen((o) => !o),
4343
+ onClick: () => {
4344
+ if (disabled) return;
4345
+ setOpen((o) => !o);
4346
+ },
4347
+ disabled,
4322
4348
  className: cn(
4323
4349
  "relative flex w-full items-center rounded-lg border border-border bg-background h-14 px-3 text-left transition-colors",
4324
4350
  open && "border-primary ring-1 ring-primary",
4325
- error && !open && "border-destructive"
4351
+ error && !open && "border-destructive",
4352
+ disabled && "opacity-50 cursor-not-allowed pointer-events-none"
4326
4353
  ),
4327
4354
  children: [
4328
4355
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -4380,7 +4407,8 @@ function FieldRenderer({
4380
4407
  onChange,
4381
4408
  defaultPhoneCountry,
4382
4409
  labels,
4383
- error
4410
+ error,
4411
+ disabled
4384
4412
  }) {
4385
4413
  var _a, _b;
4386
4414
  const fieldId = `rf-${field.id}`;
@@ -4397,6 +4425,7 @@ function FieldRenderer({
4397
4425
  {
4398
4426
  label: labels.firstNameLabel,
4399
4427
  required: field.required,
4428
+ disabled,
4400
4429
  value: v.firstName,
4401
4430
  onChange: (e) => onChange(__spreadProps(__spreadValues({}, v), { firstName: e.target.value })),
4402
4431
  error: error && !v.firstName.trim() ? error : void 0
@@ -4407,6 +4436,7 @@ function FieldRenderer({
4407
4436
  {
4408
4437
  label: labels.lastNameLabel,
4409
4438
  required: field.required,
4439
+ disabled,
4410
4440
  value: v.lastName,
4411
4441
  onChange: (e) => onChange(__spreadProps(__spreadValues({}, v), { lastName: e.target.value })),
4412
4442
  error: error && !v.lastName.trim() ? error : void 0
@@ -4425,7 +4455,8 @@ function FieldRenderer({
4425
4455
  required: field.required,
4426
4456
  value: v,
4427
4457
  onChange,
4428
- error
4458
+ error,
4459
+ disabled
4429
4460
  }
4430
4461
  );
4431
4462
  }
@@ -4443,6 +4474,7 @@ function FieldRenderer({
4443
4474
  {
4444
4475
  label: labels.emergencyContactFirstName,
4445
4476
  required: field.required,
4477
+ disabled,
4446
4478
  value: v.contactName.firstName,
4447
4479
  onChange: (e) => onChange(__spreadProps(__spreadValues({}, v), {
4448
4480
  contactName: __spreadProps(__spreadValues({}, v.contactName), {
@@ -4457,6 +4489,7 @@ function FieldRenderer({
4457
4489
  {
4458
4490
  label: labels.emergencyContactLastName,
4459
4491
  required: field.required,
4492
+ disabled,
4460
4493
  value: v.contactName.lastName,
4461
4494
  onChange: (e) => onChange(__spreadProps(__spreadValues({}, v), {
4462
4495
  contactName: __spreadProps(__spreadValues({}, v.contactName), {
@@ -4475,7 +4508,8 @@ function FieldRenderer({
4475
4508
  required: field.required,
4476
4509
  value: v.phone,
4477
4510
  onChange: (phone) => onChange(__spreadProps(__spreadValues({}, v), { phone })),
4478
- error: error && !v.phone.nationalNumber.trim() ? error : void 0
4511
+ error: error && !v.phone.nationalNumber.trim() ? error : void 0,
4512
+ disabled
4479
4513
  }
4480
4514
  )
4481
4515
  ] })
@@ -4491,7 +4525,8 @@ function FieldRenderer({
4491
4525
  optionalHint: !field.required ? labels.optionalLabel : void 0,
4492
4526
  value: typeof value === "string" ? value : "",
4493
4527
  onChange,
4494
- error
4528
+ error,
4529
+ disabled
4495
4530
  }
4496
4531
  );
4497
4532
  }
@@ -4502,7 +4537,8 @@ function FieldRenderer({
4502
4537
  field,
4503
4538
  value: typeof value === "string" ? value : "",
4504
4539
  onChange: (v) => onChange(v),
4505
- error
4540
+ error,
4541
+ disabled
4506
4542
  }
4507
4543
  );
4508
4544
  }
@@ -4532,6 +4568,7 @@ function FieldRenderer({
4532
4568
  value: opt.value,
4533
4569
  checked: value === opt.value,
4534
4570
  required: field.required,
4571
+ disabled,
4535
4572
  onChange: () => onChange(opt.value),
4536
4573
  className: "h-4 w-4 shrink-0 accent-primary cursor-pointer"
4537
4574
  }
@@ -4555,6 +4592,7 @@ function FieldRenderer({
4555
4592
  {
4556
4593
  type: "checkbox",
4557
4594
  checked: value === true,
4595
+ disabled,
4558
4596
  onChange: (e) => onChange(e.target.checked),
4559
4597
  className: "h-4 w-4 shrink-0 accent-primary cursor-pointer"
4560
4598
  }
@@ -4580,6 +4618,7 @@ function FieldRenderer({
4580
4618
  {
4581
4619
  type: "checkbox",
4582
4620
  checked,
4621
+ disabled,
4583
4622
  onChange: (e) => onChange(
4584
4623
  e.target.checked ? [...selected, opt.value] : selected.filter((x) => x !== opt.value)
4585
4624
  ),
@@ -4601,7 +4640,8 @@ function FieldRenderer({
4601
4640
  label: field.label,
4602
4641
  required: field.required,
4603
4642
  value: typeof value === "string" ? value : "",
4604
- onChange: (code) => onChange(code)
4643
+ onChange: (code) => onChange(code),
4644
+ disabled
4605
4645
  }
4606
4646
  );
4607
4647
  }
@@ -4613,7 +4653,8 @@ function FieldRenderer({
4613
4653
  required: field.required,
4614
4654
  value: asDate(value),
4615
4655
  onChange: (d) => onChange(d),
4616
- error
4656
+ error,
4657
+ disabled
4617
4658
  }
4618
4659
  );
4619
4660
  }
@@ -4624,6 +4665,7 @@ function FieldRenderer({
4624
4665
  label: field.label,
4625
4666
  required: field.required,
4626
4667
  type: "number",
4668
+ disabled,
4627
4669
  value: value == null ? "" : String(value),
4628
4670
  onChange: (e) => onChange(e.target.value),
4629
4671
  error
@@ -4637,6 +4679,7 @@ function FieldRenderer({
4637
4679
  label: field.label,
4638
4680
  required: field.required,
4639
4681
  type: htmlType,
4682
+ disabled,
4640
4683
  value: typeof value === "string" ? value : "",
4641
4684
  onChange: (e) => onChange(e.target.value),
4642
4685
  error
@@ -4667,7 +4710,8 @@ function RegistrationForm({
4667
4710
  defaultPhoneCountry = "BR",
4668
4711
  dateFormatter,
4669
4712
  labels,
4670
- className
4713
+ className,
4714
+ readOnly = false
4671
4715
  }) {
4672
4716
  var _a;
4673
4717
  const L = React22__namespace.useMemo(
@@ -4841,7 +4885,8 @@ function RegistrationForm({
4841
4885
  onChange: (v) => setField(field.id, v),
4842
4886
  defaultPhoneCountry,
4843
4887
  labels: L,
4844
- error: fieldErrors[field.id]
4888
+ error: fieldErrors[field.id],
4889
+ disabled: readOnly
4845
4890
  }
4846
4891
  ),
4847
4892
  ((_a2 = field.helpText) == null ? void 0 : _a2.trim()) && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground font-ui leading-relaxed", children: field.helpText.trim() })
@@ -4864,6 +4909,7 @@ function RegistrationForm({
4864
4909
  type: "checkbox",
4865
4910
  checked: termsAccepted,
4866
4911
  required: true,
4912
+ disabled: readOnly,
4867
4913
  onChange: (e) => setField(TERMS_ACCEPT_KEY, e.target.checked),
4868
4914
  className: "mt-0.5 h-4 w-4 shrink-0 accent-primary cursor-pointer"
4869
4915
  }
@@ -4899,6 +4945,7 @@ function RegistrationForm({
4899
4945
  name: "registration-terms-accept",
4900
4946
  checked: termsAccepted,
4901
4947
  required: true,
4948
+ disabled: readOnly,
4902
4949
  onChange: () => setField(TERMS_ACCEPT_KEY, true),
4903
4950
  className: "h-4 w-4 shrink-0 accent-primary cursor-pointer"
4904
4951
  }
@@ -4915,6 +4962,7 @@ function RegistrationForm({
4915
4962
  type: "radio",
4916
4963
  name: "registration-terms-accept",
4917
4964
  checked: current[TERMS_ACCEPT_KEY] === false,
4965
+ disabled: readOnly,
4918
4966
  onChange: () => setField(TERMS_ACCEPT_KEY, false),
4919
4967
  className: "h-4 w-4 shrink-0 accent-primary cursor-pointer"
4920
4968
  }
@@ -4928,7 +4976,7 @@ function RegistrationForm({
4928
4976
  ] })
4929
4977
  ] }) }),
4930
4978
  error && /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: "text-sm text-destructive font-ui", children: error }),
4931
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center pt-2", children: /* @__PURE__ */ jsxRuntime.jsx(
4979
+ !readOnly && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center pt-2", children: /* @__PURE__ */ jsxRuntime.jsx(
4932
4980
  "button",
4933
4981
  {
4934
4982
  type: "submit",
@@ -7900,6 +7948,66 @@ function ActivityCard({
7900
7948
  }
7901
7949
  );
7902
7950
  }
7951
+ var variantStyles = {
7952
+ info: "bg-[oklch(0.96_0.015_174)] border-[#47bca9] text-[#2e2d2c]",
7953
+ success: "bg-[oklch(0.96_0.055_160)] border-green-500 text-[#2e2d2c]",
7954
+ warning: "bg-amber-50 border-amber-400 text-[#2e2d2c]",
7955
+ error: "bg-red-50 border-red-400 text-[#2e2d2c]"
7956
+ };
7957
+ function Toast({
7958
+ message,
7959
+ variant = "info",
7960
+ onClose,
7961
+ duration = 6e3,
7962
+ className
7963
+ }) {
7964
+ const [mounted, setMounted] = React22__namespace.useState(false);
7965
+ const [visible, setVisible] = React22__namespace.useState(true);
7966
+ React22__namespace.useEffect(() => {
7967
+ setMounted(true);
7968
+ }, []);
7969
+ React22__namespace.useEffect(() => {
7970
+ if (duration === 0) return;
7971
+ const t = setTimeout(() => {
7972
+ setVisible(false);
7973
+ setTimeout(() => onClose == null ? void 0 : onClose(), 300);
7974
+ }, duration);
7975
+ return () => clearTimeout(t);
7976
+ }, [duration, onClose]);
7977
+ if (!mounted || !visible) return null;
7978
+ return reactDom.createPortal(
7979
+ /* @__PURE__ */ jsxRuntime.jsxs(
7980
+ "div",
7981
+ {
7982
+ role: "alert",
7983
+ className: cn(
7984
+ "fixed top-4 left-4 z-[9999] flex items-start gap-3 rounded-lg border px-4 py-3 shadow-lg",
7985
+ "max-w-sm text-sm font-ui leading-snug",
7986
+ "animate-in fade-in slide-in-from-left-4 duration-300",
7987
+ variantStyles[variant],
7988
+ className
7989
+ ),
7990
+ children: [
7991
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1", children: message }),
7992
+ onClose && /* @__PURE__ */ jsxRuntime.jsx(
7993
+ "button",
7994
+ {
7995
+ type: "button",
7996
+ onClick: () => {
7997
+ setVisible(false);
7998
+ setTimeout(() => onClose(), 300);
7999
+ },
8000
+ className: "shrink-0 opacity-60 hover:opacity-100 transition-opacity",
8001
+ "aria-label": "Fechar",
8002
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, { size: 14 })
8003
+ }
8004
+ )
8005
+ ]
8006
+ }
8007
+ ),
8008
+ document.body
8009
+ );
8010
+ }
7903
8011
  function PaymentModalShell({
7904
8012
  open,
7905
8013
  title,
@@ -8608,6 +8716,7 @@ exports.SiteHeader = SiteHeader;
8608
8716
  exports.TERMS_ACCEPT_KEY = TERMS_ACCEPT_KEY;
8609
8717
  exports.TermsSection = TermsSection;
8610
8718
  exports.ThemeToggle = ThemeToggle;
8719
+ exports.Toast = Toast;
8611
8720
  exports.TravellerFormInviteEmail = TravellerFormInviteEmail;
8612
8721
  exports.TripCard = TripCard;
8613
8722
  exports.TripHeader = TripHeader;