@chekinapp/ui 0.2.7 → 0.2.9

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
@@ -44,6 +44,7 @@ __export(index_exports, {
44
44
  AirbnbSearchableSelect: () => AirbnbSearchableSelect,
45
45
  AirbnbSelect: () => AirbnbSelect,
46
46
  AirbnbSwitch: () => AirbnbSwitch,
47
+ AirbnbTimePicker: () => AirbnbTimePicker,
47
48
  Alert: () => Alert,
48
49
  AlertBox: () => AlertBox,
49
50
  AlertDescription: () => AlertDescription,
@@ -605,24 +606,32 @@ var AlertSize = /* @__PURE__ */ ((AlertSize2) => {
605
606
  AlertSize2["L"] = "L";
606
607
  return AlertSize2;
607
608
  })(AlertSize || {});
608
- var getIcon = (type) => ({
609
- ["INFO" /* INFO */]: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.AlertCircle, { className: "relative" }),
610
- ["WARNING" /* WARNING */]: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.TriangleAlert, { className: "relative" }),
611
- ["ERROR" /* ERROR */]: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.XCircle, { className: "relative" }),
612
- ["LIGHT" /* LIGHT */]: null,
613
- ["SUCCESS" /* SUCCESS */]: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Check, { className: "relative" })
614
- })[type];
609
+ var getIcon = (type) => {
610
+ const key = type.toLowerCase();
611
+ const iconProps = {
612
+ className: "relative",
613
+ fill: `var(--alert-box-${key}-icon-fill)`,
614
+ stroke: `var(--alert-box-${key}-icon)`
615
+ };
616
+ return {
617
+ ["INFO" /* INFO */]: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.AlertCircle, { ...iconProps }),
618
+ ["WARNING" /* WARNING */]: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.TriangleAlert, { ...iconProps }),
619
+ ["ERROR" /* ERROR */]: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.XCircle, { ...iconProps }),
620
+ ["LIGHT" /* LIGHT */]: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.AlertCircle, { ...iconProps }),
621
+ ["SUCCESS" /* SUCCESS */]: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Check, { ...iconProps })
622
+ }[type];
623
+ };
615
624
  var sizeClasses = {
616
625
  ["S" /* S */]: "px-3 py-3 text-sm font-medium items-start",
617
626
  ["M" /* M */]: "p-4 text-base font-medium items-start",
618
627
  ["L" /* L */]: "px-6 py-5 items-start"
619
628
  };
620
629
  var typeStyles = {
621
- ["INFO" /* INFO */]: "bg-[var(--alert-box-info-bg)] [&_svg]:text-[var(--alert-box-info-icon)]",
622
- ["WARNING" /* WARNING */]: "bg-[var(--alert-box-warning-bg)] [&_svg]:text-[var(--alert-box-warning-icon)]",
623
- ["ERROR" /* ERROR */]: "bg-[var(--alert-box-error-bg)] [&_svg]:text-[var(--alert-box-error-icon)]",
624
- ["SUCCESS" /* SUCCESS */]: "bg-[var(--alert-box-success-bg)] text-[var(--alert-box-success-text)] [&_svg]:text-[var(--alert-box-success-icon)]",
625
- ["LIGHT" /* LIGHT */]: ""
630
+ ["INFO" /* INFO */]: "border-[color:var(--alert-box-info-border)] bg-[var(--alert-box-info-bg)] text-[color:var(--alert-box-info-text)]",
631
+ ["WARNING" /* WARNING */]: "border-[color:var(--alert-box-warning-border)] bg-[var(--alert-box-warning-bg)] text-[color:var(--alert-box-warning-text)]",
632
+ ["ERROR" /* ERROR */]: "border-[color:var(--alert-box-error-border)] bg-[var(--alert-box-error-bg)] text-[color:var(--alert-box-error-text)]",
633
+ ["SUCCESS" /* SUCCESS */]: "border-[color:var(--alert-box-success-border)] bg-[var(--alert-box-success-bg)] text-[color:var(--alert-box-success-text)]",
634
+ ["LIGHT" /* LIGHT */]: "border-[color:var(--alert-box-light-border)] bg-[var(--alert-box-light-bg)] text-[color:var(--alert-box-light-text)]"
626
635
  };
627
636
  function AlertBox({
628
637
  children,
@@ -636,7 +645,7 @@ function AlertBox({
636
645
  {
637
646
  "data-slot": "alert-box",
638
647
  className: cn(
639
- "flex gap-3 rounded-[var(--alert-box-radius)] [&_svg]:h-5 [&_svg]:w-5 [&_svg]:shrink-0",
648
+ "flex gap-3 rounded-[var(--alert-box-radius)] border-solid border-[length:var(--alert-box-border-width)] [&_svg]:h-5 [&_svg]:w-5 [&_svg]:shrink-0",
640
649
  sizeClasses[size],
641
650
  typeStyles[type],
642
651
  className
@@ -8346,9 +8355,9 @@ var LinkInternal = (0, import_react53.forwardRef)(
8346
8355
  {
8347
8356
  ref,
8348
8357
  className: cn(
8349
- "inline cursor-pointer text-[var(--button-link-text)] no-underline transition-all duration-75 ease-in-out",
8358
+ "inline cursor-pointer text-[var(--link-text-color)] [text-decoration:var(--link-text-decoration)] transition-all duration-75 ease-in-out",
8350
8359
  !disabled && "hover:opacity-80 active:opacity-100",
8351
- disabled && "cursor-not-allowed text-[var(--chekin-neutral-400)]",
8360
+ disabled && "cursor-not-allowed text-[var(--link-disabled-text-color)]",
8352
8361
  "[&_img]:inline [&_img]:align-middle [&_svg]:relative [&_svg]:bottom-[1px] [&_svg]:ml-1 [&_svg]:inline [&_svg]:align-middle",
8353
8362
  className
8354
8363
  ),
@@ -18915,13 +18924,13 @@ var import_date_fns2 = require("date-fns");
18915
18924
  var import_date_fns = require("date-fns");
18916
18925
  var DEFAULT_DISPLAY_FORMAT = "dd-MM-yyyy";
18917
18926
  var SUPPORTED_FORMATS = ["dd-MM-yyyy", "dd.MM.yyyy", "dd/MM/yyyy"];
18918
- var formatDate = (format2 = DEFAULT_DISPLAY_FORMAT) => (date) => (0, import_date_fns.format)(date, format2);
18927
+ var formatDate = (format3 = DEFAULT_DISPLAY_FORMAT) => (date) => (0, import_date_fns.format)(date, format3);
18919
18928
  var parseDate = (displayFormat) => (dateStr) => {
18920
18929
  if (!dateStr) return void 0;
18921
18930
  const formats = displayFormat ? Array.from(/* @__PURE__ */ new Set([...SUPPORTED_FORMATS, displayFormat])) : SUPPORTED_FORMATS;
18922
- for (const format2 of formats) {
18923
- const parsed = (0, import_date_fns.parse)(dateStr, format2, /* @__PURE__ */ new Date());
18924
- if ((0, import_date_fns.isValid)(parsed) && (0, import_date_fns.format)(parsed, format2) === dateStr) {
18931
+ for (const format3 of formats) {
18932
+ const parsed = (0, import_date_fns.parse)(dateStr, format3, /* @__PURE__ */ new Date());
18933
+ if ((0, import_date_fns.isValid)(parsed) && (0, import_date_fns.format)(parsed, format3) === dateStr) {
18925
18934
  return parsed;
18926
18935
  }
18927
18936
  }
@@ -19022,14 +19031,14 @@ function useRangeValue({
19022
19031
  var React66 = __toESM(require("react"), 1);
19023
19032
 
19024
19033
  // src/fields/date-range-picker/utils/inputFormat.ts
19025
- function parseDateInputFormat(format2) {
19034
+ function parseDateInputFormat(format3) {
19026
19035
  const tokens = [];
19027
19036
  let i = 0;
19028
- while (i < format2.length) {
19029
- const ch = format2[i];
19037
+ while (i < format3.length) {
19038
+ const ch = format3[i];
19030
19039
  if (/[a-zA-Z]/.test(ch)) {
19031
19040
  let len = 1;
19032
- while (i + len < format2.length && format2[i + len] === ch) len++;
19041
+ while (i + len < format3.length && format3[i + len] === ch) len++;
19033
19042
  tokens.push({ type: "digits", length: len });
19034
19043
  i += len;
19035
19044
  } else {
@@ -19101,8 +19110,8 @@ function autoFormatDateInput(raw, tokens) {
19101
19110
  var countDigits = (text) => text.replace(/\D/g, "").length;
19102
19111
  function useRangeTextInputs({
19103
19112
  value,
19104
- format: format2,
19105
- parse: parse3,
19113
+ format: format3,
19114
+ parse: parse4,
19106
19115
  displayFormat,
19107
19116
  onCommit,
19108
19117
  onBlur,
@@ -19114,23 +19123,23 @@ function useRangeTextInputs({
19114
19123
  [displayFormat]
19115
19124
  );
19116
19125
  const maxDigits = React66.useMemo(() => getMaxDigits(tokens), [tokens]);
19117
- const [fromText, setFromText] = React66.useState(value?.from ? format2(value.from) : "");
19118
- const [toText, setToText] = React66.useState(value?.to ? format2(value.to) : "");
19126
+ const [fromText, setFromText] = React66.useState(value?.from ? format3(value.from) : "");
19127
+ const [toText, setToText] = React66.useState(value?.to ? format3(value.to) : "");
19119
19128
  React66.useEffect(() => {
19120
- setFromText(value?.from ? format2(value.from) : "");
19121
- setToText(value?.to ? format2(value.to) : "");
19122
- }, [format2, value?.from, value?.to]);
19129
+ setFromText(value?.from ? format3(value.from) : "");
19130
+ setToText(value?.to ? format3(value.to) : "");
19131
+ }, [format3, value?.from, value?.to]);
19123
19132
  const handleFromChange = React66.useCallback(
19124
19133
  (raw) => {
19125
19134
  const formatted = autoFormatDateInput(raw, tokens);
19126
19135
  const wasComplete = countDigits(fromText) === maxDigits;
19127
19136
  const isComplete = countDigits(formatted) === maxDigits;
19128
19137
  setFromText(formatted);
19129
- if (!wasComplete && isComplete && parse3(formatted)) {
19138
+ if (!wasComplete && isComplete && parse4(formatted)) {
19130
19139
  setTimeout(() => onFromComplete?.(), 0);
19131
19140
  }
19132
19141
  },
19133
- [fromText, maxDigits, onFromComplete, parse3, tokens]
19142
+ [fromText, maxDigits, onFromComplete, parse4, tokens]
19134
19143
  );
19135
19144
  const handleToChange = React66.useCallback(
19136
19145
  (raw) => {
@@ -19138,11 +19147,11 @@ function useRangeTextInputs({
19138
19147
  const wasComplete = countDigits(toText) === maxDigits;
19139
19148
  const isComplete = countDigits(formatted) === maxDigits;
19140
19149
  setToText(formatted);
19141
- if (!wasComplete && isComplete && parse3(formatted)) {
19150
+ if (!wasComplete && isComplete && parse4(formatted)) {
19142
19151
  setTimeout(() => onToComplete?.(), 0);
19143
19152
  }
19144
19153
  },
19145
- [maxDigits, onToComplete, parse3, toText, tokens]
19154
+ [maxDigits, onToComplete, parse4, toText, tokens]
19146
19155
  );
19147
19156
  const handleFromBlur = React66.useCallback(() => {
19148
19157
  if (!fromText) {
@@ -19151,16 +19160,16 @@ function useRangeTextInputs({
19151
19160
  onBlur?.(next);
19152
19161
  return void 0;
19153
19162
  }
19154
- const parsed = parse3(fromText);
19163
+ const parsed = parse4(fromText);
19155
19164
  if (parsed) {
19156
19165
  const next = { from: parsed, to: value?.to };
19157
19166
  onCommit(next);
19158
19167
  onBlur?.(next);
19159
19168
  return parsed;
19160
19169
  }
19161
- setFromText(value?.from ? format2(value.from) : "");
19170
+ setFromText(value?.from ? format3(value.from) : "");
19162
19171
  return void 0;
19163
- }, [format2, fromText, onBlur, onCommit, parse3, value]);
19172
+ }, [format3, fromText, onBlur, onCommit, parse4, value]);
19164
19173
  const handleToBlur = React66.useCallback(() => {
19165
19174
  if (!toText) {
19166
19175
  const next = { from: value?.from, to: void 0 };
@@ -19168,15 +19177,15 @@ function useRangeTextInputs({
19168
19177
  onBlur?.(next);
19169
19178
  return;
19170
19179
  }
19171
- const parsed = parse3(toText);
19180
+ const parsed = parse4(toText);
19172
19181
  if (parsed) {
19173
19182
  const next = { from: value?.from, to: parsed };
19174
19183
  onCommit(next);
19175
19184
  onBlur?.(next);
19176
19185
  return;
19177
19186
  }
19178
- setToText(value?.to ? format2(value.to) : "");
19179
- }, [format2, onBlur, onCommit, parse3, toText, value]);
19187
+ setToText(value?.to ? format3(value.to) : "");
19188
+ }, [format3, onBlur, onCommit, parse4, toText, value]);
19180
19189
  return {
19181
19190
  fromText,
19182
19191
  toText,
@@ -20361,7 +20370,7 @@ function AirbnbFieldHelperText({
20361
20370
  {
20362
20371
  id,
20363
20372
  className: cn(
20364
- "mt-2 text-[12px] font-normal leading-5 text-[var(--chekin-airbnb-gray-text)]",
20373
+ "mt-2 text-[12px] leading-5 text-[var(--chekin-airbnb-gray-text)]",
20365
20374
  disabled && "opacity-50",
20366
20375
  className
20367
20376
  ),
@@ -22762,6 +22771,62 @@ var AirbnbSwitch = React84.forwardRef(
22762
22771
  }
22763
22772
  );
22764
22773
  AirbnbSwitch.displayName = "AirbnbSwitch";
22774
+
22775
+ // src/airbnb-fields/time-picker/TimePicker.tsx
22776
+ var React85 = __toESM(require("react"), 1);
22777
+ var import_date_fns6 = require("date-fns");
22778
+ var import_jsx_runtime198 = require("react/jsx-runtime");
22779
+ var SHORT_TIME_FORMAT2 = "HH:mm";
22780
+ function parseTime2(value) {
22781
+ return (0, import_date_fns6.parse)(value, SHORT_TIME_FORMAT2, /* @__PURE__ */ new Date());
22782
+ }
22783
+ function getRange2(settings) {
22784
+ const min = parseTime2(settings.min_time);
22785
+ const max = settings.max_time === "00:00" && settings.addNextDay ? (0, import_date_fns6.addDays)(parseTime2(settings.max_time), 1) : parseTime2(settings.max_time);
22786
+ return { min, max };
22787
+ }
22788
+ function buildOptions2(settings) {
22789
+ const interval_unit = settings.interval_unit ?? "M";
22790
+ const interval = settings.interval ?? (interval_unit === "H" ? 1 : 60);
22791
+ const min_time = settings.min_time ?? "00:00";
22792
+ const max_time = settings.max_time ?? (interval_unit === "H" ? "23:00" : "23:00");
22793
+ const addNextDay = settings.addNextDay !== false;
22794
+ const { min, max } = getRange2({ interval_unit, interval, min_time, max_time, addNextDay });
22795
+ const options = [];
22796
+ let current = new Date(min.getTime());
22797
+ while (current.getTime() <= max.getTime()) {
22798
+ const text = (0, import_date_fns6.format)(current, SHORT_TIME_FORMAT2);
22799
+ options.push({ value: text, label: text });
22800
+ current = interval_unit === "H" ? (0, import_date_fns6.addHours)(current, interval) : (0, import_date_fns6.addMinutes)(current, interval);
22801
+ }
22802
+ return options;
22803
+ }
22804
+ var FORMAT_SETTINGS2 = {
22805
+ time: { interval_unit: "M", interval: 30, min_time: "00:00", max_time: "23:30" },
22806
+ timeEach15Minutes: {
22807
+ interval_unit: "M",
22808
+ interval: 15,
22809
+ min_time: "00:00",
22810
+ max_time: "23:45"
22811
+ },
22812
+ timeEach30Minutes: {
22813
+ interval_unit: "M",
22814
+ interval: 30,
22815
+ min_time: "00:00",
22816
+ max_time: "23:30"
22817
+ },
22818
+ hours: { interval_unit: "H", interval: 1, min_time: "00:00", max_time: "23:00" }
22819
+ };
22820
+ var AirbnbTimePicker = React85.forwardRef(
22821
+ function AirbnbTimePicker2({ format: formatName = "time", timeSettings, options, ...selectProps }, ref) {
22822
+ const resolvedOptions = React85.useMemo(() => {
22823
+ if (options) return options;
22824
+ const settings = timeSettings ?? FORMAT_SETTINGS2[formatName];
22825
+ return buildOptions2(settings);
22826
+ }, [formatName, options, timeSettings]);
22827
+ return /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(AirbnbSelect, { ref, ...selectProps, options: resolvedOptions });
22828
+ }
22829
+ );
22765
22830
  // Annotate the CommonJS export names for ESM import in node:
22766
22831
  0 && (module.exports = {
22767
22832
  ALERT_BOX_VARIANTS,
@@ -22778,6 +22843,7 @@ AirbnbSwitch.displayName = "AirbnbSwitch";
22778
22843
  AirbnbSearchableSelect,
22779
22844
  AirbnbSelect,
22780
22845
  AirbnbSwitch,
22846
+ AirbnbTimePicker,
22781
22847
  Alert,
22782
22848
  AlertBox,
22783
22849
  AlertDescription,